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; }
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);
210 bool LoadXpm(
const char *FileName);
213 bool SetXpm(
const char *
const Xpm[],
bool IgnoreNone =
false);
232 void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
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(); }
393 void Grow(
int Dx,
int Dy);
452 #define MAXPIXMAPLAYERS 8 592 virtual void Clear(
void) = 0;
681 #define LOCK_PIXMAPS cPixmapMutexLock PixmapMutexLock 694 const uint8_t *
Data(
void) {
return (uint8_t *)
data; }
695 virtual void Clear(
void);
711 #define MAXOSDAREAS 16 788 #ifndef DEPRECATED_GETBITMAP 789 #define DEPRECATED_GETBITMAP 0 791 #if DEPRECATED_GETBITMAP 881 virtual void SaveRegion(
int x1,
int y1,
int x2,
int y2);
897 virtual void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
908 virtual void DrawScaledBitmap(
int x,
int y,
const cBitmap &Bitmap,
double FactorX,
double FactorY,
bool AntiAlias =
false);
922 virtual void DrawEllipse(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Quadrants = 0);
932 virtual void DrawSlope(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Type);
944 virtual void Flush(
void);
963 #define MAXOSDIMAGES 64 1059 void Scroll(
bool Up,
bool Page);
cRect(const cPoint &Point, 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...
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 ...
void Fill(tIndex Index)
Fills the bitmap data with the given Index.
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]
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...
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 const cSize & MaxPixmapSize(void) const
Returns the maximum possible size of a pixmap this OSD can create.
cPoint Shifted(const cPoint &Dp) const
bool Contains(int x, int y) const
Returns true if this bitmap contains the point (x, y).
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.
void SetOffset(int X0, int Y0)
Sets the offset of this bitmap to the given values.
bool SetXpm(const char *const Xpm[], bool IgnoreNone=false)
Sets this bitmap to the given XPM data.
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 ...
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...
cRect Grown(int Dw, int Dh) const
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...
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 ...
cRect Shifted(const cPoint &Dp) const
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...
cPoint Shifted(int Dx, int Dy) const
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]
void MarkViewPortDirty(const cRect &Rect)
Marks the given rectangle of the view port of this pixmap as dirty.
bool operator!=(const cRect &Rect) const
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...
const cRect & DrawPort(void) const
Returns the pixmap's draw port, which is relative to the view port.
cSize(int Width, int Height)
virtual int StoreImageData(const cImage &Image)
Copies the given Image and returns a handle for later reference.
bool Contains(const cPoint &Point) const
Returns true if this rectangle contains Point.
virtual eOsdError SetPalette(const cPalette &Palette, int Area)
Sets the Palette for the given Area (the first area is numbered 0).
virtual void Fill(tColor Color)
Fills the pixmap's draw port with the given Color.
static bool OsdSizeChanged(int &State)
Checks if the OSD size has changed and a currently displayed OSD needs to be redrawn.
tColor Color(int Index) const
Returns the color at the given Index.
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...
cPoint operator-(const cPoint &Point) const
void SetHeight(int Height)
bool operator==(const cRect &Rect) const
bool operator<(const cSize &Size) const
bool operator!=(const cPoint &Point) const
const tColor * Data(void) const
virtual void Flush(void)
Actually commits all data to the OSD hardware.
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.
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.
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.
tColor GetColor(int x, int y) const
Returns the color at the given coordinates.
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.
void Set(int Width, int Height)
static int OsdWidth(void)
const cPoint & Point(void) const
static cSize maxPixmapSize
cRect Intersected(const cRect &Rect) const
Returns the intersection of this rectangle and the given Rect.
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
double antiAliasGranularity
static cVector< cOsd * > Osds
void Set(const cSize &Size)
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)
void SetBottom(int Bottom)
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...
tColor GetPixel(const cPoint &Point) const
Returns the pixel value at the given Point.
const tIndex * Data(int x, int y) const
Returns the address of the index byte at the given coordinates.
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 Set(int X, int Y, int Width, int Height)
cPoint(const cPoint &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.
static const cCursesFont Font
cRect Combined(const cPoint &Point) const
Returns the surrounding rectangle that contains this rectangle and the given Point.
const tColor * Colors(int &NumColors) const
Returns a pointer to the complete color table and stores the number of valid entries in NumColors...
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.
cBitmap * Scaled(double FactorX, double FactorY, bool AntiAlias=false) const
Creates a copy of this bitmap, scaled by the given factors.
bool operator==(const cSize &Size) const
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.
cRect Shifted(int Dx, int Dy) const
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)
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 cRect & DirtyViewPort(void) const
Returns the "dirty" rectangle this pixmap causes on the OSD.
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...
bool operator==(const cPoint &Point) const
cPoint operator-(void) const
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.
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.
const cRect & DirtyDrawPort(void) const
Returns the "dirty" rectangle in the draw port of this this pixmap.
#define OSD_LEVEL_DEFAULT
tColor Blend(tColor ColorFg, tColor ColorBg, uint8_t Level) const
Determines a color that consists of a linear blend between ColorFg and ColorBg.
bool IsTrueColor(void) const
Returns 'true' if this is a true color OSD (providing full 32 bit color depth).
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...
const cSize & Size(void) const
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.
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.
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().
bool Intersects(const cRect &Rect) const
Returns true if this rectangle intersects with Rect.
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)
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.
cSize Grown(int Dw, int Dh) const
bool Intersects(const tArea &Area) const
static void DropImage(int ImageHandle)
Drops the image referenced by the given ImageHandle.
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).
cRect Combined(const cRect &Rect) const
Returns the surrounding rectangle that contains this rectangle and the given Rect.
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
cPixmap * RenderPixmaps(void)
Renders the dirty part of all pixmaps into a resulting pixmap that shall be displayed on the OSD...
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 Contains(const cPoint &Point) const
bool IsEmpty(void) const
Returns true if this rectangle is empty.
const cRect & ViewPort(void) const
Returns the pixmap's view port, which is relative to the OSD's origin.
const cSize & Size(void) 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.
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...