Go to the documentation of this file.
8 #include <linux/dvb/osd.h>
14 #define MAX_NUM_FONTFACES 8
15 #define MAX_NUM_FONTS 8
16 #define MAX_BITMAP_SIZE (1024*1024)
55 virtual void SaveRegion(
int x1,
int y1,
int x2,
int y2);
58 virtual void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
61 virtual void DrawEllipse(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Quadrants = 0);
62 virtual void DrawSlope(
int x1,
int y1,
int x2,
int y2,
tColor Color,
int Type);
63 virtual void Flush(
void);
67 :
cOsd(Left, Top, Level)
83 memset(&config, 0,
sizeof(config));
136 for (
int i = 0; i < NumAreas; i++)
138 if (Areas[i].bpp != 1 && Areas[i].bpp != 2 && Areas[i].bpp != 4 && Areas[i].bpp != 8)
150 for (
int i = 0; i < NumAreas; i++)
161 for (
int i = 0; (bitmap =
GetBitmap(i)) != NULL; i++)
211 for (i = 0; i < numColors; i++)
214 if (ColorFg || ColorBg)
237 for (
int yc = 0; yc <
height; yc += chunk)
243 (uint8_t *) Bitmap.
Data(0, yc),
width, hc,
278 if (pFontFace == NULL)
283 FILE * fp = fopen(fontFileName,
"rb");
286 fseek(fp, 0, SEEK_END);
287 long fileSize = ftell(fp);
288 fseek(fp, 0, SEEK_SET);
291 uint8_t * buffer =
new uint8_t[fileSize];
294 if (fread(buffer, fileSize, 1, fp) == 1)
310 if (pFontFace == NULL)
348 if ((Alignment &
taLeft) != 0)
350 #if (APIVERSNUM >= 10728)
355 else if ((Alignment &
taRight) != 0)
359 #if (APIVERSNUM >= 10728)
367 x += (
Width - w) / 2;
372 if ((Alignment &
taTop) != 0)
374 else if ((Alignment &
taBottom) != 0)
396 while (*s && (len < (
sizeof(tmp) - 1)))
425 switch (abs(Quadrants))
511 x2 - x1 + 1, y2 - y1 + 1, Color, Type);
523 for (
int i = 0; (Bitmap =
GetBitmap(i)) != NULL; i++)
530 if (Bitmap->
Dirty(x1, y1, x2, y2))
565 virtual void Flush(
void);
569 :
cOsd(Left, Top, Level)
637 for (
int i = 0; i < NumAreas; i++)
639 if (Areas[i].bpp != 1 && Areas[i].bpp != 2 && Areas[i].bpp != 4 && Areas[i].bpp != 8
649 for (
int i = 0; i < NumAreas; i++)
666 #ifdef MEASURE_OSD_TIME
667 struct timeval start;
669 struct timezone timeZone;
670 gettimeofday(&start, &timeZone);
676 uint8_t * buffer = 0;
684 #if (APIVERSNUM >= 20110)
690 int w = pm->ViewPort().Width();
691 int h = pm->ViewPort().Height();
692 int d = w *
sizeof(
tColor);
696 for (
int y = 0; y < h; y += Chunk)
704 Left() + pm->ViewPort().X(),
Top() + pm->ViewPort().Y() + y,
705 pm->Data() + y * d, w, hc, hc * d,
710 const tColor * pixmapData = (
const tColor *) (pm->Data() + y * d);
711 uint8_t * bitmapData = buffer;
712 for (
int i = 0; i < hc * w; i++)
714 bitmapData[2] = (pixmapData[i] & 0xFF000000) >> 24;
715 bitmapData[1] = ((pixmapData[i] & 0x00F80000) >> 16)
716 | ((pixmapData[i] & 0x0000E000) >> 13);
717 bitmapData[0] = ((pixmapData[i] & 0x00001C00) >> 5)
718 | ((pixmapData[i] & 0x000000F8) >> 3);
722 Left() + pm->ViewPort().X(),
Top() + pm->ViewPort().Y() + y,
723 buffer, w, hc, hc * w * 3,
728 const tColor * pixmapData = (
const tColor *) (pm->Data() + y * d);
729 uint16_t * bitmapData = (uint16_t *) buffer;
730 for (
int i = 0; i < hc * w; i++)
732 bitmapData[i] = ((pixmapData[i] & 0xF0000000) >> 16)
733 | ((pixmapData[i] & 0x00F00000) >> 12)
734 | ((pixmapData[i] & 0x0000F000) >> 8)
735 | ((pixmapData[i] & 0x000000F0) >> 4);
738 Left() + pm->ViewPort().X(),
Top() + pm->ViewPort().Y() + y,
739 buffer, w, hc, hc * w * 2,
743 #if (APIVERSNUM >= 20110)
759 for (
int i = 0; (bitmap =
GetBitmap(i)) != NULL; i++)
761 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
766 x2 = bitmap->
Width() - 1;
767 y2 = bitmap->
Height() - 1;
774 for (
int c = 0; c < numColors; c++)
788 int width = x2 - x1 + 1;
793 for (
int y = 0; y <
height; y += chunk)
798 for (
int r = 0; r < hc; r++)
801 Left() + bitmap->
X0() + x1,
Top() + bitmap->
Y0() + y1 + y,
814 #ifdef MEASURE_OSD_TIME
815 gettimeofday(&end, &timeZone);
816 int timeNeeded = end.tv_usec - start.tv_usec;
817 timeNeeded += (end.tv_sec - start.tv_sec) * 1000000;
818 printf(
"time = %d\n", timeNeeded);
const tIndex * Data(int x, int y) const
Returns the address of the index byte at the given coordinates.
uint32_t CmdOsdCreatePalette(HdffColorType_t ColorType, HdffColorFormat_t ColorFormat, uint32_t NumColors, const uint32_t *pColors)
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 CmdOsdSetPaletteColors(uint32_t hPalette, HdffColorFormat_t ColorFormat, uint8_t StartColor, uint32_t NumColors, const uint32_t *pColors)
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
cHdffOsd(int Left, int Top, HDFF::cHdffCmdIf *pHdffCmdIf, uint Level)
struct _tFontFace tFontFace
@ HDFF_COLOR_TYPE_ARGB4444
The cOsd class is the interface to the "On Screen Display".
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
virtual cOsd * CreateOsd(int Left, int Top, uint Level)
Returns a pointer to a newly created cOsd object, which will be located at the given coordinates.
virtual int Size(void) const
Returns the original size as requested when the font was created.
@ HDFF_COLOR_TYPE_ARGB8565
void CmdOsdSetDisplayOutputRectangle(uint32_t hDisplay, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
void CmdOsdDrawUtf8Text(uint32_t hDisplay, uint32_t hFont, int X, int Y, const char *pText, uint32_t Color)
void CmdOsdDeletePalette(uint32_t hPalette)
void CmdOsdDrawSlope(uint32_t hDisplay, int X, int Y, int Width, int Height, uint32_t Color, uint32_t Type)
void CmdOsdRestoreRegion(uint32_t hDisplay)
@ HDFF_DRAW_QUARTER_TOP_LEFT
uint32_t CmdOsdCreateDisplay(uint32_t Width, uint32_t Height, HdffColorType_t ColorType)
@ HDFF_DRAW_QUARTER_BOTTOM_RIGHT_INVERTED
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
void CmdOsdConfigure(const HdffOsdConfig_t *pConfig)
void CmdOsdDeleteDisplay(uint32_t hDisplay)
@ HDFF_DRAW_QUARTER_BOTTOM_LEFT_INVERTED
virtual int Width(void) const
Returns the original character width as requested when the font was created, or 0 if the default widt...
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 CmdOsdDrawTextW(uint32_t hDisplay, uint32_t hFont, int X, int Y, const uint16_t *pText, uint32_t Color)
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
const tColor * Colors(int &NumColors) const
Returns a pointer to the complete color table and stores the number of valid entries in NumColors.
void Clean(void)
Marks the dirty area as clean.
#define HDFF_SIZE_FULL_SCREEN
virtual void SaveRegion(int x1, int y1, int x2, int y2)
Saves the region defined by the given coordinates for later restoration through RestoreRegion().
virtual void Flush(void)
Actually commits all data to the OSD hardware.
void CmdOsdDrawBitmap(uint32_t hDisplay, int X, int Y, const uint8_t *pBitmap, int BmpWidth, int BmpHeight, int BmpSize, HdffColorType_t ColorType, uint32_t hPalette)
cHdffOsdProvider(HDFF::cHdffCmdIf *pHdffCmdIf)
tFont mFonts[MAX_NUM_FONTS]
cBitmap * GetBitmap(int Area)
Returns a pointer to the bitmap for the given Area, or NULL if no such bitmap exists.
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
virtual void SetActive(bool On)
Sets this OSD to be the active one.
uint32_t mBitmapColors[256]
cPixmap * RenderPixmaps(void)
Renders the dirty part of all pixmaps into a resulting pixmap that shall be displayed on the OSD.
void CmdOsdRenderDisplay(uint32_t hDisplay)
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...
@ HDFF_DRAW_QUARTER_BOTTOM_RIGHT
void CmdOsdSaveRegion(uint32_t hDisplay, int X, int Y, int Width, int Height)
virtual void Flush(void)
Actually commits all data to the OSD hardware.
void CmdOsdSetDisplayClippingArea(uint32_t hDisplay, bool Enable, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
void CmdOsdDrawEllipse(uint32_t hDisplay, int CX, int CY, int RadiusX, int RadiusY, uint32_t Color, uint32_t Flags)
#define HDFF_INVALID_HANDLE
HDFF::cHdffCmdIf * mHdffCmdIf
uint32_t CmdGetFirmwareVersion(char *pString, uint32_t MaxLength)
#define MAX_NUM_FONTFACES
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
@ HDFF_DRAW_QUARTER_TOP_RIGHT
HDFF::cHdffCmdIf * mHdffCmdIf
#define TEXT_ALIGN_BORDER
void CmdOsdDeleteFont(uint32_t hFont)
uint32_t CmdOsdCreateFont(uint32_t hFontFace, uint32_t Size)
tFontFace mFontFaces[MAX_NUM_FONTFACES]
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
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 ...
void GetOsdSize(int &Width, int &Height, double &PixelAspect)
void CmdOsdDrawRectangle(uint32_t hDisplay, int X, int Y, int Width, int Height, uint32_t Color)
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
virtual const char * FontName(void) const
Returns the font name.
uint32_t CmdOsdCreateFontFace(const uint8_t *pFontData, uint32_t DataSize)
static int Utf8CharLen(const char *s)
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 ...
@ HDFF_DRAW_QUARTER_BOTTOM_LEFT
@ HDFF_DRAW_QUARTER_TOP_RIGHT_INVERTED
@ HDFF_COLOR_TYPE_ARGB8888
virtual void SetActive(bool On)
Sets this OSD to be the active one.
virtual void SetActive(bool On)
Sets this OSD to be the active one.
cHdffOsdRaw(int Left, int Top, HDFF::cHdffCmdIf *pHdffCmdIf, uint Level)
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.
HDFF::cHdffCmdIf * mHdffCmdIf
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 eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
virtual int Height(void) const
Returns the height of this font in pixel (all characters have the same height).
void CmdOsdDeleteFontFace(uint32_t hFontFace)
static const cCursesFont Font
uint32_t mBitmapColors[256]
@ HDFF_DRAW_QUARTER_TOP_LEFT_INVERTED
bool IsTrueColor(void) const
Returns 'true' if this is a true color OSD (providing full 32 bit color depth).