21 #define OSD_LEVEL_DEFAULT 0
22 #define OSD_LEVEL_SUBTITLES 10
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
70 return RgbToColor(uint8_t(0xFF * R), uint8_t(0xFF * G), uint8_t(0xFF * B));
183 cBitmap(
const char *
const Xpm[]);
186 int X0(
void)
const {
return x0; }
187 int Y0(
void)
const {
return y0; }
197 bool Covers(
int x1,
int y1,
int x2,
int y2)
const;
200 bool Intersects(
int x1,
int y1,
int x2,
int y2)
const;
203 bool Dirty(
int &x1,
int &y1,
int &x2,
int &y2);
208 bool LoadXpm(
const char *FileName);
211 bool SetXpm(
const char *
const Xpm[],
bool IgnoreNone =
false);
228 void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
286 cBitmap *
Scaled(
double FactorX,
double FactorY,
bool AntiAlias =
false);
314 int X(
void)
const {
return x; }
315 int Y(
void)
const {
return y; }
320 void Shift(
int Dx,
int Dy) {
x += Dx;
y += Dy; }
365 int Left(
void)
const {
return X(); }
366 int Top(
void)
const {
return Y(); }
389 void Grow(
int Dx,
int Dy);
448 #define MAXPIXMAPLAYERS 8
584 virtual void Clear(
void) = 0;
673 #define LOCK_PIXMAPS cPixmapMutexLock PixmapMutexLock
686 const uint8_t *
Data(
void) {
return (uint8_t *)
data; }
687 virtual void Clear(
void);
703 #define MAXOSDAREAS 16
857 virtual void SaveRegion(
int x1,
int y1,
int x2,
int y2);
873 virtual void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
893 virtual void DrawEllipse(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Quadrants = 0);
903 virtual void DrawSlope(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Type);
915 virtual void Flush(
void);
931 #define MAXOSDIMAGES 64
1020 void Scroll(
bool Up,
bool Page);
cRect(const cPoint &Point, const cSize &Size)
void ReduceBpp(const cPalette &Palette)
Reduces the color depth of the bitmap to that of the given Palette.
virtual void Pan(const cPoint &Dest, const cRect &Source=cRect::Null)
Does the same as Scroll(), but also shifts the draw port accordingly, so that the view port doesn't g...
static int OsdHeight(void)
virtual void DrawPixel(const cPoint &Point, tColor Color)=0
Sets the pixel at the given Point to the given Color, which is a full 32 bit ARGB value...
void SetAntiAliasGranularity(uint FixedColors, uint BlendColors)
Allows the system to optimize utilization of the limited color palette entries when generating blende...
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
bool Covers(int x1, int y1, int x2, int y2) const
Returns true if the rectangle defined by the given coordinates completely covers this bitmap...
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 this bitmap with the data from the given Bitmap, putting the upper left corner of ...
void Shift(const cPoint &Dp)
virtual void Pan(const cPoint &Dest, const cRect &Source=cRect::Null)=0
Does the same as Scroll(), but also shifts the draw port accordingly, so that the view port doesn't g...
static cImage * images[MAXOSDIMAGES]
virtual void SetViewPort(const cRect &Rect)
Sets the pixmap's view port to the given Rect.
void Shift(int Dx, int Dy)
void Clean(void)
Marks the dirty area as clean.
void Reset(void)
Resets the palette, making it contain no colors.
static cOsdProvider * osdProvider
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...
virtual void Scroll(const cPoint &Dest, const cRect &Source=cRect::Null)
Scrolls the data in the pixmap's draw port to the given Dest point.
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
void SetHeight(int Height)
virtual void SetActive(bool On)
Sets this OSD to be the active one.
static const cImage * GetImageData(int ImageHandle)
Gets the image data referenced by ImageHandle.
cRect Shifted(const cPoint &Dp) const
bool operator<(const cSize &Size) const
bool SetXpm(const char *const Xpm[], bool IgnoreNone=false)
Sets this bitmap to the given XPM data.
void Shift(const cPoint &Dp)
virtual void DrawPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to the given Color, which is a full 32 bit ARGB value...
static void SetOsdPosition(int Left, int Top, int Width, int Height)
Sets the position and size of the OSD to the given values.
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)
Copies the part of the given Pixmap covered by Source into this pixmap at location Dest...
const tColor * Colors(int &NumColors) const
Returns a pointer to the complete color table and stores the number of valid entries in NumColors...
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 ...
bool operator!=(const cPoint &Point) const
const cRect & DrawPort(void) const
Returns the pixmap's draw port, which is relative to the view port.
int Index(tColor Color)
Returns the index of the given Color (the first color has index 0).
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...
void SetSize(int Width, int Height)
void Set(cOsd *Osd, int Left, int Top, int Width, int Height, const char *Text, const cFont *Font, tColor ColorFg, tColor ColorBg)
cVector< cPixmap * > pixmaps
tIndex tIndexes[MAXNUMCOLORS]
cBitmap * Scaled(double FactorX, double FactorY, bool AntiAlias=false)
Creates a copy of this bitmap, scaled by the given factors.
bool IsEmpty(void) const
Returns true if this rectangle is empty.
cPoint operator-(const cPoint &Point) const
void MarkViewPortDirty(const cRect &Rect)
Marks the given rectangle of the view port of this pixmap as dirty.
int Lines(void)
Returns the actual number of lines needed to display the full wrapped text.
virtual void SetDrawPortPoint(const cPoint &Point, bool Dirty=true)
Sets the pixmap's draw port to the given Point.
const uint8_t * Data(void)
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...
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...
tColor Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const
Determines a color that consists of a linear blend between ColorFg and ColorBg.
cSize(int Width, int Height)
virtual int StoreImageData(const cImage &Image)
Copies the given Image and returns a handle for later reference.
virtual eOsdError SetPalette(const cPalette &Palette, int Area)
Sets the Palette for the given Area (the first area is numbered 0).
cPixmapMemory * RenderPixmaps(void)
Renders the dirty part of all pixmaps into a resulting pixmap that shall be displayed on the OSD...
virtual void Fill(tColor Color)
Fills the pixmap's draw port with the given Color.
virtual void SetAlpha(int Alpha)
Sets the alpha value of this pixmap to the given value.
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...
void SetHeight(int Height)
virtual void Flush(void)
Actually commits all data to the OSD hardware.
bool Intersects(const tArea &Area) const
bool Contains(const cPoint &Point) const
void Scroll(bool Up, bool Page)
static void Lock(void)
All public member functions of cPixmap set locks as necessary to make sure they are thread-safe (unle...
cPixmap * AddPixmap(cPixmap *Pixmap)
Adds the given Pixmap to the list of currently active pixmaps in this OSD.
bool operator!=(const cRect &Rect) const
bool operator==(const cSize &Size) const
const cRect & ViewPort(void) const
Returns the pixmap's view port, which is relative to the OSD's origin.
void SetSize(int Width, int Height)
Sets the size of this bitmap to the given values.
bool operator!=(const cSize &Size) const
void Combine(const cRect &Rect)
Combines this rectangle with the given Rect.
cRect Shifted(int Dx, int Dy) const
tColor color[MAXNUMCOLORS]
void SetPoint(int X, int Y)
virtual cOsd * CreateOsd(int Left, int Top, uint Level)=0
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates...
virtual void DrawImage(const cPoint &Point, const cImage &Image)=0
Draws the given Image into this pixmap at the given Point.
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
Draws the given string at Point with the given foreground and background color and font...
void Replace(const cPalette &Palette)
Replaces the colors of this palette with the colors from the given palette.
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 ...
bool LoadXpm(const char *FileName)
Calls SetXpm() with the data from the file FileName.
const cSize & Size(void) const
void Set(int Width, int Height)
static int OsdWidth(void)
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
cPoint operator-(void) const
double antiAliasGranularity
static cVector< cOsd * > Osds
void Set(const cSize &Size)
bool Intersects(int x1, int y1, int x2, int y2) const
Returns true if the rectangle defined by the given coordinates intersects with this bitmap...
virtual void DrawRectangle(const cRect &Rect, tColor Color)
Draws a filled rectangle with the given Color.
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
void Set(cPoint Point, cSize Size)
const tColor * Data(void) const
void SetBottom(int Bottom)
const cRect & DirtyDrawPort(void) const
Returns the "dirty" rectangle in the draw port of this this pixmap.
virtual ~cOsd()
Shuts down the OSD.
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...
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...
tColor GetPixel(const cPoint &Point) const
Returns the pixel value at the given Point.
void Set(int X, int Y, int Width, int Height)
cPoint(const cPoint &Point)
bool Contains(const cPoint &Point) const
Returns true if this rectangle contains Point.
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...
static void UpdateOsdSize(bool Force=false)
Inquires the actual size of the video display and adjusts the OSD and font sizes accordingly.
const cRect & DirtyViewPort(void) const
Returns the "dirty" rectangle this pixmap causes on the OSD.
bool Contains(int x, int y) const
Returns true if this bitmap contains the point (x, y).
static const cCursesFont Font
cRect Intersected(const cRect &Rect) const
Returns the intersection of this rectangle and the given Rect.
The cOsd class is the interface to the "On Screen Display".
void Set(const cPoint &Point)
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)=0
Renders the part of the given Pixmap covered by Source into this pixmap at location Dest...
void SetClean(void)
Resets the "dirty" rectangles of this pixmap.
tColor RgbToColor(uint8_t R, uint8_t G, uint8_t B)
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image into this pixmap at the given Point.
static int IsOpen(void)
Returns true if there is currently a level 0 OSD open.
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...
void Clear(void)
Clears the image data by setting all pixels to be fully transparent.
virtual void SetTile(bool Tile)
Sets the tile property of this pixmap to the given value.
tColor AlphaBlend(tColor ColorFg, tColor ColorBg, uint8_t AlphaLayer=ALPHA_OPAQUE)
const cPoint & Point(void) const
cPoint Shifted(const cPoint &Dp) const
void SetColor(int Index, tColor Color)
Sets the palette entry at Index to Color.
void Grow(int Dx, int Dy)
Grows the rectangle by the given number of pixels in either direction.
virtual void DrawPixmap(const cPixmap *Pixmap, const cRect &Dirty)
Draws the Dirty part of the given Pixmap into this pixmap.
cRect(int X, int Y, int Width, int Height)
void ShrinkBpp(int NewBpp)
Shrinks the color depth of the bitmap to NewBpp by keeping only the 2^NewBpp most frequently used col...
tColor ArgbToColor(uint8_t A, uint8_t R, uint8_t G, uint8_t B)
virtual cPixmap * CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort=cRect::Null)
Creates a new true color pixmap on this OSD (see cPixmap for details).
virtual void Fill(tColor Color)=0
Fills the pixmap's draw port with the given Color.
const tIndex * Data(int x, int y) const
Returns the address of the index byte at the given coordinates.
const cSize & Size(void) const
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)
Draws the given string at Point with the given foreground and background color and font...
static bool SupportsTrueColor(void)
Returns true if the current OSD provider is able to handle a true color OSD.
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants=0)=0
Draws a filled ellipse with the given Color that fits into the given rectangle.
virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)
Renders the part of the given Pixmap covered by Source into this pixmap at location Dest...
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type)
Draws a "slope" with the given Color into the given rectangle.
void Shift(int Dx, int Dy)
virtual void Clear(void)
Clears the pixmap's draw port by setting all pixels to be fully transparent.
#define OSD_LEVEL_DEFAULT
cSize Grown(int Dw, int Dh) const
cBitmap * bitmaps[MAXOSDAREAS]
virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg=0, tColor ColorBg=0, bool Overlay=false)=0
Sets the pixels in the OSD with the data from the given Bitmap, putting the upper left corner of the ...
virtual void DrawSlope(const cRect &Rect, tColor Color, int Type)=0
Draws a "slope" with the given Color into the given rectangle.
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...
cRect Combined(const cPoint &Point) const
Returns the surrounding rectangle that contains this rectangle and the given Point.
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
virtual void DrawImage(const cPoint &Point, const cImage &Image)
Draws the given Image on this OSD at the given Point.
cPixmapMemory * savedPixmap
void MarkDrawPortDirty(const cRect &Rect)
Marks the given rectangle of the draw port of this pixmap as dirty.
tColor RgbShade(tColor Color, double Factor)
Returns a brighter (Factor > 0) or darker (Factor < 0) version of the given Color.
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.
tColor Color(int Index) const
Returns the color at the given Index.
tColor GetColor(int x, int y) const
Returns the color at the given coordinates.
static int StoreImage(const cImage &Image)
Stores the given Image for later use with DrawImage() on an OSD or pixmap.
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...
virtual void SetLayer(int Layer)
Sets the layer of this pixmap to the given value.
void Fill(tColor Color)
Fills the image data with the given Color.
cRect Combined(const cRect &Rect) const
Returns the surrounding rectangle that contains this rectangle and the given Rect.
void SetPixel(const cPoint &Point, tColor Color)
Sets the pixel at the given Point to Color.
cOsd(int Left, int Top, uint Level)
Initializes the OSD with the given coordinates.
void SetSize(const cSize &Size)
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
virtual void Clear(void)=0
Clears the pixmap's draw port by setting all pixels to be fully transparent.
virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants=0)
Draws a filled ellipse with the given Color that fits into the given rectangle.
void SetAntiAliasGranularity(uint FixedColors, uint BlendColors)
Allows the system to optimize utilization of the limited color palette entries when generating blende...
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...
void Grow(int Dw, int Dh)
cRect Grown(int Dw, int Dh) const
void SetBpp(int Bpp)
Sets the color depth of this palette to the given value.
virtual void DropImageData(int ImageHandle)
Drops the image data referenced by ImageHandle.
bool IsTrueColor(void) const
Returns 'true' if this is a true color OSD (providing full 32 bit color depth).
static void DropImage(int ImageHandle)
Drops the image referenced by the given ImageHandle.
cPoint Shifted(int Dx, int Dy) const
void SetPoint(const cPoint &Point)
cPalette(int Bpp=8)
Initializes the palette with the given color depth.
cBitmap(int Width, int Height, int Bpp, int X0=0, int Y0=0)
Creates a bitmap with the given Width, Height and color depth (Bpp).
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
void SetIndex(int x, int y, tIndex Index)
Sets the index at the given coordinates to Index.
cBitmap * GetBitmap(int Area)
Returns a pointer to the bitmap for the given Area, or NULL if no such bitmap exists.
bool Intersects(const cRect &Rect) const
Returns true if this rectangle intersects with Rect.
bool operator==(const cRect &Rect) const
static void Shutdown(void)
Shuts down the OSD provider facility by deleting the current OSD provider.
virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest)=0
Copies the part of the given Pixmap covered by Source into this pixmap at location Dest...
virtual void DrawRectangle(const cRect &Rect, tColor Color)=0
Draws a filled rectangle with the given Color.
bool operator==(const cPoint &Point) const
virtual void Scroll(const cPoint &Dest, const cRect &Source=cRect::Null)=0
Scrolls the data in the pixmap's draw port to the given Dest point.
static cOsd * NewOsd(int Left, int Top, uint Level=OSD_LEVEL_DEFAULT)
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates...