## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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 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     if (!text || !*text) return;
    00051
    00052     int realColorFG;
    00053     uint8 alphaFG;
    00054     SplitAlpha (fg, realColorFG, alphaFG);
    00055     int realColorBG;
    00056     uint8 alphaBG;
    00057     SplitAlpha (bg, realColorBG, alphaBG);
    00058
    00059     if (alphaBG == 0)
    00060     {
    00061       if (alphaFG == 0)
    00062         return;
    00063       realColorBG = realColorFG;
    00064       if (alphaFG == 255)
    00065       {
    00066         csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerNoop<Tpixel>,
    00067           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG,
    00068           realColorBG, alphaBG, text, flags);
    00069       }
    00070       else
    00071       {
    00072         csG2DDrawText<Tpixel, Tpixmixer, csPixMixerNoop<Tpixel>,
    00073           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG,
    00074           realColorBG, alphaBG, text, flags);
    00075       }
    00076     }
    00077     else if (alphaBG == 255)
    00078     {
    00079       if (alphaFG == 0)
    00080       {
    00081         csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, csPixMixerCopy<Tpixel>,
    00082           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG,
    00083           realColorBG, alphaBG, text, flags);
    00084       }
    00085       else if (alphaFG == 255)
    00086       {
    00087         csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, csPixMixerCopy<Tpixel>,
    00088           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG,
    00089           realColorBG, alphaBG, text, flags);
    00090       }
    00091       else
    00092       {
    00093         csG2DDrawText<Tpixel, Tpixmixer, csPixMixerCopy<Tpixel>,
    00094           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG,
    00095           realColorBG, alphaBG, text, flags);
    00096       }
    00097     }
    00098     else
    00099     {
    00100       if (alphaFG == 0)
    00101       {
    00102         csG2DDrawText<Tpixel, csPixMixerNoop<Tpixel>, Tpixmixer,
    00103           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG,
    00104           realColorBG, alphaBG, text, flags);
    00105       }
    00106       else if (alphaFG == 255)
    00107       {
    00108         csG2DDrawText<Tpixel, csPixMixerCopy<Tpixel>, Tpixmixer,
    00109           Tpixmixer>::DrawText (this, font, x, y, realColorFG, alphaFG,
    00110           realColorBG, alphaBG, text, flags);
    00111       }
    00112       else
    00113       {
    00114         csG2DDrawText<Tpixel, Tpixmixer, Tpixmixer, Tpixmixer>::DrawText (
    00115           this, font, x, y, realColorFG, alphaFG, realColorBG, alphaBG, text,
    00116           flags);
    00117       }
    00118     }
    00119   }
    00120 };
    00121
    00124 #endif // __CS_CSPLUGINCOMMON_CANVAS_SOFTFONTCACHEIMPL_H__