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);
80 if (
mHdffCmdIf->CmdGetFirmwareVersion(NULL, 0) >= 0x309)
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,
251 int w =
Font->Width(s);
252 int h =
Font->Height();
256 int size =
Font->Size();
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)
320 &&
mFonts[i].Size == size)
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);
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
640 && (Areas[i].bpp != 32 || !
gHdffSetup.TrueColorOsd))
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);
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 ...
void Clean(void)
Marks the dirty area as clean.
const tIndex * Data(int x, int y) const
Returns the address of the index byte at the given coordinates.
cHdffOsdProvider(HDFF::cHdffCmdIf *pHdffCmdIf)
HDFF::cHdffCmdIf * mHdffCmdIf
virtual bool ProvidesTrueColor(void)
Returns true if this OSD provider is able to handle a true color OSD.
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.
uint32_t mBitmapColors[256]
HDFF::cHdffCmdIf * mHdffCmdIf
cHdffOsdRaw(int Left, int Top, HDFF::cHdffCmdIf *pHdffCmdIf, uint Level)
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
virtual void SetActive(bool On)
Sets this OSD to be the active one.
virtual eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
virtual void Flush(void)
Actually commits all data to the OSD hardware.
virtual void SetActive(bool On)
Sets this OSD to be the active one.
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...
uint32_t mBitmapColors[256]
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 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.
tFontFace mFontFaces[MAX_NUM_FONTFACES]
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 Flush(void)
Actually commits all data to the OSD hardware.
virtual void RestoreRegion(void)
Restores the region previously saved by a call to SaveRegion().
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.
HDFF::cHdffCmdIf * mHdffCmdIf
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
tFont mFonts[MAX_NUM_FONTS]
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 ...
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...
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,...
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.
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 eOsdError SetAreas(const tArea *Areas, int NumAreas)
Sets the sub-areas to the given areas.
cBitmap * GetBitmap(int Area)
Returns a pointer to the bitmap for the given Area, or NULL if no such bitmap exists.
virtual void DestroyPixmap(cPixmap *Pixmap)
Destroys the given Pixmap, which has previously been created by a call to CreatePixmap().
virtual eOsdError CanHandleAreas(const tArea *Areas, int NumAreas)
Checks whether the OSD can display the given set of sub-areas.
cPixmap * RenderPixmaps(void)
Renders the dirty part of all pixmaps into a resulting pixmap that shall be displayed on the OSD.
const tColor * Colors(int &NumColors) const
Returns a pointer to the complete color table and stores the number of valid entries in NumColors.
@ HDFF_COLOR_TYPE_ARGB8565
@ HDFF_COLOR_TYPE_ARGB4444
@ HDFF_COLOR_TYPE_ARGB8888
#define HDFF_INVALID_HANDLE
#define HDFF_SIZE_FULL_SCREEN
@ HDFF_DRAW_QUARTER_TOP_LEFT_INVERTED
@ HDFF_DRAW_QUARTER_BOTTOM_LEFT_INVERTED
@ HDFF_DRAW_QUARTER_BOTTOM_RIGHT
@ HDFF_DRAW_QUARTER_BOTTOM_LEFT
@ HDFF_DRAW_QUARTER_TOP_RIGHT_INVERTED
@ HDFF_DRAW_QUARTER_TOP_LEFT
@ HDFF_DRAW_QUARTER_TOP_RIGHT
@ HDFF_DRAW_QUARTER_BOTTOM_RIGHT_INVERTED
struct _tFontFace tFontFace
#define MAX_NUM_FONTFACES
#define TEXT_ALIGN_BORDER
static const cCursesFont Font