vdr  2.2.0
hdffosd.c
Go to the documentation of this file.
1 /*
2  * hdffosd.c: Implementation of the DVB HD Full Featured On Screen Display
3  *
4  * See the README file for copyright information and how to reach the author.
5  */
6 
7 #include "hdffosd.h"
8 #include <linux/dvb/osd.h>
9 #include <sys/ioctl.h>
10 #include <sys/time.h>
11 #include "hdffcmd.h"
12 #include "setup.h"
13 
14 #define MAX_NUM_FONTFACES 8
15 #define MAX_NUM_FONTS 8
16 #define MAX_BITMAP_SIZE (1024*1024)
17 
18 typedef struct _tFontFace
19 {
21  uint32_t Handle;
22 } tFontFace;
23 
24 typedef struct _tFont
25 {
26  uint32_t hFontFace;
27  int Size;
28  uint32_t Handle;
29 } tFont;
30 
31 class cHdffOsd : public cOsd
32 {
33 private:
35  int mLeft;
36  int mTop;
39  bool mChanged;
40  uint32_t mDisplay;
43  uint32_t mBitmapPalette;
44  uint32_t mBitmapColors[256];
45 
47 
48 protected:
49  virtual void SetActive(bool On);
50 public:
51  cHdffOsd(int Left, int Top, HDFF::cHdffCmdIf * pHdffCmdIf, uint Level);
52  virtual ~cHdffOsd();
53  virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas);
54  virtual eOsdError SetAreas(const tArea *Areas, int NumAreas);
55  virtual void SaveRegion(int x1, int y1, int x2, int y2);
56  virtual void RestoreRegion(void);
57  virtual void DrawPixel(int x, int y, tColor Color);
58  virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool ReplacePalette = false, bool Overlay = false);
59  virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault);
60  virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color);
61  virtual void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants = 0);
62  virtual void DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type);
63  virtual void Flush(void);
64 };
65 
66 cHdffOsd::cHdffOsd(int Left, int Top, HDFF::cHdffCmdIf * pHdffCmdIf, uint Level)
67 : cOsd(Left, Top, Level)
68 {
69  double pixelAspect;
70  HdffOsdConfig_t config;
71 
72  //printf("cHdffOsd %d, %d, %d\n", Left, Top, Level);
73  mHdffCmdIf = pHdffCmdIf;
74  mLeft = Left;
75  mTop = Top;
76  mChanged = false;
78 
79  mSupportsUtf8Text = false;
80  if (mHdffCmdIf->CmdGetFirmwareVersion(NULL, 0) >= 0x309)
81  mSupportsUtf8Text = true;
82 
83  memset(&config, 0, sizeof(config));
84  config.FontKerning = true;
85  config.FontAntialiasing = Setup.AntiAlias ? true : false;
86  mHdffCmdIf->CmdOsdConfigure(&config);
87 
91  for (int i = 0; i < MAX_NUM_FONTFACES; i++)
92  {
93  mFontFaces[i].Name = "";
95  }
96  for (int i = 0; i < MAX_NUM_FONTS; i++)
97  {
99  mFonts[i].Size = 0;
101  }
102 }
103 
105 {
106  //printf("~cHdffOsd %d %d\n", mLeft, mTop);
107  if (Active()) {
110  }
111  SetActive(false);
112 
113  for (int i = 0; i < MAX_NUM_FONTS; i++)
114  {
115  if (mFonts[i].Handle == HDFF_INVALID_HANDLE)
116  break;
117  mHdffCmdIf->CmdOsdDeleteFont(mFonts[i].Handle);
118  }
119  for (int i = 0; i < MAX_NUM_FONTFACES; i++)
120  {
121  if (mFontFaces[i].Handle == HDFF_INVALID_HANDLE)
122  break;
124  }
125 
129 }
130 
131 eOsdError cHdffOsd::CanHandleAreas(const tArea *Areas, int NumAreas)
132 {
133  eOsdError Result = cOsd::CanHandleAreas(Areas, NumAreas);
134  if (Result == oeOk)
135  {
136  for (int i = 0; i < NumAreas; i++)
137  {
138  if (Areas[i].bpp != 1 && Areas[i].bpp != 2 && Areas[i].bpp != 4 && Areas[i].bpp != 8)
139  return oeBppNotSupported;
140  }
141  }
142  return Result;
143 }
144 
145 eOsdError cHdffOsd::SetAreas(const tArea *Areas, int NumAreas)
146 {
147  eOsdError error;
148  cBitmap * bitmap;
149 
150  for (int i = 0; i < NumAreas; i++)
151  {
152  //printf("SetAreas %d: %d %d %d %d %d\n", i, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2, Areas[i].bpp);
153  }
154  if (Active() && mDisplay != HDFF_INVALID_HANDLE)
155  {
158  }
159  error = cOsd::SetAreas(Areas, NumAreas);
160 
161  for (int i = 0; (bitmap = GetBitmap(i)) != NULL; i++)
162  {
163  bitmap->Clean();
164  }
165 
166  return error;
167 }
168 
169 void cHdffOsd::SetActive(bool On)
170 {
171  if (On != Active())
172  {
173  cOsd::SetActive(On);
174  if (On)
175  {
176  if (GetBitmap(0)) // only flush here if there are already bitmaps
177  Flush();
178  }
179  else if (mDisplay != HDFF_INVALID_HANDLE)
180  {
183  }
184  }
185 }
186 
187 void cHdffOsd::SaveRegion(int x1, int y1, int x2, int y2)
188 {
189  mHdffCmdIf->CmdOsdSaveRegion(mDisplay, mLeft + x1, mTop + y1, x2 - x1 + 1, y2 - y1 + 1);
190  mChanged = true;
191 }
192 
194 {
196  mChanged = true;
197 }
198 
199 void cHdffOsd::DrawPixel(int x, int y, tColor Color)
200 {
201  //printf("DrawPixel\n");
202 }
203 
204 void cHdffOsd::DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg, tColor ColorBg, bool ReplacePalette, bool Overlay)
205 {
206  //printf("DrawBitmap %d %d %d x %d\n", x, y, Bitmap.Width(), Bitmap.Height());
207  int i;
208  int numColors;
209  const tColor * colors = Bitmap.Colors(numColors);
210 
211  for (i = 0; i < numColors; i++)
212  {
213  mBitmapColors[i] = colors[i];
214  if (ColorFg || ColorBg)
215  {
216  if (i == 0)
217  mBitmapColors[i] = ColorBg;
218  else if (i == 1)
219  mBitmapColors[i] = ColorFg;
220  }
221  }
223  {
226  }
227  else
228  {
230  HDFF_COLOR_FORMAT_ARGB, 0, numColors, mBitmapColors);
231  }
232  int width = Bitmap.Width();
233  int height = Bitmap.Height();
234  int chunk = MAX_BITMAP_SIZE / width;
235  if (chunk > height)
236  chunk = height;
237  for (int yc = 0; yc < height; yc += chunk)
238  {
239  int hc = chunk;
240  if (yc + hc > height)
241  hc = height - yc;
243  (uint8_t *) Bitmap.Data(0, yc), width, hc,
245  }
246  mChanged = true;
247 }
248 
249 void cHdffOsd::DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width, int Height, int Alignment)
250 {
251  int w = Font->Width(s);
252  int h = Font->Height();
253  int cw = Width ? Width : w;
254  int ch = Height ? Height : h;
255  int i;
256  int size = Font->Size();
257  tFontFace * pFontFace;
258  tFont * pFont;
259 
260  if (ColorBg != clrTransparent)
261  mHdffCmdIf->CmdOsdDrawRectangle(mDisplay, mLeft + x, mTop + y, cw, ch, ColorBg);
262 
263  if (s == NULL)
264  return;
265 
266  pFontFace = NULL;
267  for (i = 0; i < MAX_NUM_FONTFACES; i++)
268  {
269  if (mFontFaces[i].Handle == HDFF_INVALID_HANDLE)
270  break;
271 
272  if (strcmp(mFontFaces[i].Name, Font->FontName()) == 0)
273  {
274  pFontFace = &mFontFaces[i];
275  break;
276  }
277  }
278  if (pFontFace == NULL)
279  {
280  if (i < MAX_NUM_FONTFACES)
281  {
282  cString fontFileName = Font->FontName();
283  FILE * fp = fopen(fontFileName, "rb");
284  if (fp)
285  {
286  fseek(fp, 0, SEEK_END);
287  long fileSize = ftell(fp);
288  fseek(fp, 0, SEEK_SET);
289  if (fileSize > 0)
290  {
291  uint8_t * buffer = new uint8_t[fileSize];
292  if (buffer)
293  {
294  if (fread(buffer, fileSize, 1, fp) == 1)
295  {
296  mFontFaces[i].Handle = mHdffCmdIf->CmdOsdCreateFontFace(buffer, fileSize);
297  if (mFontFaces[i].Handle != HDFF_INVALID_HANDLE)
298  {
299  mFontFaces[i].Name = Font->FontName();
300  pFontFace = &mFontFaces[i];
301  }
302  }
303  delete[] buffer;
304  }
305  }
306  fclose(fp);
307  }
308  }
309  }
310  if (pFontFace == NULL)
311  return;
312 
313  pFont = NULL;
314  for (i = 0; i < MAX_NUM_FONTS; i++)
315  {
316  if (mFonts[i].Handle == HDFF_INVALID_HANDLE)
317  break;
318 
319  if (mFonts[i].hFontFace == pFontFace->Handle
320  && mFonts[i].Size == size)
321  {
322  pFont = &mFonts[i];
323  break;
324  }
325  }
326  if (pFont == NULL)
327  {
328  if (i < MAX_NUM_FONTS)
329  {
330  mFonts[i].Handle = mHdffCmdIf->CmdOsdCreateFont(pFontFace->Handle, size);
331  if (mFonts[i].Handle != HDFF_INVALID_HANDLE)
332  {
333  mFonts[i].hFontFace = pFontFace->Handle;
334  mFonts[i].Size = size;
335  pFont = &mFonts[i];
336  }
337  }
338  }
339  if (pFont == NULL)
340  return;
341 
342  mHdffCmdIf->CmdOsdSetDisplayClippingArea(mDisplay, true, mLeft + x, mTop + y, cw, ch);
343 
344  if (Width || Height)
345  {
346  if (Width)
347  {
348  if ((Alignment & taLeft) != 0)
349  {
350 #if (APIVERSNUM >= 10728)
351  if ((Alignment & taBorder) != 0)
352  x += max(h / TEXT_ALIGN_BORDER, 1);
353 #endif
354  }
355  else if ((Alignment & taRight) != 0)
356  {
357  if (w < Width)
358  x += Width - w;
359 #if (APIVERSNUM >= 10728)
360  if ((Alignment & taBorder) != 0)
361  x -= max(h / TEXT_ALIGN_BORDER, 1);
362 #endif
363  }
364  else
365  { // taCentered
366  if (w < Width)
367  x += (Width - w) / 2;
368  }
369  }
370  if (Height)
371  {
372  if ((Alignment & taTop) != 0)
373  ;
374  else if ((Alignment & taBottom) != 0)
375  {
376  if (h < Height)
377  y += Height - h;
378  }
379  else
380  { // taCentered
381  if (h < Height)
382  y += (Height - h) / 2;
383  }
384  }
385  }
386 #if 0
387  if (mSupportsUtf8Text)
388  {
389  mHdffCmdIf->CmdOsdDrawUtf8Text(mDisplay, pFont->Handle, x + mLeft, y + mTop + h, s, ColorFg);
390  }
391  else
392 #endif
393  {
394  uint16_t tmp[1000];
395  uint16_t len = 0;
396  while (*s && (len < (sizeof(tmp) - 1)))
397  {
398  int sl = Utf8CharLen(s);
399  uint sym = Utf8CharGet(s, sl);
400  s += sl;
401  tmp[len] = sym;
402  len++;
403  }
404  tmp[len] = 0;
405  mHdffCmdIf->CmdOsdDrawTextW(mDisplay, pFont->Handle, x + mLeft, y + mTop + h, tmp, ColorFg);
406  }
407  mHdffCmdIf->CmdOsdSetDisplayClippingArea(mDisplay, false, 0, 0, 0, 0);
408  mChanged = true;
409 }
410 
411 void cHdffOsd::DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
412 {
413  mHdffCmdIf->CmdOsdDrawRectangle(mDisplay, mLeft + x1, mTop + y1, x2 - x1 + 1, y2 - y1 + 1, Color);
414  mChanged = true;
415 }
416 
417 void cHdffOsd::DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants)
418 {
419  uint32_t flags;
420  int cx;
421  int cy;
422  int rx;
423  int ry;
424 
425  switch (abs(Quadrants))
426  {
427  case 1:
428  if (Quadrants > 0)
430  else
432  cx = x1;
433  cy = y2;
434  rx = x2 - x1;
435  ry = y2 - y1;
436  break;
437  case 2:
438  if (Quadrants > 0)
440  else
442  cx = x2;
443  cy = y2;
444  rx = x2 - x1;
445  ry = y2 - y1;
446  break;
447  case 3:
448  if (Quadrants > 0)
450  else
452  cx = x2;
453  cy = y1;
454  rx = x2 - x1;
455  ry = y2 - y1;
456  break;
457  case 4:
458  if (Quadrants > 0)
460  else
462  cx = x1;
463  cy = y1;
464  rx = x2 - x1;
465  ry = y2 - y1;
466  break;
467  case 5:
468  flags = HDFF_DRAW_HALF_RIGHT;
469  cx = x1;
470  cy = (y1 + y2) / 2;
471  rx = x2 - x1;
472  ry = (y2 - y1) / 2;
473  break;
474  case 6:
475  flags = HDFF_DRAW_HALF_TOP;
476  cx = (x1 + x2) / 2;
477  cy = y2;
478  rx = (x2 - x1) / 2;
479  ry = y2 - y1;
480  break;
481  case 7:
482  flags = HDFF_DRAW_HALF_LEFT;
483  cx = x2;
484  cy = (y1 + y2) / 2;
485  rx = x2 - x1;
486  ry = (y2 - y1) / 2;
487  break;
488  case 8:
489  flags = HDFF_DRAW_HALF_BOTTOM;
490  cx = (x1 + x2) / 2;
491  cy = y1;
492  rx = (x2 - x1) / 2;
493  ry = y2 - y1;
494  break;
495  default:
496  flags = HDFF_DRAW_FULL;
497  cx = (x1 + x2) / 2;
498  cy = (y1 + y2) / 2;
499  rx = (x2 - x1) / 2;
500  ry = (y2 - y1) / 2;
501  break;
502  }
503  mHdffCmdIf->CmdOsdDrawEllipse(mDisplay, mLeft + cx, mTop + cy, rx, ry, Color, flags);
504  mChanged = true;
505 }
506 
507 void cHdffOsd::DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type)
508 {
509  //printf("DrawSlope\n");
511  x2 - x1 + 1, y2 - y1 + 1, Color, Type);
512  mChanged = true;
513 }
514 
515 void cHdffOsd::Flush(void)
516 {
517  if (!Active())
518  return;
519 
520  //printf("Flush\n");
521  cBitmap * Bitmap;
522 
523  for (int i = 0; (Bitmap = GetBitmap(i)) != NULL; i++)
524  {
525  int x1;
526  int y1;
527  int x2;
528  int y2;
529 
530  if (Bitmap->Dirty(x1, y1, x2, y2))
531  {
532  //printf("dirty %d %d, %d %d\n", x1, y1, x2, y2);
533  DrawBitmap(0, 0, *Bitmap);
534  Bitmap->Clean();
535  }
536  }
537 
538  if (!mChanged)
539  return;
540 
542 
543  mChanged = false;
544 }
545 
546 
547 class cHdffOsdRaw : public cOsd
548 {
549 private:
553  bool refresh;
554  uint32_t mDisplay;
555  uint32_t mBitmapPalette;
556  uint32_t mBitmapColors[256];
557 
558 protected:
559  virtual void SetActive(bool On);
560 public:
561  cHdffOsdRaw(int Left, int Top, HDFF::cHdffCmdIf * pHdffCmdIf, uint Level);
562  virtual ~cHdffOsdRaw();
563  virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas);
564  virtual eOsdError SetAreas(const tArea *Areas, int NumAreas);
565  virtual void Flush(void);
566 };
567 
568 cHdffOsdRaw::cHdffOsdRaw(int Left, int Top, HDFF::cHdffCmdIf * pHdffCmdIf, uint Level)
569 : cOsd(Left, Top, Level)
570 {
571  double pixelAspect;
572 
573  //printf("cHdffOsdRaw %d, %d, %d\n", Left, Top, Level);
574  mHdffCmdIf = pHdffCmdIf;
575  refresh = true;
578 
580 }
581 
583 {
584  //printf("~cHdffOsdRaw %d %d\n", Left(), Top());
586  {
589  }
596 }
597 
599 {
600  if (On != Active())
601  {
602  cOsd::SetActive(On);
603  if (On)
604  {
606  {
610  }
611  refresh = true;
612  if (GetBitmap(0)) // only flush here if there are already bitmaps
613  Flush();
614  }
615  else
616  {
618  {
621  }
628  }
629  }
630 }
631 
632 eOsdError cHdffOsdRaw::CanHandleAreas(const tArea *Areas, int NumAreas)
633 {
634  eOsdError Result = cOsd::CanHandleAreas(Areas, NumAreas);
635  if (Result == oeOk)
636  {
637  for (int i = 0; i < NumAreas; i++)
638  {
639  if (Areas[i].bpp != 1 && Areas[i].bpp != 2 && Areas[i].bpp != 4 && Areas[i].bpp != 8
640  && (Areas[i].bpp != 32 || !gHdffSetup.TrueColorOsd))
641  return oeBppNotSupported;
642  }
643  }
644  return Result;
645 }
646 
647 eOsdError cHdffOsdRaw::SetAreas(const tArea *Areas, int NumAreas)
648 {
649  for (int i = 0; i < NumAreas; i++)
650  {
651  //printf("SetAreas %d: %d %d %d %d %d\n", i, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2, Areas[i].bpp);
652  }
654  {
657  refresh = true;
658  }
659  return cOsd::SetAreas(Areas, NumAreas);
660 }
661 
663 {
664  if (!Active() || (mDisplay == HDFF_INVALID_HANDLE))
665  return;
666 #ifdef MEASURE_OSD_TIME
667  struct timeval start;
668  struct timeval end;
669  struct timezone timeZone;
670  gettimeofday(&start, &timeZone);
671 #endif
672 
673  bool render = false;
674  if (IsTrueColor())
675  {
676  uint8_t * buffer = 0;
677  if (gHdffSetup.TrueColorFormat != 0)
678  {
679  buffer = new uint8_t[MAX_BITMAP_SIZE];
680  if (!buffer)
681  return;
682  }
683  LOCK_PIXMAPS;
684  while (cPixmapMemory *pm = dynamic_cast<cPixmapMemory *>(RenderPixmaps()))
685  {
686  int w = pm->ViewPort().Width();
687  int h = pm->ViewPort().Height();
688  int d = w * sizeof(tColor);
689  int Chunk = MAX_BITMAP_SIZE / w / sizeof(tColor);
690  if (Chunk > h)
691  Chunk = h;
692  for (int y = 0; y < h; y += Chunk)
693  {
694  int hc = Chunk;
695  if (y + hc > h)
696  hc = h - y;
697  if (gHdffSetup.TrueColorFormat == 0) // ARGB8888 (32 bit)
698  {
700  Left() + pm->ViewPort().X(), Top() + pm->ViewPort().Y() + y,
701  pm->Data() + y * d, w, hc, hc * d,
703  }
704  else if (gHdffSetup.TrueColorFormat == 1) // ARGB8565 (24 bit)
705  {
706  const tColor * pixmapData = (const tColor *) (pm->Data() + y * d);
707  uint8_t * bitmapData = buffer;
708  for (int i = 0; i < hc * w; i++)
709  {
710  bitmapData[2] = (pixmapData[i] & 0xFF000000) >> 24;
711  bitmapData[1] = ((pixmapData[i] & 0x00F80000) >> 16)
712  | ((pixmapData[i] & 0x0000E000) >> 13);
713  bitmapData[0] = ((pixmapData[i] & 0x00001C00) >> 5)
714  | ((pixmapData[i] & 0x000000F8) >> 3);
715  bitmapData += 3;
716  }
718  Left() + pm->ViewPort().X(), Top() + pm->ViewPort().Y() + y,
719  buffer, w, hc, hc * w * 3,
721  }
722  else if (gHdffSetup.TrueColorFormat == 2) // ARGB4444 (16 bit)
723  {
724  const tColor * pixmapData = (const tColor *) (pm->Data() + y * d);
725  uint16_t * bitmapData = (uint16_t *) buffer;
726  for (int i = 0; i < hc * w; i++)
727  {
728  bitmapData[i] = ((pixmapData[i] & 0xF0000000) >> 16)
729  | ((pixmapData[i] & 0x00F00000) >> 12)
730  | ((pixmapData[i] & 0x0000F000) >> 8)
731  | ((pixmapData[i] & 0x000000F0) >> 4);
732  }
734  Left() + pm->ViewPort().X(), Top() + pm->ViewPort().Y() + y,
735  buffer, w, hc, hc * w * 2,
737  }
738  }
739  DestroyPixmap(pm);
740  render = true;
741  }
742  if (buffer)
743  delete[] buffer;
744  }
745  else
746  {
747  uint8_t * buffer = new uint8_t[MAX_BITMAP_SIZE];
748  if (!buffer)
749  return;
750  cBitmap * bitmap;
751  for (int i = 0; (bitmap = GetBitmap(i)) != NULL; i++)
752  {
753  int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
754  if (refresh || bitmap->Dirty(x1, y1, x2, y2))
755  {
756  if (refresh)
757  {
758  x2 = bitmap->Width() - 1;
759  y2 = bitmap->Height() - 1;
760  }
761  // commit colors:
762  int numColors;
763  const tColor * colors = bitmap->Colors(numColors);
764  if (colors)
765  {
766  for (int c = 0; c < numColors; c++)
767  mBitmapColors[c] = colors[c];
769  {
772  }
773  else
774  {
776  HDFF_COLOR_FORMAT_ARGB, 0, numColors, mBitmapColors);
777  }
778  }
779  // commit modified data:
780  int width = x2 - x1 + 1;
781  int height = y2 - y1 + 1;
782  int chunk = MAX_BITMAP_SIZE / width;
783  if (chunk > height)
784  chunk = height;
785  for (int y = 0; y < height; y += chunk)
786  {
787  int hc = chunk;
788  if (y + hc > height)
789  hc = height - y;
790  for (int r = 0; r < hc; r++)
791  memcpy(buffer + r * width, bitmap->Data(x1, y1 + y + r), width);
793  Left() + bitmap->X0() + x1, Top() + bitmap->Y0() + y1 + y,
794  buffer, width, hc, hc * width,
796  }
797  render = true;
798  }
799  bitmap->Clean();
800  }
801  delete[] buffer;
802  }
803  if (render)
804  {
806 #ifdef MEASURE_OSD_TIME
807  gettimeofday(&end, &timeZone);
808  int timeNeeded = end.tv_usec - start.tv_usec;
809  timeNeeded += (end.tv_sec - start.tv_sec) * 1000000;
810  printf("time = %d\n", timeNeeded);
811 #endif
812  }
813  refresh = false;
814 }
815 
816 
817 
818 
820 {
821  mHdffCmdIf = HdffCmdIf;
822 }
823 
824 cOsd *cHdffOsdProvider::CreateOsd(int Left, int Top, uint Level)
825 {
826  //printf("CreateOsd %d %d %d\n", Left, Top, Level);
828  return new cHdffOsd(Left, Top, mHdffCmdIf, Level);
829  else
830  return new cHdffOsdRaw(Left, Top, mHdffCmdIf, Level);
831 }
832 
834 {
836 }
uint32_t CmdOsdCreateFont(uint32_t hFontFace, uint32_t Size)
Definition: hdffcmd.c:282
void CmdOsdRenderDisplay(uint32_t hDisplay)
Definition: hdffcmd.c:226
int AntiAlias
Definition: config.h:323
uint32_t hFontFace
Definition: hdffosd.c:26
uint32_t mBitmapPalette
Definition: hdffosd.c:43
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
Definition: hdffosd.c:833
void CmdOsdDrawBitmap(uint32_t hDisplay, int X, int Y, const uint8_t *pBitmap, int BmpWidth, int BmpHeight, int BmpSize, HdffColorType_t ColorType, uint32_t hPalette)
Definition: hdffcmd.c:339
void Clean(void)
Marks the dirty area as clean.
Definition: osd.c:354
virtual ~cHdffOsdRaw()
Definition: hdffosd.c:582
cHdffOsd(int Left, int Top, HDFF::cHdffCmdIf *pHdffCmdIf, uint Level)
Definition: hdffosd.c:66
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
Definition: osd.c:1823
virtual void SetActive(bool On)
Sets this OSD to be the active one.
Definition: osd.h:757
uint32_t CmdOsdCreatePalette(HdffColorType_t ColorType, HdffColorFormat_t ColorFormat, uint32_t NumColors, const uint32_t *pColors)
Definition: hdffcmd.c:232
uint32_t CmdOsdCreateDisplay(uint32_t Width, uint32_t Height, HdffColorType_t ColorType)
Definition: hdffcmd.c:191
cHdffSetup gHdffSetup
Definition: setup.c:16
Definition: osd.h:163
const tColor * Colors(int &NumColors) const
Returns a pointer to the complete color table and stores the number of valid entries in NumColors...
Definition: osd.c:185
virtual void DrawPixel(int x, int y, tColor Color)
Sets the pixel at the given coordinates to the given Color, which is a full 32 bit ARGB value...
Definition: hdffosd.c:199
#define HDFF_INVALID_HANDLE
Definition: hdffcmd_osd.h:28
void CmdOsdSetPaletteColors(uint32_t hPalette, HdffColorFormat_t ColorFormat, uint8_t StartColor, uint32_t NumColors, const uint32_t *pColors)
Definition: hdffcmd.c:256
Definition: hdffosd.c:24
void CmdOsdDeletePalette(uint32_t hPalette)
Definition: hdffcmd.c:246
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
Definition: hdffosd.c:632
bool Active(void)
Definition: osd.h:756
void CmdOsdRestoreRegion(uint32_t hDisplay)
Definition: hdffcmd.c:353
uint32_t Handle
Definition: hdffosd.c:28
T max(T a, T b)
Definition: tools.h:55
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition: hdffosd.c:515
virtual void DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type)
Draws a "slope" into the rectangle defined by the upper left (x1, y1) and lower right (x2...
Definition: hdffosd.c:507
bool mSupportsUtf8Text
Definition: hdffosd.c:46
virtual void Flush(void)
Actually commits all data to the OSD hardware.
Definition: hdffosd.c:662
int HighLevelOsd
Definition: setup.h:38
void CmdOsdDrawEllipse(uint32_t hDisplay, int CX, int CY, int RadiusX, int RadiusY, uint32_t Color, uint32_t Flags)
Definition: hdffcmd.c:307
tFont mFonts[MAX_NUM_FONTS]
Definition: hdffosd.c:42
void CmdOsdDrawSlope(uint32_t hDisplay, int X, int Y, int Width, int Height, uint32_t Color, uint32_t Type)
Definition: hdffcmd.c:314
uint32_t mBitmapColors[256]
Definition: hdffosd.c:556
int mDispWidth
Definition: hdffosd.c:37
#define MAX_NUM_FONTS
Definition: hdffosd.c:15
void CmdOsdDeleteFont(uint32_t hFont)
Definition: hdffcmd.c:295
uint32_t CmdOsdCreateFontFace(const uint8_t *pFontData, uint32_t DataSize)
Definition: hdffcmd.c:263
#define LOCK_PIXMAPS
Definition: osd.h:677
Definition: osd.h:169
int Width(void) const
Definition: osd.h:188
virtual ~cHdffOsd()
Definition: hdffosd.c:104
int TrueColorOsd
Definition: setup.h:39
virtual void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants=0)
Draws a filled ellipse defined by the upper left (x1, y1) and lower right (x2, y2) corners with the g...
Definition: hdffosd.c:417
#define HDFF_SIZE_FULL_SCREEN
Definition: hdffcmd_osd.h:33
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
Definition: hdffosd.c:131
Definition: osd.h:161
int Top(void)
Definition: osd.h:801
virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color)
Draws a filled rectangle defined by the upper left (x1, y1) and lower right (x2, y2) corners with the...
Definition: hdffosd.c:411
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
Definition: osddemo.c:18
virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool ReplacePalette=false, bool Overlay=false)
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
Definition: hdffosd.c:204
bool Dirty(int &x1, int &y1, int &x2, int &y2)
Tells whether there is a dirty area and returns the bounding rectangle of that area (relative to the ...
Definition: osd.c:342
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
Definition: hdffosd.c:193
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
Definition: osd.c:1720
int width
Definition: osd.h:732
#define MAX_NUM_FONTFACES
Definition: hdffosd.c:14
int Height(void) const
Definition: osd.h:189
uint32_t CmdGetFirmwareVersion(char *pString, uint32_t MaxLength)
Definition: hdffcmd.c:33
virtual const char * FontName(void) const
Returns the font name.
Definition: font.h:42
Definition: osd.h:162
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
Definition: osd.c:1801
void CmdOsdSaveRegion(uint32_t hDisplay, int X, int Y, int Width, int Height)
Definition: hdffcmd.c:348
Definition: osd.h:164
int mDispHeight
Definition: hdffosd.c:38
struct _tFontFace tFontFace
static const cCursesFont Font
Definition: skincurses.c:30
int mTop
Definition: hdffosd.c:36
The cOsd class is the interface to the "On Screen Display".
Definition: osd.h:720
int mDispHeight
Definition: hdffosd.c:552
void CmdOsdSetDisplayClippingArea(uint32_t hDisplay, bool Enable, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
Definition: hdffcmd.c:220
void CmdOsdDeleteFontFace(uint32_t hFontFace)
Definition: hdffcmd.c:276
virtual void DrawText(int x, int y, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width=0, int Height=0, int Alignment=taDefault)
Draws the given string at coordinates (x, y) with the given foreground and background color and font...
Definition: hdffosd.c:249
cSetup Setup
Definition: config.c:373
static int Utf8CharLen(const char *s)
Definition: si.c:417
uint32_t mBitmapColors[256]
Definition: hdffosd.c:44
void CmdOsdSetDisplayOutputRectangle(uint32_t hDisplay, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
Definition: hdffcmd.c:214
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
Definition: osddemo.c:60
virtual cOsd * CreateOsd(int Left, int Top, uint Level)
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates...
Definition: hdffosd.c:824
void CmdOsdDeleteDisplay(uint32_t hDisplay)
Definition: hdffcmd.c:202
int Height(void)
Definition: osd.h:803
int Y0(void) const
Definition: osd.h:187
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
Definition: hdffosd.c:187
void GetOsdSize(int &Width, int &Height, double &PixelAspect)
Definition: setup.c:64
const tIndex * Data(int x, int y) const
Returns the address of the index byte at the given coordinates.
Definition: osd.c:760
void CmdOsdDrawRectangle(uint32_t hDisplay, int X, int Y, int Width, int Height, uint32_t Color)
Definition: hdffcmd.c:301
uint32_t mBitmapPalette
Definition: hdffosd.c:555
#define TEXT_ALIGN_BORDER
Definition: osd.h:28
virtual int Size(void) const
Returns the original size as requested when the font was created.
Definition: font.h:44
struct _tFont tFont
Definition: osd.h:298
#define MAX_BITMAP_SIZE
Definition: hdffosd.c:16
virtual int Width(uint c) const =0
Returns the width of the given character in pixel.
virtual void SetActive(bool On)
Sets this OSD to be the active one.
Definition: hdffosd.c:598
int Width(void)
Definition: osd.h:802
eOsdError
Definition: osd.h:44
int TrueColorFormat
Definition: setup.h:40
Definition: osd.h:159
cHdffOsdRaw(int Left, int Top, HDFF::cHdffCmdIf *pHdffCmdIf, uint Level)
Definition: hdffosd.c:568
bool mChanged
Definition: hdffosd.c:39
int Left(void)
Definition: osd.h:800
virtual void SetActive(bool On)
Sets this OSD to be the active one.
Definition: hdffosd.c:169
uint Utf8CharGet(const char *s, int Length)
Returns the UTF-8 symbol at the beginning of the given string.
Definition: tools.c:771
int height
Definition: osd.h:732
uint32_t Handle
Definition: hdffosd.c:21
uint32_t mDisplay
Definition: hdffosd.c:554
void CmdOsdConfigure(const HdffOsdConfig_t *pConfig)
Definition: hdffcmd.c:181
HDFF::cHdffCmdIf * mHdffCmdIf
Definition: hdffosd.c:550
Definition: osd.h:44
cString Name
Definition: hdffosd.c:20
Definition: osd.h:160
virtual int Height(void) const =0
Returns the height of this font in pixel (all characters have the same height).
int Size
Definition: hdffosd.c:27
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
Definition: hdffosd.c:145
uint32_t mDisplay
Definition: hdffosd.c:40
int mLeft
Definition: hdffosd.c:35
int X0(void) const
Definition: osd.h:186
tFontFace mFontFaces[MAX_NUM_FONTFACES]
Definition: hdffosd.c:41
bool IsTrueColor(void) const
Returns &#39;true&#39; if this is a true color OSD (providing full 32 bit color depth).
Definition: osd.h:797
cHdffOsdProvider(HDFF::cHdffCmdIf *pHdffCmdIf)
Definition: hdffosd.c:819
cPixmap * RenderPixmaps(void)
Renders the dirty part of all pixmaps into a resulting pixmap that shall be displayed on the OSD...
Definition: osd.c:1750
cBitmap * GetBitmap(int Area)
Returns a pointer to the bitmap for the given Area, or NULL if no such bitmap exists.
Definition: osd.c:1703
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
Definition: hdffosd.c:647
Definition: font.h:37
bool refresh
Definition: hdffosd.c:553
int mDispWidth
Definition: hdffosd.c:551
Definition: tools.h:168
HDFF::cHdffCmdIf * mHdffCmdIf
Definition: hdffosd.c:34
void CmdOsdDrawUtf8Text(uint32_t hDisplay, uint32_t hFont, int X, int Y, const char *pText, uint32_t Color)
Definition: hdffcmd.c:327
void CmdOsdDrawTextW(uint32_t hDisplay, uint32_t hFont, int X, int Y, const uint16_t *pText, uint32_t Color)
Definition: hdffcmd.c:333
uint32_t tColor
Definition: font.h:29