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) 44 uint32_t mBitmapColors[256];
49 virtual void SetActive(
bool On);
53 virtual eOsdError CanHandleAreas(
const tArea *Areas,
int NumAreas);
55 virtual void SaveRegion(
int x1,
int y1,
int x2,
int y2);
56 virtual void RestoreRegion(
void);
57 virtual void DrawPixel(
int x,
int y,
tColor Color);
58 virtual void DrawBitmap(
int x,
int y,
const cBitmap &Bitmap,
tColor ColorFg = 0,
tColor ColorBg = 0,
bool ReplacePalette =
false,
bool Overlay =
false);
59 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);
60 virtual void DrawRectangle(
int x1,
int y1,
int x2,
int y2,
tColor Color);
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)
240 if (yc + hc > height)
243 (uint8_t *) Bitmap.
Data(0, yc),
width, hc,
251 int w = Font->
Width(s);
253 int cw = Width ?
Width : w;
254 int ch = Height ?
Height : h;
256 int size = Font->
Size();
278 if (pFontFace == NULL)
280 if (i < MAX_NUM_FONTFACES)
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)
328 if (i < MAX_NUM_FONTS)
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)
382 y += (Height - h) / 2;
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;
686 int w = pm->ViewPort().Width();
687 int h = pm->ViewPort().Height();
688 int d = w *
sizeof(
tColor);
692 for (
int y = 0; y < h; y += Chunk)
700 Left() + pm->ViewPort().X(),
Top() + pm->ViewPort().Y() + y,
701 pm->Data() + y * d, w, hc, hc * d,
706 const tColor * pixmapData = (
const tColor *) (pm->Data() + y * d);
707 uint8_t * bitmapData = buffer;
708 for (
int i = 0; i < hc * w; i++)
710 bitmapData[2] = (pixmapData[i] & 0xFF000000) >> 24;
711 bitmapData[1] = ((pixmapData[i] & 0x00F80000) >> 16)
712 | ((pixmapData[i] & 0x0000E000) >> 13);
713 bitmapData[0] = ((pixmapData[i] & 0x00001C00) >> 5)
714 | ((pixmapData[i] & 0x000000F8) >> 3);
718 Left() + pm->ViewPort().X(),
Top() + pm->ViewPort().Y() + y,
719 buffer, w, hc, hc * w * 3,
724 const tColor * pixmapData = (
const tColor *) (pm->Data() + y * d);
725 uint16_t * bitmapData = (uint16_t *) buffer;
726 for (
int i = 0; i < hc * w; i++)
728 bitmapData[i] = ((pixmapData[i] & 0xF0000000) >> 16)
729 | ((pixmapData[i] & 0x00F00000) >> 12)
730 | ((pixmapData[i] & 0x0000F000) >> 8)
731 | ((pixmapData[i] & 0x000000F0) >> 4);
734 Left() + pm->ViewPort().X(),
Top() + pm->ViewPort().Y() + y,
735 buffer, w, hc, hc * w * 2,
751 for (
int i = 0; (bitmap =
GetBitmap(i)) != NULL; i++)
753 int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
758 x2 = bitmap->
Width() - 1;
759 y2 = bitmap->
Height() - 1;
766 for (
int c = 0; c < numColors; c++)
780 int width = x2 - x1 + 1;
785 for (
int y = 0; y <
height; y += chunk)
790 for (
int r = 0; r < hc; r++)
791 memcpy(buffer + r * width, bitmap->
Data(x1, y1 + y + r),
width);
793 Left() + bitmap->
X0() + x1,
Top() + bitmap->
Y0() + y1 + y,
806 #ifdef MEASURE_OSD_TIME 807 gettimeofday(&end, &timeZone);
808 int timeNeeded = end.tv_usec - start.tv_usec;
809 timeNeeded += (end.tv_sec - start.tv_sec) * 1000000;
810 printf(
"time = %d\n", timeNeeded);
uint32_t CmdOsdCreateFont(uint32_t hFontFace, uint32_t Size)
void CmdOsdRenderDisplay(uint32_t hDisplay)
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
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)
void Clean(void)
Marks the dirty area as clean.
cHdffOsd(int Left, int Top, HDFF::cHdffCmdIf *pHdffCmdIf, uint Level)
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
virtual void SetActive(bool On)
Sets this OSD to be the active one.
uint32_t CmdOsdCreatePalette(HdffColorType_t ColorType, HdffColorFormat_t ColorFormat, uint32_t NumColors, const uint32_t *pColors)
uint32_t CmdOsdCreateDisplay(uint32_t Width, uint32_t Height, HdffColorType_t ColorType)
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...
#define HDFF_INVALID_HANDLE
void CmdOsdSetPaletteColors(uint32_t hPalette, HdffColorFormat_t ColorFormat, uint8_t StartColor, uint32_t NumColors, const uint32_t *pColors)
void CmdOsdDeletePalette(uint32_t hPalette)
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
void CmdOsdRestoreRegion(uint32_t hDisplay)
virtual void Flush(void)
Actually commits all data to the OSD hardware.
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...
virtual void Flush(void)
Actually commits all data to the OSD hardware.
void CmdOsdDrawEllipse(uint32_t hDisplay, int CX, int CY, int RadiusX, int RadiusY, uint32_t Color, uint32_t Flags)
tFont mFonts[MAX_NUM_FONTS]
void CmdOsdDrawSlope(uint32_t hDisplay, int X, int Y, int Width, int Height, uint32_t Color, uint32_t Type)
uint32_t mBitmapColors[256]
virtual int Size(void) const
Returns the original size as requested when the font was created.
void CmdOsdDeleteFont(uint32_t hFont)
uint32_t CmdOsdCreateFontFace(const uint8_t *pFontData, uint32_t DataSize)
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...
#define HDFF_SIZE_FULL_SCREEN
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 =0
Returns the height of this font in pixel (all characters have the same height).
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...
void DrawEllipse(cOsd *Osd, int x1, int y1, int x2, int y2, int Quadrants)
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 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 ...
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
#define MAX_NUM_FONTFACES
uint32_t CmdGetFirmwareVersion(char *pString, uint32_t MaxLength)
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
void CmdOsdSaveRegion(uint32_t hDisplay, int X, int Y, int Width, int Height)
const tIndex * Data(int x, int y) const
Returns the address of the index byte at the given coordinates.
struct _tFontFace tFontFace
static const cCursesFont Font
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 CmdOsdSetDisplayClippingArea(uint32_t hDisplay, bool Enable, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
void CmdOsdDeleteFontFace(uint32_t hFontFace)
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...
static int Utf8CharLen(const char *s)
uint32_t mBitmapColors[256]
void CmdOsdSetDisplayOutputRectangle(uint32_t hDisplay, uint32_t X, uint32_t Y, uint32_t Width, uint32_t Height)
void DrawSlope(cOsd *Osd, int x1, int y1, int x2, int y2, int Type)
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...
void CmdOsdDeleteDisplay(uint32_t hDisplay)
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 GetOsdSize(int &Width, int &Height, double &PixelAspect)
void CmdOsdDrawRectangle(uint32_t hDisplay, int X, int Y, int Width, int Height, uint32_t Color)
#define TEXT_ALIGN_BORDER
virtual void SetActive(bool On)
Sets this OSD to be the active one.
bool IsTrueColor(void) const
Returns 'true' if this is a true color OSD (providing full 32 bit color depth).
virtual const char * FontName(void) const
Returns the font name.
cHdffOsdRaw(int Left, int Top, HDFF::cHdffCmdIf *pHdffCmdIf, uint Level)
virtual void SetActive(bool On)
Sets this OSD to be the active one.
void CmdOsdConfigure(const HdffOsdConfig_t *pConfig)
HDFF::cHdffCmdIf * mHdffCmdIf
virtual int Width(uint c) const =0
Returns the width of the given character in pixel.
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
tFontFace mFontFaces[MAX_NUM_FONTFACES]
cHdffOsdProvider(HDFF::cHdffCmdIf *pHdffCmdIf)
cPixmap * RenderPixmaps(void)
Renders the dirty part of all pixmaps into a resulting pixmap that shall be displayed on the OSD...
cBitmap * GetBitmap(int Area)
Returns a pointer to the bitmap for the given Area, or NULL if no such bitmap exists.
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
HDFF::cHdffCmdIf * mHdffCmdIf
void CmdOsdDrawUtf8Text(uint32_t hDisplay, uint32_t hFont, int X, int Y, const char *pText, uint32_t Color)
void CmdOsdDrawTextW(uint32_t hDisplay, uint32_t hFont, int X, int Y, const uint16_t *pText, uint32_t Color)