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