CrystalSpace

Public API Reference

csplugincommon/canvas/softfontcacheimpl.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2004 by Jorrit Tyberghein
00003               (C) 2004 by Frank Richter
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public
00016     License along with this library; if not, write to the Free
00017     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 #ifndef __CS_CSPLUGINCOMMON_CANVAS_SOFTFONTCACHEIMPL_H__
00021 #define __CS_CSPLUGINCOMMON_CANVAS_SOFTFONTCACHEIMPL_H__
00022 
00027 #include "graph2d.h"
00028 #include "csplugincommon/canvas/draw_text.h"
00029 
00040 template <class Tpixel, class Tpixmixer>
00041 class csSoftFontCacheImpl : public csSoftFontCache
00042 {
00043   void WriteString (iFont *font, int x, int y, int fg, int bg, 
00044     const void* text, bool isWide, uint flags)
00045   {
00046     int realColorFG;
00047     uint8 alphaFG;
00048     SplitAlpha (fg, realColorFG, alphaFG);
00049     int realColorBG;
00050     uint8 alphaBG;
00051     SplitAlpha (bg, realColorBG, alphaBG);
00052 
00053     if (alphaBG == 0)
00054     {
00055       if (alphaFG == 0)
00056         return;
00057       realColorBG = realColorFG;
00058       if (alphaFG == 255)
00059       {
00060         csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerNoop<Tpixel>, 
00061           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 
00062           realColorBG, alphaBG, text, isWide, flags);
00063       }
00064       else
00065       {
00066         csG2DDrawText<Tpixel, Tpixmixer, csPixMixerNoop<Tpixel>, 
00067           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 
00068           realColorBG, alphaBG, text, isWide, flags);
00069       }
00070     }
00071     else if (alphaBG == 255)
00072     {
00073       if (alphaFG == 0)
00074       {
00075         csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, csPixMixerCopy<Tpixel>, 
00076           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 
00077           realColorBG, alphaBG, text, isWide, flags);
00078       }
00079       else if (alphaFG == 255)
00080       {
00081         csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerCopy<Tpixel>, 
00082           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 
00083           realColorBG, alphaBG, text, isWide, flags);
00084       }
00085       else
00086       {
00087         csG2DDrawText<Tpixel, Tpixmixer, csPixMixerCopy<Tpixel>, 
00088           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 
00089           realColorBG, alphaBG, text, isWide, flags);
00090       }
00091     }
00092     else
00093     {
00094       if (alphaFG == 0)
00095       {
00096         csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, Tpixmixer, 
00097           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 
00098           realColorBG, alphaBG, text, isWide, flags);
00099       }
00100       else if (alphaFG == 255)
00101       {
00102         csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, Tpixmixer, 
00103           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 
00104           realColorBG, alphaBG, text, isWide, flags);
00105       }
00106       else
00107       {
00108         csG2DDrawText<Tpixel, Tpixmixer, Tpixmixer, Tpixmixer>::DrawText (
00109           this, font, x, y, realColorFG, alphaFG, realColorBG, alphaBG, text, 
00110           isWide, flags);
00111       }
00112     }
00113   }
00114 public:
00115   csSoftFontCacheImpl (csGraphics2D* G2D) : csSoftFontCache (G2D)
00116   {
00117   }
00118   virtual void WriteString (iFont *font, int x, int y, int fg, int bg, 
00119     const utf8_char* text, uint flags)
00120   {
00121     if (!text || !*text) return;
00122     
00123     WriteString (font, x, y, fg, bg, text, false, flags);
00124   }
00125   virtual void WriteString (iFont *font, int x, int y, int fg, int bg, 
00126     const wchar_t* text, uint flags)
00127   {
00128     if (!text || !*text) return;
00129     
00130     WriteString (font, x, y, fg, bg, text, true, flags);
00131   }
00132 };
00133 
00136 #endif // __CS_CSPLUGINCOMMON_CANVAS_SOFTFONTCACHEIMPL_H__

Generated for Crystal Space 1.0.2 by doxygen 1.4.7