xbmc
Teletext.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "TeletextDefines.h"
12 #include "guilib/GUITexture.h"
13 #include "utils/ColorUtils.h"
14 
15 // stuff for freetype
16 #include <ft2build.h>
17 
18 #ifdef TARGET_WINDOWS_STORE
19 #define generic GenericFromFreeTypeLibrary
20 #endif
21 
22 #include FT_FREETYPE_H
23 #include FT_CACHE_H
24 #include FT_CACHE_SMALL_BITMAPS_H
25 
26 class CAction;
27 
28 typedef enum /* object type */
29 {
30  OBJ_PASSIVE,
31  OBJ_ACTIVE,
32  OBJ_ADAPTIVE
33 } tObjType;
34 
36 {
37 public:
39  virtual ~CTeletextDecoder(void);
40 
41  bool NeedRendering() { return m_updateTexture; }
42  void RenderingDone() { m_updateTexture = false; }
43  UTILS::COLOR::Color* GetTextureBuffer()
44  {
45  return m_TextureBuffer + (m_RenderInfo.Width * m_YOffset);
46  }
47  int GetHeight() { return m_RenderInfo.Height; }
48  int GetWidth() { return m_RenderInfo.Width; }
49  bool InitDecoder();
50  void EndDecoder();
51  void RenderPage();
52  bool HandleAction(const CAction &action);
53 
54 private:
55  void PageInput(int Number);
56  void GetNextPageOne(bool up);
57  void GetNextSubPage(int offset);
58  bool IsSubtitlePage(int pageNumber) const;
59  void SwitchZoomMode();
60  void SwitchTranspMode();
61  void SwitchHintMode();
62  void ColorKey(int target);
63  void StartPageCatching();
64  void StopPageCatching();
65  void CatchNextPage(int firstlineinc, int inc);
66  void RenderCatchedPage();
67  void DoFlashing(int startrow);
68  void DoRenderPage(int startrow, int national_subset_bak);
69  void Decode_BTT();
70  void Decode_ADIP();
71  int TopText_GetNext(int startpage, int up, int findgroup);
72  void Showlink(int column, int linkpage);
73  void CreateLine25();
74  void RenderCharFB(int Char, TextPageAttr_t *Attribute);
75  void RenderCharBB(int Char, TextPageAttr_t *Attribute);
76  void CopyBB2FB();
77  void SetFontWidth(int newWidth);
78  int GetCurFontWidth();
79  void SetPosX(int column);
80  void ClearBB(UTILS::COLOR::Color Color);
81  void ClearFB(UTILS::COLOR::Color Color);
82  void FillBorder(UTILS::COLOR::Color Color);
83  void FillRect(
84  UTILS::COLOR::Color* buffer, int xres, int x, int y, int w, int h, UTILS::COLOR::Color Color);
85  void DrawVLine(
86  UTILS::COLOR::Color* lfb, int xres, int x, int y, int l, UTILS::COLOR::Color color);
87  void DrawHLine(
88  UTILS::COLOR::Color* lfb, int xres, int x, int y, int l, UTILS::COLOR::Color color);
89  void FillRectMosaicSeparated(UTILS::COLOR::Color* lfb,
90  int xres,
91  int x,
92  int y,
93  int w,
94  int h,
95  UTILS::COLOR::Color fgcolor,
96  UTILS::COLOR::Color bgcolor,
97  int set);
98  void FillTrapez(UTILS::COLOR::Color* lfb,
99  int xres,
100  int x0,
101  int y0,
102  int l0,
103  int xoffset1,
104  int h,
105  int l1,
106  UTILS::COLOR::Color color);
107  void FlipHorz(UTILS::COLOR::Color* lfb, int xres, int x, int y, int w, int h);
108  void FlipVert(UTILS::COLOR::Color* lfb, int xres, int x, int y, int w, int h);
109  int ShapeCoord(int param, int curfontwidth, int curfontheight);
110  void DrawShape(UTILS::COLOR::Color* lfb,
111  int xres,
112  int x,
113  int y,
114  int shapenumber,
115  int curfontwidth,
116  int fontheight,
117  int curfontheight,
118  UTILS::COLOR::Color fgcolor,
119  UTILS::COLOR::Color bgcolor,
120  bool clear);
121  void RenderDRCS(
122  int xres,
123  unsigned char* s, /* pointer to char data, parity undecoded */
124  UTILS::COLOR::Color* d, /* pointer to frame buffer of top left pixel */
125  unsigned char* ax, /* array[0..12] of x-offsets, array[0..10] of y-offsets for each pixel */
126  UTILS::COLOR::Color fgcolor,
127  UTILS::COLOR::Color bgcolor);
128  void RenderCharIntern(TextRenderInfo_t* RenderInfo, int Char, TextPageAttr_t *Attribute, int zoom, int yoffset);
129  int RenderChar(
130  UTILS::COLOR::Color* buffer, // pointer to render buffer, min. fontheight*2*xres
131  int xres, // length of 1 line in render buffer
132  int Char, // character to render
133  int*
134  pPosX, // left border for rendering relative to *buffer, will be set to right border after rendering
135  int PosY, // vertical position of char in *buffer
136  TextPageAttr_t* Attribute, // Attributes of Char
137  bool zoom, // 1= character will be rendered in double height
138  int curfontwidth, // rendering width of character
139  int curfontwidth2, // rendering width of next character (needed for doublewidth)
140  int fontheight, // height of character
141  bool transpmode, // 1= transparent display
142  unsigned char* axdrcs, // width and height of DRCS-chars
143  int Ascender);
144  TextPageinfo_t* DecodePage(bool showl25, // 1=decode Level2.5-graphics
145  unsigned char* PageChar, // page buffer, min. 25*40
146  TextPageAttr_t *PageAtrb, // attribute buffer, min 25*40
147  bool HintMode, // 1=show hidden information
148  bool showflof); // 1=decode FLOF-line
149  void Eval_l25(unsigned char* page_char, TextPageAttr_t *PageAtrb, bool HintMode);
150  void Eval_Object(int iONr, TextCachedPage_t *pstCachedPage,
151  unsigned char *pAPx, unsigned char *pAPy,
152  unsigned char *pAPx0, unsigned char *pAPy0,
153  tObjType ObjType, unsigned char* pagedata, unsigned char* page_char, TextPageAttr_t* PageAtrb);
154  void Eval_NumberedObject(int p, int s, int packet, int triplet, int high,
155  unsigned char *pAPx, unsigned char *pAPy,
156  unsigned char *pAPx0, unsigned char *pAPy0, unsigned char* page_char, TextPageAttr_t* PageAtrb);
157  int Eval_Triplet(int iOData, TextCachedPage_t *pstCachedPage,
158  unsigned char *pAPx, unsigned char *pAPy,
159  unsigned char *pAPx0, unsigned char *pAPy0,
160  unsigned char *drcssubp, unsigned char *gdrcssubp,
161  signed char *endcol, TextPageAttr_t *attrPassive, unsigned char* pagedata, unsigned char* page_char, TextPageAttr_t* PageAtrb);
162  int iTripletNumber2Data(int iONr, TextCachedPage_t *pstCachedPage, unsigned char* pagedata);
163  int SetNational(unsigned char sec);
164  int NextHex(int i);
165  void SetColors(const unsigned short *pcolormap, int offset, int number);
166  UTILS::COLOR::Color GetColorRGB(enumTeletextColor ttc);
167 
168  static FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface);
169 
170  std::string m_teletextFont; /* Path to teletext font */
171  int m_YOffset; /* Swap position for Front buffer and Back buffer */
172  UTILS::COLOR::Color* m_TextureBuffer; /* Texture buffer to hold generated data */
173  bool m_updateTexture; /* Update the texture if set */
174  char prevHeaderPage; /* Needed for texture update if header is changed */
175  char prevTimeSec; /* Needed for Time string update */
176 
177  int m_CatchRow; /* for page catching */
178  int m_CatchCol; /* " " " */
179  int m_CatchedPage; /* " " " */
180  int m_PCOldRow; /* " " " */
181  int m_PCOldCol; /* " " " */
182 
183  FT_Library m_Library; /* FreeType 2 data */
184  FTC_Manager m_Manager; /* " " " */
185  FTC_SBitCache m_Cache; /* " " " */
186  FTC_SBit m_sBit; /* " " " */
187  FT_Face m_Face; /* " " " */
189  FTC_Node m_anode;
190  FTC_ImageTypeRec m_TypeTTF; /* " " " */
191  int m_Ascender; /* " " " */
192 
193  int m_TempPage; /* Temporary page number for number input */
194  int m_LastPage; /* Last selected Page */
195  std::shared_ptr<TextCacheStruct_t> m_txtCache; /* Text cache generated by the VideoPlayer if Teletext present */
196  TextRenderInfo_t m_RenderInfo; /* Rendering information of displayed Teletext page */
197 };
Definition: TeletextDefines.h:360
class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:22
Definition: TeletextDefines.h:308
Definition: TeletextDefines.h:371
Definition: TeletextDefines.h:433
Definition: Teletext.h:35