vdr  2.2.0
osd.h
Go to the documentation of this file.
1 /*
2  * osd.h: Abstract On Screen Display layer
3  *
4  * See the main source file 'vdr.c' for copyright information and
5  * how to reach the author.
6  *
7  * $Id: osd.h 3.6 2015/02/11 09:48:02 kls Exp $
8  */
9 
10 #ifndef __OSD_H
11 #define __OSD_H
12 
13 #include <limits.h>
14 #include <stdio.h>
15 #include <stdint.h>
16 #include "config.h"
17 #include "font.h"
18 #include "thread.h"
19 #include "tools.h"
20 
21 #define OSD_LEVEL_DEFAULT 0
22 #define OSD_LEVEL_SUBTITLES 10
23 
24 #define MAXNUMCOLORS 256
25 #define ALPHA_TRANSPARENT 0x00
26 #define ALPHA_OPAQUE 0xFF
27 #define IS_OPAQUE(c) ((c >> 24) == ALPHA_OPAQUE)
28 #define TEXT_ALIGN_BORDER 10 // fraction of the font height used for sizing border
29 
30 enum {
31  //AARRGGBB
32  clrTransparent = 0x00000000,
33  clrGray50 = 0x7F000000, // 50% gray
34  clrBlack = 0xFF000000,
35  clrRed = 0xFFFC1414,
36  clrGreen = 0xFF24FC24,
37  clrYellow = 0xFFFCC024,
38  clrMagenta = 0xFFB000FC,
39  clrBlue = 0xFF0000FC,
40  clrCyan = 0xFF00FCFC,
41  clrWhite = 0xFFFCFCFC,
42  };
43 
44 enum eOsdError { oeOk, // see also OsdErrorTexts in osd.c
53  };
54 
55 typedef uint32_t tColor; // see also font.h
56 typedef uint8_t tIndex;
57 
58 inline tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
59 {
60  return (tColor(A) << 24) | (tColor(R) << 16) | (tColor(G) << 8) | B;
61 }
62 
63 inline tColor RgbToColor(uint8_t R, uint8_t G, uint8_t B)
64 {
65  return (tColor(R) << 16) | (tColor(G) << 8) | B;
66 }
67 
68 inline tColor RgbToColor(double R, double G, double B)
69 {
70  return RgbToColor(uint8_t(0xFF * R), uint8_t(0xFF * G), uint8_t(0xFF * B));
71 }
72 
73 tColor RgbShade(tColor Color, double Factor);
80 
81 tColor HsvToColor(double H, double S, double V);
85 
86 tColor AlphaBlend(tColor ColorFg, tColor ColorBg, uint8_t AlphaLayer = ALPHA_OPAQUE);
87 
88 class cPalette {
89 private:
91  int bpp;
93  bool modified;
95 protected:
97 public:
98  cPalette(int Bpp = 8);
100  virtual ~cPalette();
101  void SetAntiAliasGranularity(uint FixedColors, uint BlendColors);
111  int Bpp(void) const { return bpp; }
112  void Reset(void);
114  int Index(tColor Color);
119  tColor Color(int Index) const { return Index < maxColors ? color[Index] : 0; }
122  void SetBpp(int Bpp);
125  void SetColor(int Index, tColor Color);
129  const tColor *Colors(int &NumColors) const;
134  void Take(const cPalette &Palette, tIndexes *Indexes = NULL, tColor ColorFg = 0, tColor ColorBg = 0);
141  void Replace(const cPalette &Palette);
144  tColor Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const;
150  int ClosestColor(tColor Color, int MaxDiff = INT_MAX) const;
156  };
157 
158 enum eTextAlignment { taCenter = 0x00,
159  taLeft = 0x01,
160  taRight = 0x02,
161  taTop = 0x04,
162  taBottom = 0x08,
163  taBorder = 0x10, // keeps some distance from the left or right alignment edge
165  };
166 
167 class cFont;
168 
169 class cBitmap : public cPalette {
170 private:
172  int x0, y0;
173  int width, height;
174  int dirtyX1, dirtyY1, dirtyX2, dirtyY2;
175 public:
176  cBitmap(int Width, int Height, int Bpp, int X0 = 0, int Y0 = 0);
181  cBitmap(const char *FileName);
183  cBitmap(const char *const Xpm[]);
185  virtual ~cBitmap();
186  int X0(void) const { return x0; }
187  int Y0(void) const { return y0; }
188  int Width(void) const { return width; }
189  int Height(void) const { return height; }
190  void SetSize(int Width, int Height);
195  void SetOffset(int X0, int Y0) { x0 = X0; y0 = Y0; }
197  bool Contains(int x, int y) const;
199  bool Covers(int x1, int y1, int x2, int y2) const;
202  bool Intersects(int x1, int y1, int x2, int y2) const;
205  bool Dirty(int &x1, int &y1, int &x2, int &y2);
208  void Clean(void);
210  bool LoadXpm(const char *FileName);
213  bool SetXpm(const char *const Xpm[], bool IgnoreNone = false);
223  void SetIndex(int x, int y, tIndex Index);
226  void Fill(tIndex Index);
228  void DrawPixel(int x, int y, tColor Color);
232  void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool ReplacePalette = false, bool Overlay = false);
242  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);
248  void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color);
253  void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants = 0);
263  void DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type);
275  const tIndex *Data(int x, int y) const;
277  tColor GetColor(int x, int y) const { return Color(*Data(x, y)); }
279  void ReduceBpp(const cPalette &Palette);
285  void ShrinkBpp(int NewBpp);
290  cBitmap *Scaled(double FactorX, double FactorY, bool AntiAlias = false) const;
296  };
297 
298 struct tArea {
299  int x1, y1, x2, y2;
300  int bpp;
301  int Width(void) const { return x2 - x1 + 1; }
302  int Height(void) const { return y2 - y1 + 1; }
303  bool Intersects(const tArea &Area) const { return !(x2 < Area.x1 || x1 > Area.x2 || y2 < Area.y1 || y1 > Area.y2); }
304  };
305 
306 class cPoint {
307 private:
308  int x;
309  int y;
310 public:
311  cPoint(void) { x = y = 0; }
312  cPoint(int X, int Y) { x = X; y = Y; }
313  cPoint(const cPoint &Point) { x = Point.X(); y = Point.Y(); }
314  bool operator==(const cPoint &Point) const { return x == Point.X() && y == Point.Y(); }
315  bool operator!=(const cPoint &Point) const { return !(*this == Point); }
316  cPoint operator-(void) const { return cPoint(-x, -y); }
317  cPoint operator-(const cPoint &Point) const { return cPoint(x - Point.X(), y - Point.Y()); }
318  int X(void) const { return x; }
319  int Y(void) const { return y; }
320  void SetX(int X) { x = X; }
321  void SetY(int Y) { y = Y; }
322  void Set(int X, int Y) { x = X; y = Y; }
323  void Set(const cPoint &Point) { x = Point.X(); y = Point.Y(); }
324  void Shift(int Dx, int Dy) { x += Dx; y += Dy; }
325  void Shift(const cPoint &Dp) { x += Dp.X(); y += Dp.Y(); }
326  cPoint Shifted(int Dx, int Dy) const { cPoint p(*this); p.Shift(Dx, Dy); return p; }
327  cPoint Shifted(const cPoint &Dp) const { cPoint p(*this); p.Shift(Dp); return p; }
328  };
329 
330 class cSize {
331 private:
332  int width;
333  int height;
334 public:
335  cSize(void) { width = height = 0; }
336  cSize(int Width, int Height) { width = Width; height = Height; }
337  cSize(const cSize &Size) { width = Size.Width(); height = Size.Height(); }
338  bool operator==(const cSize &Size) const { return width == Size.Width() && height == Size.Height(); }
339  bool operator!=(const cSize &Size) const { return !(*this == Size); }
340  bool operator<(const cSize &Size) const { return width < Size.Width() && height < Size.Height(); }
341  int Width(void) const { return width; }
342  int Height(void) const { return height; }
343  void SetWidth(int Width) { width = Width; }
344  void SetHeight(int Height) { height = Height; }
345  void Set(int Width, int Height) { width = Width; height = Height; }
346  void Set(const cSize &Size) { width = Size.Width(); height = Size.Height(); }
347  bool Contains(const cPoint &Point) const { return 0 <= Point.X() && 0 <= Point.Y() && Point.X() < width && Point.Y() < height; }
348  void Grow(int Dw, int Dh) { width += 2 * Dw; height += 2 * Dh; }
349  cSize Grown(int Dw, int Dh) const { cSize s(*this); s.Grow(Dw, Dh); return s; }
350  };
351 
352 class cRect {
353 private:
356 public:
357  static const cRect Null;
358  cRect(void): point(0, 0), size(0, 0) {}
359  cRect(int X, int Y, int Width, int Height): point(X, Y), size(Width, Height) {}
360  cRect(const cPoint &Point, const cSize &Size): point(Point), size(Size) {}
361  cRect(const cSize &Size): point(0, 0), size(Size) {}
362  cRect(const cRect &Rect): point(Rect.Point()), size(Rect.Size()) {}
363  bool operator==(const cRect &Rect) const { return point == Rect.Point() && size == Rect.Size(); }
364  bool operator!=(const cRect &Rect) const { return !(*this == Rect); }
365  int X(void) const { return point.X(); }
366  int Y(void) const { return point.Y(); }
367  int Width(void) const { return size.Width(); }
368  int Height(void) const { return size.Height(); }
369  int Left(void) const { return X(); }
370  int Top(void) const { return Y(); }
371  int Right(void) const { return X() + Width() - 1; }
372  int Bottom(void) const { return Y() + Height() - 1; }
373  const cPoint &Point(void) const { return point; }
374  const cSize &Size(void) const { return size; }
375  void Set(int X, int Y, int Width, int Height) { point.Set(X, Y); size.Set(Width, Height); }
376  void Set(cPoint Point, cSize Size) { point.Set(Point); size.Set(Size); }
377  void SetPoint(int X, int Y) { point.Set(X, Y); }
378  void SetPoint(const cPoint &Point) { point.Set(Point); }
379  void SetSize(int Width, int Height) { size.Set(Width, Height); }
380  void SetSize(const cSize &Size) { size.Set(Size); }
381  void SetX(int X) { point.SetX(X); }
382  void SetY(int Y) { point.SetY(Y); }
383  void SetWidth(int Width) { size.SetWidth(Width); }
384  void SetHeight(int Height) { size.SetHeight(Height); }
385  void SetLeft(int Left) { SetWidth(Width() + X() - Left); SetX(Left); }
386  void SetTop(int Top) { SetHeight(Height() + Y() - Top); SetY(Top); }
387  void SetRight(int Right) { SetWidth(Right - X() + 1); }
388  void SetBottom(int Bottom) { SetHeight(Bottom - Y() + 1); }
389  void Shift(int Dx, int Dy) { point.Shift(Dx, Dy); }
390  void Shift(const cPoint &Dp) { point.Shift(Dp); }
391  cRect Shifted(int Dx, int Dy) const { cRect r(*this); r.Shift(Dx, Dy); return r; }
392  cRect Shifted(const cPoint &Dp) const { cRect r(*this); r.Shift(Dp); return r; }
393  void Grow(int Dx, int Dy);
396  cRect Grown(int Dw, int Dh) const { cRect r(*this); r.Grow(Dw, Dh); return r; }
397  bool Contains(const cPoint &Point) const;
399  bool Contains(const cRect &Rect) const;
401  bool Intersects(const cRect &Rect) const;
403  cRect Intersected(const cRect &Rect) const;
405  void Combine(const cRect &Rect);
407  cRect Combined(const cRect &Rect) const { cRect r(*this); r.Combine(Rect); return r; }
410  void Combine(const cPoint &Point);
412  cRect Combined(const cPoint &Point) const { cRect r(*this); r.Combine(Point); return r; }
415  bool IsEmpty(void) const { return Width() <= 0 || Height() <= 0; }
417  };
418 
419 class cImage {
420 private:
423 public:
424  cImage(void);
425  cImage(const cImage &Image);
426  cImage(const cSize &Size, const tColor *Data = NULL);
433  virtual ~cImage();
434  const cSize &Size(void) const { return size; }
435  int Width(void) const { return size.Width(); }
436  int Height(void) const { return size.Height(); }
437  const tColor *Data(void) const { return data; }
438  tColor GetPixel(const cPoint &Point) const { return data[size.Width() * Point.Y() + Point.X()]; }
442  void SetPixel(const cPoint &Point, tColor Color) { data[size.Width() * Point.Y() + Point.X()] = Color; }
446  void Clear(void);
448  void Fill(tColor Color);
450  };
451 
452 #define MAXPIXMAPLAYERS 8
453 
454 class cPixmap {
455  friend class cOsd;
456  friend class cPixmapMutexLock;
457 private:
458  static cMutex mutex;
459  int layer;
460  int alpha;
461  bool tile;
466 protected:
467  virtual ~cPixmap() {}
468  void MarkViewPortDirty(const cRect &Rect);
472  void MarkViewPortDirty(const cPoint &Point);
476  void MarkDrawPortDirty(const cRect &Rect);
482  void MarkDrawPortDirty(const cPoint &Point);
488  void SetClean(void);
490  virtual void DrawPixmap(const cPixmap *Pixmap, const cRect &Dirty);
495 public:
496  cPixmap(void);
497  cPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
525  static void Lock(void) { mutex.Lock(); }
531  static void Unlock(void) { mutex.Unlock(); }
532  int Layer(void) const { return layer; }
533  int Alpha(void) const { return alpha; }
534  bool Tile(void) const { return tile; }
535  const cRect &ViewPort(void) const { return viewPort; }
539  const cRect &DrawPort(void) const { return drawPort; }
543  const cRect &DirtyViewPort(void) const { return dirtyViewPort; }
550  const cRect &DirtyDrawPort(void) const { return dirtyDrawPort; }
557  virtual void SetLayer(int Layer);
564  virtual void SetAlpha(int Alpha);
569  virtual void SetTile(bool Tile);
575  virtual void SetViewPort(const cRect &Rect);
579  virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty = true);
588  virtual void Clear(void) = 0;
591  virtual void Fill(tColor Color) = 0;
594  virtual void DrawImage(const cPoint &Point, const cImage &Image) = 0;
596  virtual void DrawImage(const cPoint &Point, int ImageHandle) = 0;
601  virtual void DrawPixel(const cPoint &Point, tColor Color) = 0;
606  virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false) = 0;
617  virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault) = 0;
623  virtual void DrawRectangle(const cRect &Rect, tColor Color) = 0;
625  virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0) = 0;
634  virtual void DrawSlope(const cRect &Rect, tColor Color, int Type) = 0;
645  virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) = 0;
649  virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) = 0;
654  virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null) = 0;
658  virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null) = 0;
670  };
671 
672 class cPixmapMutexLock : public cMutexLock {
673 public:
675  };
676 
677 #define LOCK_PIXMAPS cPixmapMutexLock PixmapMutexLock
678 
679 // cPixmapMemory is an implementation of cPixmap that uses an array of tColor
680 // values to store the pixmap.
681 
682 class cPixmapMemory : public cPixmap {
683 private:
685  bool panning;
686 public:
687  cPixmapMemory(void);
688  cPixmapMemory(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
689  virtual ~cPixmapMemory();
690  const uint8_t *Data(void) { return (uint8_t *)data; }
691  virtual void Clear(void);
692  virtual void Fill(tColor Color);
693  virtual void DrawImage(const cPoint &Point, const cImage &Image);
694  virtual void DrawImage(const cPoint &Point, int ImageHandle);
695  virtual void DrawPixel(const cPoint &Point, tColor Color);
696  virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false);
697  virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault);
698  virtual void DrawRectangle(const cRect &Rect, tColor Color);
699  virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0);
700  virtual void DrawSlope(const cRect &Rect, tColor Color, int Type);
701  virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest);
702  virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest);
703  virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null);
704  virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null);
705  };
706 
707 #define MAXOSDAREAS 16
708 
719 
720 class cOsd {
721  friend class cOsdProvider;
722 private:
723  static int osdLeft, osdTop, osdWidth, osdHeight;
725  static cMutex mutex;
728  cBitmap *bitmaps[MAXOSDAREAS];
732  int left, top, width, height;
733  uint level;
734  bool active;
735 protected:
736  cOsd(int Left, int Top, uint Level);
756  bool Active(void) { return active; }
757  virtual void SetActive(bool On) { active = On; }
760  cPixmap *AddPixmap(cPixmap *Pixmap);
766  cPixmap *RenderPixmaps(void);
783 public:
784  virtual ~cOsd();
786  static int OsdLeft(void) { return osdLeft ? osdLeft : Setup.OSDLeft; }
787  static int OsdTop(void) { return osdTop ? osdTop : Setup.OSDTop; }
788  static int OsdWidth(void) { return osdWidth ? osdWidth : Setup.OSDWidth; }
789  static int OsdHeight(void) { return osdHeight ? osdHeight : Setup.OSDHeight; }
790  static void SetOsdPosition(int Left, int Top, int Width, int Height);
795  static int IsOpen(void) { return Osds.Size() && Osds[0]->level == OSD_LEVEL_DEFAULT; }
797  bool IsTrueColor(void) const { return isTrueColor; }
800  int Left(void) { return left; }
801  int Top(void) { return top; }
802  int Width(void) { return width; }
803  int Height(void) { return height; }
804  void SetAntiAliasGranularity(uint FixedColors, uint BlendColors);
815  cBitmap *GetBitmap(int Area);
823  virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null);
830  virtual void DestroyPixmap(cPixmap *Pixmap);
835  virtual void DrawImage(const cPoint &Point, const cImage &Image);
838  virtual void DrawImage(const cPoint &Point, int ImageHandle);
844  virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas);
852  virtual eOsdError SetAreas(const tArea *Areas, int NumAreas);
864  virtual void SaveRegion(int x1, int y1, int x2, int y2);
868  virtual void RestoreRegion(void);
871  virtual eOsdError SetPalette(const cPalette &Palette, int Area);
874  virtual void DrawPixel(int x, int y, tColor Color);
880  virtual void DrawBitmap(int x, int y, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool ReplacePalette = false, bool Overlay = false);
891  virtual void DrawScaledBitmap(int x, int y, const cBitmap &Bitmap, double FactorX, double FactorY, bool AntiAlias = false);
896  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);
902  virtual void DrawRectangle(int x1, int y1, int x2, int y2, tColor Color);
905  virtual void DrawEllipse(int x1, int y1, int x2, int y2, tColor Color, int Quadrants = 0);
915  virtual void DrawSlope(int x1, int y1, int x2, int y2, tColor Color, int Type);
927  virtual void Flush(void);
944  };
945 
946 #define MAXOSDIMAGES 64
947 
949  friend class cPixmapMemory;
950 private:
952  static int oldWidth;
953  static int oldHeight;
954  static double oldAspect;
955  static cImage *images[MAXOSDIMAGES];
956  static int osdState;
957 protected:
958  virtual cOsd *CreateOsd(int Left, int Top, uint Level) = 0;
961  virtual bool ProvidesTrueColor(void) { return false; }
963  virtual int StoreImageData(const cImage &Image);
974  virtual void DropImageData(int ImageHandle);
976  static const cImage *GetImageData(int ImageHandle);
978 public:
979  cOsdProvider(void);
980  //XXX maybe parameter to make this one "sticky"??? (frame-buffer etc.)
981  virtual ~cOsdProvider();
982  static cOsd *NewOsd(int Left, int Top, uint Level = OSD_LEVEL_DEFAULT);
988  static void UpdateOsdSize(bool Force = false);
993  static bool OsdSizeChanged(int &State);
999  static bool SupportsTrueColor(void);
1001  static int StoreImage(const cImage &Image);
1011  static void DropImage(int ImageHandle);
1014  static void Shutdown(void);
1016  };
1017 
1019 private:
1021  int left, top, width, height;
1022  const cFont *font;
1023  tColor colorFg, colorBg;
1024  int offset, shown;
1026  void DrawText(void);
1027 public:
1028  cTextScroller(void);
1029  cTextScroller(cOsd *Osd, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg);
1030  void Set(cOsd *Osd, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg);
1031  void Reset(void);
1032  int Left(void) { return left; }
1033  int Top(void) { return top; }
1034  int Width(void) { return width; }
1035  int Height(void) { return height; }
1036  int Total(void) { return textWrapper.Lines(); }
1037  int Offset(void) { return offset; }
1038  int Shown(void) { return shown; }
1039  bool CanScroll(void) { return CanScrollUp() || CanScrollDown(); }
1040  bool CanScrollUp(void) { return offset > 0; }
1041  bool CanScrollDown(void) { return offset + shown < Total(); }
1042  void Scroll(bool Up, bool Page);
1043  };
1044 
1045 #endif //__OSD_H
cRect(const cPoint &Point, const cSize &Size)
Definition: osd.h:360
cRect dirtyDrawPort
Definition: osd.h:465
int y2
Definition: osd.h:299
int Shown(void)
Definition: osd.h:1038
int maxColors
Definition: osd.h:92
static int OsdHeight(void)
Definition: osd.h:789
int y0
Definition: osd.h:172
void Lock(void)
Definition: thread.c:191
Definition: osd.h:36
cSize size
Definition: osd.h:355
int width
Definition: osd.h:1021
static int osdState
Definition: osd.h:956
cOsd * osd
Definition: osd.h:1020
int Height(void) const
Definition: osd.h:436
static int oldHeight
Definition: osd.h:953
void SetTop(int Top)
Definition: osd.h:386
Definition: osd.h:454
void SetAntiAliasGranularity(uint FixedColors, uint BlendColors)
Allows the system to optimize utilization of the limited color palette entries when generating blende...
Definition: osd.c:127
static cOsd * CreateOsd(int Left, int Top, int x0, int y0, int x1, int y1)
Definition: skinlcars.c:205
void Shift(const cPoint &Dp)
Definition: osd.h:390
int y
Definition: osd.h:309
cPoint(void)
Definition: osd.h:311
void SetWidth(int Width)
Definition: osd.h:383
void Shift(int Dx, int Dy)
Definition: osd.h:324
void Reset(void)
Resets the palette, making it contain no colors.
Definition: osd.c:138
static cOsdProvider * osdProvider
Definition: osd.h:951
tColor HsvToColor(double H, double S, double V)
Converts the given Hue (0..360), Saturation (0..1) and Value (0..1) to an RGB tColor value...
Definition: osd.c:19
void SetHeight(int Height)
Definition: osd.h:384
virtual void SetActive(bool On)
Sets this OSD to be the active one.
Definition: osd.h:757
cRect(const cRect &Rect)
Definition: osd.h:362
virtual ~cPalette()
Definition: osd.c:123
cRect Shifted(const cPoint &Dp) const
Definition: osd.h:392
bool operator<(const cSize &Size) const
Definition: osd.h:340
void SetOffset(int X0, int Y0)
Sets the offset of this bitmap to the given values.
Definition: osd.h:195
void Shift(const cPoint &Dp)
Definition: osd.h:325
int x1
Definition: osd.h:299
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
cRect drawPort
Definition: osd.h:463
int Alpha(void) const
Definition: osd.h:533
int numBitmaps
Definition: osd.h:729
bool operator!=(const cPoint &Point) const
Definition: osd.h:315
tIndex * bitmap
Definition: osd.h:171
const cRect & DrawPort(void) const
Returns the pixmap&#39;s draw port, which is relative to the view port.
Definition: osd.h:539
Definition: osd.h:419
int Index(tColor Color)
Returns the index of the given Color (the first color has index 0).
Definition: osd.c:144
cPoint(int X, int Y)
Definition: osd.h:312
void SetSize(int Width, int Height)
Definition: osd.h:379
cVector< cPixmap * > pixmaps
Definition: osd.h:731
int bpp
Definition: osd.h:91
bool tile
Definition: osd.h:461
bool isTrueColor
Definition: osd.h:726
int Width(void) const
Definition: osd.h:367
tIndex tIndexes[MAXNUMCOLORS]
Definition: osd.h:96
int X(void) const
Definition: osd.h:318
#define MAXOSDIMAGES
Definition: osd.h:946
bool IsEmpty(void) const
Returns true if this rectangle is empty.
Definition: osd.h:415
cPoint operator-(const cPoint &Point) const
Definition: osd.h:317
int bpp
Definition: osd.h:300
bool Active(void)
Definition: osd.h:756
Definition: osd.h:306
int Lines(void)
Returns the actual number of lines needed to display the full wrapped text.
Definition: font.h:113
cSize(const cSize &Size)
Definition: osd.h:337
virtual ~cPixmap()
Definition: osd.h:467
const uint8_t * Data(void)
Definition: osd.h:690
tColor Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const
Determines a color that consists of a linear blend between ColorFg and ColorBg.
Definition: osd.c:216
cSize(int Width, int Height)
Definition: osd.h:336
int OSDTop
Definition: config.h:319
cRect(void)
Definition: osd.h:358
static double oldAspect
Definition: osd.h:954
int Height(void) const
Definition: osd.h:342
int shown
Definition: osd.h:1024
void SetHeight(int Height)
Definition: osd.h:344
void SetY(int Y)
Definition: osd.h:382
int Bpp(void) const
Definition: osd.h:111
bool active
Definition: osd.h:734
bool Intersects(const tArea &Area) const
Definition: osd.h:303
static cMutex mutex
Definition: osd.h:458
bool Contains(const cPoint &Point) const
Definition: osd.h:347
Definition: osd.h:158
Definition: osd.h:169
int Width(void) const
Definition: osd.h:188
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
Definition: osd.h:525
Definition: osd.h:34
int Height(void)
Definition: osd.h:1035
bool operator!=(const cRect &Rect) const
Definition: osd.h:364
bool operator==(const cSize &Size) const
Definition: osd.h:338
const cRect & ViewPort(void) const
Returns the pixmap&#39;s view port, which is relative to the OSD&#39;s origin.
Definition: osd.h:535
cBitmap * savedBitmap
Definition: osd.h:727
void SetX(int X)
Definition: osd.h:320
bool operator!=(const cSize &Size) const
Definition: osd.h:339
Definition: osd.h:161
void Combine(const cRect &Rect)
Combines this rectangle with the given Rect.
Definition: osd.c:932
cRect Shifted(int Dx, int Dy) const
Definition: osd.h:391
Definition: osd.h:33
tColor color[MAXNUMCOLORS]
Definition: osd.h:90
void SetPoint(int X, int Y)
Definition: osd.h:377
int Width(void) const
Definition: osd.h:301
int Top(void)
Definition: osd.h:801
void Replace(const cPalette &Palette)
Replaces the colors of this palette with the colors from the given palette.
Definition: osd.c:208
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
Definition: osddemo.c:18
static cMutex mutex
Definition: osd.h:725
const cSize & Size(void) const
Definition: osd.h:374
void Set(int Width, int Height)
Definition: osd.h:345
static int OsdWidth(void)
Definition: osd.h:788
bool Tile(void) const
Definition: osd.h:534
cPoint operator-(void) const
Definition: osd.h:316
int width
Definition: osd.h:732
double antiAliasGranularity
Definition: osd.h:94
int numColors
Definition: osd.h:92
static cVector< cOsd * > Osds
Definition: osd.h:724
int Height(void) const
Definition: osd.h:189
Definition: osd.h:37
void Set(const cSize &Size)
Definition: osd.h:346
Definition: osd.h:39
Definition: osd.h:162
Definition: osd.h:352
void Set(cPoint Point, cSize Size)
Definition: osd.h:376
Definition: osd.h:164
const tColor * Data(void) const
Definition: osd.h:437
void SetBottom(int Bottom)
Definition: osd.h:388
const cRect & DirtyDrawPort(void) const
Returns the "dirty" rectangle in the draw port of this this pixmap.
Definition: osd.h:550
cRect viewPort
Definition: osd.h:462
int height
Definition: osd.h:333
void SetLeft(int Left)
Definition: osd.h:385
#define MAXOSDAREAS
Definition: osd.h:707
tColor GetPixel(const cPoint &Point) const
Returns the pixel value at the given Point.
Definition: osd.h:438
void Set(int X, int Y, int Width, int Height)
Definition: osd.h:375
cPoint(const cPoint &Point)
Definition: osd.h:313
int x2
Definition: osd.h:299
cPoint point
Definition: osd.h:354
const cRect & DirtyViewPort(void) const
Returns the "dirty" rectangle this pixmap causes on the OSD.
Definition: osd.h:543
const cFont * font
Definition: osd.h:1022
static const cCursesFont Font
Definition: skincurses.c:30
int Left(void) const
Definition: osd.h:369
tColor colorFg
Definition: osd.h:1023
The cOsd class is the interface to the "On Screen Display".
Definition: osd.h:720
Definition: osd.h:40
int Top(void)
Definition: osd.h:1033
void Set(const cPoint &Point)
Definition: osd.h:323
Definition: osd.h:330
cSetup Setup
Definition: config.c:373
tColor RgbToColor(uint8_t R, uint8_t G, uint8_t B)
Definition: osd.h:63
int Width(void) const
Definition: osd.h:341
bool panning
Definition: osd.h:685
tColor * data
Definition: osd.h:422
eTextAlignment
Definition: osd.h:158
bool CanScroll(void)
Definition: osd.h:1039
static int IsOpen(void)
Returns true if there is currently a level 0 OSD open.
Definition: osd.h:795
int OSDLeft
Definition: config.h:319
Definition: osd.h:38
Definition: thread.h:63
static const cRect Null
Definition: osd.h:357
int Width(void) const
Definition: osd.h:435
int Size(void) const
Definition: tools.h:551
int Right(void) const
Definition: osd.h:371
static int OsdTop(void)
Definition: osd.h:787
tColor AlphaBlend(tColor ColorFg, tColor ColorBg, uint8_t AlphaLayer=ALPHA_OPAQUE)
Definition: osd.c:81
const cPoint & Point(void) const
Definition: osd.h:373
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
Definition: osddemo.c:60
cPoint Shifted(const cPoint &Dp) const
Definition: osd.h:327
void SetColor(int Index, tColor Color)
Sets the palette entry at Index to Color.
Definition: osd.c:172
bool CanScrollUp(void)
Definition: osd.h:1040
void Grow(int Dx, int Dy)
Grows the rectangle by the given number of pixels in either direction.
Definition: osd.c:890
int Height(void)
Definition: osd.h:803
int Y0(void) const
Definition: osd.h:187
cRect(int X, int Y, int Width, int Height)
Definition: osd.h:359
void SetRight(int Right)
Definition: osd.h:387
static int OsdLeft(void)
Definition: osd.h:786
Definition: osd.h:41
int Left(void)
Definition: osd.h:1032
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
Definition: osd.h:58
void Set(int X, int Y)
Definition: osd.h:322
int Height(void) const
Definition: osd.h:302
const cSize & Size(void) const
Definition: osd.h:434
#define MAXNUMCOLORS
Definition: osd.h:24
int Height(void) const
Definition: osd.h:368
void Shift(int Dx, int Dy)
Definition: osd.h:389
int y1
Definition: osd.h:299
Definition: osd.h:88
Definition: osd.h:298
#define OSD_LEVEL_DEFAULT
Definition: osd.h:21
int Width(void)
Definition: osd.h:802
eOsdError
Definition: osd.h:44
cSize Grown(int Dw, int Dh) const
Definition: osd.h:349
Definition: osd.h:159
int alpha
Definition: osd.h:460
int Left(void)
Definition: osd.h:800
cRect Combined(const cPoint &Point) const
Returns the surrounding rectangle that contains this rectangle and the given Point.
Definition: osd.h:412
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
Definition: osd.h:961
int Width(void)
Definition: osd.h:1034
cPixmapMemory * savedPixmap
Definition: osd.h:730
cSize size
Definition: osd.h:421
bool modified
Definition: osd.h:93
tColor RgbShade(tColor Color, double Factor)
Returns a brighter (Factor > 0) or darker (Factor < 0) version of the given Color.
Definition: osd.c:43
int Y(void) const
Definition: osd.h:319
static int oldWidth
Definition: osd.h:952
Definition: osd.h:44
Definition: osd.h:160
int ClosestColor(tColor Color, int MaxDiff=INT_MAX) const
Returns the index of a color in this palette that is closest to the given Color.
Definition: osd.c:235
cPixmapMutexLock(void)
Definition: osd.h:674
tColor Color(int Index) const
Returns the color at the given Index.
Definition: osd.h:119
tColor GetColor(int x, int y) const
Returns the color at the given coordinates.
Definition: osd.h:277
int Bottom(void) const
Definition: osd.h:372
void SetWidth(int Width)
Definition: osd.h:343
void Take(const cPalette &Palette, tIndexes *Indexes=NULL, tColor ColorFg=0, tColor ColorBg=0)
Takes the colors from the given Palette and adds them to this palette, using existing entries if poss...
Definition: osd.c:191
cRect Combined(const cRect &Rect) const
Returns the surrounding rectangle that contains this rectangle and the given Rect.
Definition: osd.h:407
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
Definition: osd.h:442
int X(void) const
Definition: osd.h:365
void SetY(int Y)
Definition: osd.h:321
void SetSize(const cSize &Size)
Definition: osd.h:380
int width
Definition: osd.h:332
uint level
Definition: osd.h:733
void Grow(int Dw, int Dh)
Definition: osd.h:348
cRect Grown(int Dw, int Dh) const
Definition: osd.h:396
static void Unlock(void)
Definition: osd.h:531
void SetBpp(int Bpp)
Sets the color depth of this palette to the given value.
Definition: osd.c:165
int OSDHeight
Definition: config.h:319
int X0(void) const
Definition: osd.h:186
cRect(const cSize &Size)
Definition: osd.h:361
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
int OSDWidth
Definition: config.h:319
uint8_t tIndex
Definition: font.h:31
int Layer(void) const
Definition: osd.h:532
cPoint Shifted(int Dx, int Dy) const
Definition: osd.h:326
cSize(void)
Definition: osd.h:335
void SetPoint(const cPoint &Point)
Definition: osd.h:378
cPalette(int Bpp=8)
Initializes the palette with the given color depth.
Definition: osd.c:117
int Y(void) const
Definition: osd.h:366
Definition: osd.h:52
tColor * data
Definition: osd.h:684
uint8_t tIndex
Definition: osd.h:56
cRect dirtyViewPort
Definition: osd.h:464
Definition: osd.h:35
void SetX(int X)
Definition: osd.h:381
bool operator==(const cRect &Rect) const
Definition: osd.h:363
uint32_t tColor
Definition: osd.h:55
Definition: font.h:37
int x
Definition: osd.h:308
int Top(void) const
Definition: osd.h:370
int width
Definition: osd.h:173
int Offset(void)
Definition: osd.h:1037
int layer
Definition: osd.h:459
cTextWrapper textWrapper
Definition: osd.h:1025
#define ALPHA_OPAQUE
Definition: osd.h:26
bool operator==(const cPoint &Point) const
Definition: osd.h:314
static int osdWidth
Definition: osd.h:723
uint32_t tColor
Definition: font.h:29
bool CanScrollDown(void)
Definition: osd.h:1041
int dirtyY2
Definition: osd.h:174
void Unlock(void)
Definition: thread.c:197
int Total(void)
Definition: osd.h:1036