4 * Copyright (C) 2005-2013 Team XBMC
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with XBMC; see the file COPYING. If not, see
19 * <http://www.gnu.org/licenses/>.
23 #include "TeletextDefines.h"
24 #include "guilib/Key.h"
25 #include "guilib/GUITexture.h"
29 #include FT_FREETYPE_H
31 #include FT_CACHE_SMALL_BITMAPS_H
33 typedef enum /* object type */
40 class CTeletextDecoder
44 virtual ~CTeletextDecoder(void);
46 bool NeedRendering() { return m_updateTexture; }
47 void RenderingDone() { m_updateTexture = false; }
48 color_t *GetTextureBuffer() { return m_TextureBuffer + (m_RenderInfo.Width*m_YOffset); }
49 int GetHeight() { return m_RenderInfo.Height; }
50 int GetWidth() { return m_RenderInfo.Width; }
54 bool HandleAction(const CAction &action);
57 void PageInput(int Number);
58 void GetNextPageOne(bool up);
59 void GetNextSubPage(int offset);
60 void SwitchZoomMode();
61 void SwitchTranspMode();
62 void SwitchHintMode();
63 void ColorKey(int target);
64 void StartPageCatching();
65 void StopPageCatching();
66 void CatchNextPage(int firstlineinc, int inc);
67 void RenderCatchedPage();
68 void DoFlashing(int startrow);
69 void DoRenderPage(int startrow, int national_subset_bak);
72 int TopText_GetNext(int startpage, int up, int findgroup);
73 void Showlink(int column, int linkpage);
75 void RenderCharFB(int Char, TextPageAttr_t *Attribute);
76 void RenderCharBB(int Char, TextPageAttr_t *Attribute);
78 void SetFontWidth(int newWidth);
79 int GetCurFontWidth();
80 void SetPosX(int column);
81 void ClearBB(color_t Color);
82 void ClearFB(color_t Color);
83 void FillBorder(color_t Color);
84 void FillRect(color_t *buffer, int xres, int x, int y, int w, int h, color_t Color);
85 void DrawVLine(color_t *lfb, int xres, int x, int y, int l, color_t color);
86 void DrawHLine(color_t *lfb, int xres,int x, int y, int l, color_t color);
87 void FillRectMosaicSeparated(color_t *lfb, int xres,int x, int y, int w, int h, color_t fgcolor, color_t bgcolor, int set);
88 void FillTrapez(color_t *lfb, int xres,int x0, int y0, int l0, int xoffset1, int h, int l1, color_t color);
89 void FlipHorz(color_t *lfb, int xres,int x, int y, int w, int h);
90 void FlipVert(color_t *lfb, int xres,int x, int y, int w, int h);
91 int ShapeCoord(int param, int curfontwidth, int curfontheight);
92 void DrawShape(color_t *lfb, int xres, int x, int y, int shapenumber, int curfontwidth, int fontheight, int curfontheight, color_t fgcolor, color_t bgcolor, bool clear);
93 void RenderDRCS(int xres,
94 unsigned char *s, /* pointer to char data, parity undecoded */
95 color_t *d, /* pointer to frame buffer of top left pixel */
96 unsigned char *ax, /* array[0..12] of x-offsets, array[0..10] of y-offsets for each pixel */
97 color_t fgcolor, color_t bgcolor);
98 void RenderCharIntern(TextRenderInfo_t* RenderInfo, int Char, TextPageAttr_t *Attribute, int zoom, int yoffset);
99 int RenderChar(color_t *buffer, // pointer to render buffer, min. fontheight*2*xres
100 int xres, // length of 1 line in render buffer
101 int Char, // character to render
102 int *pPosX, // left border for rendering relative to *buffer, will be set to right border after rendering
103 int PosY, // vertical position of char in *buffer
104 TextPageAttr_t *Attribute, // Attributes of Char
105 bool zoom, // 1= character will be rendered in double height
106 int curfontwidth, // rendering width of character
107 int curfontwidth2, // rendering width of next character (needed for doublewidth)
108 int fontheight, // height of character
109 bool transpmode, // 1= transparent display
110 unsigned char *axdrcs, // width and height of DRCS-chars
112 TextPageinfo_t* DecodePage(bool showl25, // 1=decode Level2.5-graphics
113 unsigned char* PageChar, // page buffer, min. 25*40
114 TextPageAttr_t *PageAtrb, // attribut buffer, min 25*40
115 bool HintMode, // 1=show hidden information
116 bool showflof); // 1=decode FLOF-line
117 void Eval_l25(unsigned char* page_char, TextPageAttr_t *PageAtrb, bool HintMode);
118 void Eval_Object(int iONr, TextCachedPage_t *pstCachedPage,
119 unsigned char *pAPx, unsigned char *pAPy,
120 unsigned char *pAPx0, unsigned char *pAPy0,
121 tObjType ObjType, unsigned char* pagedata, unsigned char* page_char, TextPageAttr_t* PageAtrb);
122 void Eval_NumberedObject(int p, int s, int packet, int triplet, int high,
123 unsigned char *pAPx, unsigned char *pAPy,
124 unsigned char *pAPx0, unsigned char *pAPy0, unsigned char* page_char, TextPageAttr_t* PageAtrb);
125 int Eval_Triplet(int iOData, TextCachedPage_t *pstCachedPage,
126 unsigned char *pAPx, unsigned char *pAPy,
127 unsigned char *pAPx0, unsigned char *pAPy0,
128 unsigned char *drcssubp, unsigned char *gdrcssubp,
129 signed char *endcol, TextPageAttr_t *attrPassive, unsigned char* pagedata, unsigned char* page_char, TextPageAttr_t* PageAtrb);
130 int iTripletNumber2Data(int iONr, TextCachedPage_t *pstCachedPage, unsigned char* pagedata);
131 int SetNational(unsigned char sec);
133 void SetColors(unsigned short *pcolormap, int offset, int number);
134 color_t GetColorRGB(enumTeletextColor ttc);
136 static FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface);
138 CStdString m_teletextFont; /* Path to teletext font */
139 int m_YOffset; /* Swap position for Front buffer and Back buffer */
140 color_t *m_TextureBuffer; /* Texture buffer to hold generated data */
141 bool m_updateTexture; /* Update the texture if set */
142 char prevHeaderPage; /* Needed for texture update if header is changed */
143 char prevTimeSec; /* Needed for Time string update */
145 int m_CatchRow; /* for page catching */
146 int m_CatchCol; /* " " " */
147 int m_CatchedPage; /* " " " */
148 int m_PCOldRow; /* " " " */
149 int m_PCOldCol; /* " " " */
151 FT_Library m_Library; /* FreeType 2 data */
152 FTC_Manager m_Manager; /* " " " */
153 FTC_SBitCache m_Cache; /* " " " */
154 FTC_SBit m_sBit; /* " " " */
155 FT_Face m_Face; /* " " " */
156 FTC_ImageTypeRec m_TypeTTF; /* " " " */
157 int m_Ascender; /* " " " */
159 int m_TempPage; /* Temporary page number for number input */
160 int m_LastPage; /* Last selected Page */
161 TextCacheStruct_t* m_txtCache; /* Text cache generated by the DVDPLayer if Teletext present */
162 TextRenderInfo_t m_RenderInfo; /* Rendering information of displayed Teletext page */