kodi
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 
54  bool Changed();
55 
56  bool InitDecoder();
57  void EndDecoder();
58  void RenderPage();
59  bool HandleAction(const CAction &action);
60 
61 private:
62  void PageInput(int Number);
63  void GetNextPageOne(bool up);
64  void GetNextSubPage(int offset);
65  bool IsSubtitlePage(int pageNumber) const;
66  void SwitchZoomMode();
67  void SwitchTranspMode();
68  void SwitchHintMode();
69  void ColorKey(int target);
70  void StartPageCatching();
71  void StopPageCatching();
72  void CatchNextPage(int firstlineinc, int inc);
73  void RenderCatchedPage();
74  void DoFlashing(int startrow);
75  void DoRenderPage(int startrow, int national_subset_bak);
76  void Decode_BTT();
77  void Decode_ADIP();
78  int TopText_GetNext(int startpage, int up, int findgroup);
79  void Showlink(int column, int linkpage);
80  void CreateLine25();
81  void RenderCharFB(int Char, TextPageAttr_t *Attribute);
82  void RenderCharBB(int Char, TextPageAttr_t *Attribute);
83  void CopyBB2FB();
84  void SetFontWidth(int newWidth);
85  int GetCurFontWidth();
86  void SetPosX(int column);
87  void ClearBB(UTILS::COLOR::Color Color);
88  void ClearFB(UTILS::COLOR::Color Color);
89  void FillBorder(UTILS::COLOR::Color Color);
90  void FillRect(
91  UTILS::COLOR::Color* buffer, int xres, int x, int y, int w, int h, UTILS::COLOR::Color Color);
92  void DrawVLine(
93  UTILS::COLOR::Color* lfb, int xres, int x, int y, int l, UTILS::COLOR::Color color);
94  void DrawHLine(
95  UTILS::COLOR::Color* lfb, int xres, int x, int y, int l, UTILS::COLOR::Color color);
96  void FillRectMosaicSeparated(UTILS::COLOR::Color* lfb,
97  int xres,
98  int x,
99  int y,
100  int w,
101  int h,
102  UTILS::COLOR::Color fgcolor,
103  UTILS::COLOR::Color bgcolor,
104  int set);
105  void FillTrapez(UTILS::COLOR::Color* lfb,
106  int xres,
107  int x0,
108  int y0,
109  int l0,
110  int xoffset1,
111  int h,
112  int l1,
113  UTILS::COLOR::Color color);
114  void FlipHorz(UTILS::COLOR::Color* lfb, int xres, int x, int y, int w, int h);
115  void FlipVert(UTILS::COLOR::Color* lfb, int xres, int x, int y, int w, int h);
116  int ShapeCoord(int param, int curfontwidth, int curfontheight);
117  void DrawShape(UTILS::COLOR::Color* lfb,
118  int xres,
119  int x,
120  int y,
121  int shapenumber,
122  int curfontwidth,
123  int fontheight,
124  int curfontheight,
125  UTILS::COLOR::Color fgcolor,
126  UTILS::COLOR::Color bgcolor,
127  bool clear);
128  void RenderDRCS(
129  int xres,
130  unsigned char* s, /* pointer to char data, parity undecoded */
131  UTILS::COLOR::Color* d, /* pointer to frame buffer of top left pixel */
132  unsigned char* ax, /* array[0..12] of x-offsets, array[0..10] of y-offsets for each pixel */
133  UTILS::COLOR::Color fgcolor,
134  UTILS::COLOR::Color bgcolor);
135  void RenderCharIntern(TextRenderInfo_t* RenderInfo, int Char, TextPageAttr_t *Attribute, int zoom, int yoffset);
136  int RenderChar(
137  UTILS::COLOR::Color* buffer, // pointer to render buffer, min. fontheight*2*xres
138  int xres, // length of 1 line in render buffer
139  int Char, // character to render
140  int*
141  pPosX, // left border for rendering relative to *buffer, will be set to right border after rendering
142  int PosY, // vertical position of char in *buffer
143  TextPageAttr_t* Attribute, // Attributes of Char
144  bool zoom, // 1= character will be rendered in double height
145  int curfontwidth, // rendering width of character
146  int curfontwidth2, // rendering width of next character (needed for doublewidth)
147  int fontheight, // height of character
148  bool transpmode, // 1= transparent display
149  unsigned char* axdrcs, // width and height of DRCS-chars
150  int Ascender);
151  TextPageinfo_t* DecodePage(bool showl25, // 1=decode Level2.5-graphics
152  unsigned char* PageChar, // page buffer, min. 25*40
153  TextPageAttr_t *PageAtrb, // attribute buffer, min 25*40
154  bool HintMode, // 1=show hidden information
155  bool showflof); // 1=decode FLOF-line
156  void Eval_l25(unsigned char* page_char, TextPageAttr_t *PageAtrb, bool HintMode);
157  void Eval_Object(int iONr, TextCachedPage_t *pstCachedPage,
158  unsigned char *pAPx, unsigned char *pAPy,
159  unsigned char *pAPx0, unsigned char *pAPy0,
160  tObjType ObjType, unsigned char* pagedata, unsigned char* page_char, TextPageAttr_t* PageAtrb);
161  void Eval_NumberedObject(int p, int s, int packet, int triplet, int high,
162  unsigned char *pAPx, unsigned char *pAPy,
163  unsigned char *pAPx0, unsigned char *pAPy0, unsigned char* page_char, TextPageAttr_t* PageAtrb);
164  int Eval_Triplet(int iOData, TextCachedPage_t *pstCachedPage,
165  unsigned char *pAPx, unsigned char *pAPy,
166  unsigned char *pAPx0, unsigned char *pAPy0,
167  unsigned char *drcssubp, unsigned char *gdrcssubp,
168  signed char *endcol, TextPageAttr_t *attrPassive, unsigned char* pagedata, unsigned char* page_char, TextPageAttr_t* PageAtrb);
169  int iTripletNumber2Data(int iONr, TextCachedPage_t *pstCachedPage, unsigned char* pagedata);
170  int SetNational(unsigned char sec);
171  int NextHex(int i);
172  void SetColors(const unsigned short *pcolormap, int offset, int number);
173  UTILS::COLOR::Color GetColorRGB(enumTeletextColor ttc);
174 
175  static FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface);
176 
177  std::string m_teletextFont; /* Path to teletext font */
178  int m_YOffset; /* Swap position for Front buffer and Back buffer */
179  UTILS::COLOR::Color* m_TextureBuffer; /* Texture buffer to hold generated data */
180  bool m_updateTexture; /* Update the texture if set */
181  char prevHeaderPage; /* Needed for texture update if header is changed */
182  char prevTimeSec; /* Needed for Time string update */
183 
184  int m_CatchRow; /* for page catching */
185  int m_CatchCol; /* " " " */
186  int m_CatchedPage; /* " " " */
187  int m_PCOldRow; /* " " " */
188  int m_PCOldCol; /* " " " */
189 
190  FT_Library m_Library; /* FreeType 2 data */
191  FTC_Manager m_Manager; /* " " " */
192  FTC_SBitCache m_Cache; /* " " " */
193  FTC_SBit m_sBit; /* " " " */
194  FT_Face m_Face; /* " " " */
196  FTC_Node m_anode{nullptr};
197  FTC_ImageTypeRec m_TypeTTF; /* " " " */
198  int m_Ascender; /* " " " */
199 
200  int m_TempPage; /* Temporary page number for number input */
201  int m_LastPage; /* Last selected Page */
202  std::shared_ptr<TextCacheStruct_t> m_txtCache; /* Text cache generated by the VideoPlayer if Teletext present */
203  TextRenderInfo_t m_RenderInfo; /* Rendering information of displayed Teletext page */
204 };
bool Changed()
Checks if the data in the decoder has changed.
Definition: Teletext.cpp:452
Definition: TeletextDefines.h:360
Class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:21
Definition: TeletextDefines.h:308
Definition: TeletextDefines.h:371
Definition: TeletextDefines.h:433
Definition: Teletext.h:35