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 x += vpX; y += vpY; 00047 00048 int realColorFG; 00049 uint8 alphaFG; 00050 SplitAlpha (fg, realColorFG, alphaFG); 00051 int realColorBG; 00052 uint8 alphaBG; 00053 SplitAlpha (bg, realColorBG, alphaBG); 00054 00055 if (alphaBG == 0) 00056 { 00057 if (alphaFG == 0) 00058 return; 00059 realColorBG = realColorFG; 00060 if (alphaFG == 255) 00061 { 00062 csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerNoop<Tpixel>, 00063 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00064 realColorBG, alphaBG, text, isWide, flags); 00065 } 00066 else 00067 { 00068 csG2DDrawText<Tpixel, Tpixmixer, csPixMixerNoop<Tpixel>, 00069 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00070 realColorBG, alphaBG, text, isWide, flags); 00071 } 00072 } 00073 else if (alphaBG == 255) 00074 { 00075 if (alphaFG == 0) 00076 { 00077 csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, csPixMixerCopy<Tpixel>, 00078 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00079 realColorBG, alphaBG, text, isWide, flags); 00080 } 00081 else if (alphaFG == 255) 00082 { 00083 csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerCopy<Tpixel>, 00084 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00085 realColorBG, alphaBG, text, isWide, flags); 00086 } 00087 else 00088 { 00089 csG2DDrawText<Tpixel, Tpixmixer, csPixMixerCopy<Tpixel>, 00090 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00091 realColorBG, alphaBG, text, isWide, flags); 00092 } 00093 } 00094 else 00095 { 00096 if (alphaFG == 0) 00097 { 00098 csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, Tpixmixer, 00099 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00100 realColorBG, alphaBG, text, isWide, flags); 00101 } 00102 else if (alphaFG == 255) 00103 { 00104 csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, Tpixmixer, 00105 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00106 realColorBG, alphaBG, text, isWide, flags); 00107 } 00108 else 00109 { 00110 csG2DDrawText<Tpixel, Tpixmixer, Tpixmixer, Tpixmixer>::DrawText ( 00111 this, font, x, y, realColorFG, alphaFG, realColorBG, alphaBG, text, 00112 isWide, flags); 00113 } 00114 } 00115 } 00116 public: 00117 csSoftFontCacheImpl (csGraphics2D* G2D) : csSoftFontCache (G2D) 00118 { 00119 } 00120 virtual void WriteString (iFont *font, int x, int y, int fg, int bg, 00121 const utf8_char* text, uint flags) 00122 { 00123 if (!text || !*text) return; 00124 00125 WriteString (font, x, y, fg, bg, text, false, flags); 00126 } 00127 virtual void WriteString (iFont *font, int x, int y, int fg, int bg, 00128 const wchar_t* text, uint flags) 00129 { 00130 if (!text || !*text) return; 00131 00132 WriteString (font, x, y, fg, bg, text, true, flags); 00133 } 00134 }; 00135 00138 #endif // __CS_CSPLUGINCOMMON_CANVAS_SOFTFONTCACHEIMPL_H__
Generated for Crystal Space 1.4.0 by doxygen 1.5.8