Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
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 public: 00044 csSoftFontCacheImpl (csGraphics2D* G2D) : csSoftFontCache (G2D) 00045 { 00046 } 00047 virtual void WriteString (iFont *font, int x, int y, int fg, int bg, 00048 const utf8_char* text, uint flags) 00049 { 00050 int realColorFG; 00051 uint8 alphaFG; 00052 SplitAlpha (fg, realColorFG, alphaFG); 00053 int realColorBG; 00054 uint8 alphaBG; 00055 SplitAlpha (bg, realColorBG, alphaBG); 00056 00057 if (alphaBG == 0) 00058 { 00059 if (alphaFG == 0) 00060 return; 00061 realColorBG = realColorFG; 00062 if (alphaFG == 255) 00063 { 00064 csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerNoop<Tpixel>, 00065 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00066 realColorBG, alphaBG, text, flags); 00067 } 00068 else 00069 { 00070 csG2DDrawText<Tpixel, Tpixmixer, csPixMixerNoop<Tpixel>, 00071 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00072 realColorBG, alphaBG, text, flags); 00073 } 00074 } 00075 else if (alphaBG == 255) 00076 { 00077 if (alphaFG == 0) 00078 { 00079 csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, csPixMixerCopy<Tpixel>, 00080 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00081 realColorBG, alphaBG, text, flags); 00082 } 00083 else if (alphaFG == 255) 00084 { 00085 csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerCopy<Tpixel>, 00086 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00087 realColorBG, alphaBG, text, flags); 00088 } 00089 else 00090 { 00091 csG2DDrawText<Tpixel, Tpixmixer, csPixMixerCopy<Tpixel>, 00092 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00093 realColorBG, alphaBG, text, flags); 00094 } 00095 } 00096 else 00097 { 00098 if (alphaFG == 0) 00099 { 00100 csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, Tpixmixer, 00101 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00102 realColorBG, alphaBG, text, flags); 00103 } 00104 else if (alphaFG == 255) 00105 { 00106 csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, Tpixmixer, 00107 Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG, 00108 realColorBG, alphaBG, text, flags); 00109 } 00110 else 00111 { 00112 csG2DDrawText<Tpixel, Tpixmixer, Tpixmixer, Tpixmixer>::DrawText ( 00113 this, font, x, y, realColorFG, alphaFG, realColorBG, alphaBG, text, 00114 flags); 00115 } 00116 } 00117 } 00118 }; 00119 00122 #endif // __CS_CSPLUGINCOMMON_CANVAS_SOFTFONTCACHEIMPL_H__
Generated for Crystal Space by doxygen 1.4.4