along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
+#include <stdio.h> // really?
#include <chrono>
#include <sys/syscall.h>
#include <fontconfig/fontconfig.h>
-#include <vector>
#include <math.h>
#include <bcm_host.h>
#include "osdopenvg.h"
-
#define EXTERNALPICTURE(name, fname, fileextension) extern uint8_t name ## _data[] asm("_binary_other_"#fname"_"#fileextension"_start"); \
extern uint8_t name ## _data_end[] asm("_binary_other_"#fname"_"#fileextension"_end");
#undef EXTERNALPICTURE
-
#define BACKBUFFER_WIDTH 1280
#define BACKBUFFER_HEIGHT 720
-
OsdOpenVG::OsdOpenVG()
{
vgmutex.lock();
taskmutex.lock();
lastrendertime = getTimeMS();
- display_height = 0;
- display_width = 0;
- mode = 0;
- aspect_correction = 1.;
-
- bcm_backres = 0;
- freetype_inited = false;
- wait_id = 1;
const char* fontname = "Droid Sans:style=Regular";
- cur_fontname = (char*)malloc(strlen(fontname) + 1);
+ cur_fontname = static_cast<char*>(malloc(strlen(fontname) + 1));
strcpy(cur_fontname, fontname);
#define EXTERNALPICTURE(name, fname, fileextension) static_artwork_begin[sa_ ## name]=name ## _data;
OsdOpenVG::~OsdOpenVG()
{
-
- if (initted)
- {
- shutdown();
- }
+ if (initted) shutdown();
if (cur_fontname) free(cur_fontname);
while (itty != fontnames.end())
{
- free((void*)*itty);
-
+ free(*itty);
itty++;
}
}
// end
-
if (fontnames_keys.size())
{
std::vector<char*>::iterator itty = fontnames_keys.begin();
while (itty != fontnames_keys.end())
{
- free((void*)*itty);
+ free(*itty);
itty++;
}
}
taskmutex.unlock();
}
-
-
int OsdOpenVG::init()
{
if (initted) return 0;
reader.init();
- //init broadcom chipset (Move to video?)
-
-
//First get connection to egl
egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-
if (egl_display == EGL_NO_DISPLAY)
{
Log::getInstance()->log("OSD", Log::WARN, "Could not get egl display! %x", eglGetError());
return 0;
}
-
-
if (eglInitialize(egl_display, NULL, NULL) == EGL_FALSE)
{
Log::getInstance()->log("OSD", Log::WARN, "Initialising display failed! %x", eglGetError());
return 0;
}
-
const char* query_str = eglQueryString(egl_display, EGL_CLIENT_APIS);
if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str);
query_str = eglQueryString(egl_display, EGL_EXTENSIONS);
- if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str);
+ if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str);
else Log::getInstance()->log("OSD", Log::WARN, "Could not query display %x", eglGetError());
if (eglBindAPI(EGL_OPENVG_API) == EGL_FALSE)
EGL_NONE
}; // Here, we might have to select the resolution!
-
EGLint number;
if (eglChooseConfig(egl_display, attributs, &egl_ourconfig, 1, &number) == EGL_FALSE)
return 0;
}
-
-
egl_context = eglCreateContext(egl_display, egl_ourconfig, NULL, NULL);
if (egl_context == EGL_NO_CONTEXT)
uint32_t back_image_ptr;
bcm_backres = vc_dispmanx_resource_create(VC_IMAGE_RGBX32, 16, 16, &back_image_ptr);
-
updateBackgroundColor(DrawStyle::WALLPAPER);
-
-
DISPMANX_UPDATE_HANDLE_T bcm_update;
bcm_display = vc_dispmanx_display_open(0);
bcm_update = vc_dispmanx_update_start(0);
vc_dispmanx_update_submit_sync(bcm_update);
-
-
static EGL_DISPMANX_WINDOW_T nativewindow;
nativewindow.element = bcm_element;
nativewindow.height = BACKBUFFER_HEIGHT;
nativewindow.width = BACKBUFFER_WIDTH;
- egl_surface = eglCreateWindowSurface(egl_display, egl_ourconfig, &nativewindow, NULL );
-
+ egl_surface = eglCreateWindowSurface(egl_display, egl_ourconfig, &nativewindow, NULL);
if (egl_surface == EGL_NO_SURFACE)
{
Log::getInstance()->log("OSD", Log::WARN, "Creating egl window surface failed!");
// Test stuff
- query_str = (const char*)vgGetString(VG_VERSION) ;
+ query_str = reinterpret_cast<const char*>(vgGetString(VG_VERSION));
if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str);
else Log::getInstance()->log("OSD", Log::WARN, "Could not query display %x", vgGetError());
- query_str = (const char*)vgGetString(VG_VENDOR) ;
+ query_str = reinterpret_cast<const char*>(vgGetString(VG_VENDOR));
if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str);
else Log::getInstance()->log("OSD", Log::WARN, "Could not query display %x", vgGetError());
- query_str = (const char*)vgGetString(VG_RENDERER) ;
+ query_str = reinterpret_cast<const char*>(vgGetString(VG_RENDERER));
if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str);
else Log::getInstance()->log("OSD", Log::WARN, "Could not query display %x", vgGetError());
- query_str = (const char*)vgGetString(VG_EXTENSIONS) ;
+ query_str = reinterpret_cast<const char*>(vgGetString(VG_EXTENSIONS));
if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str);
else Log::getInstance()->log("OSD", Log::WARN, "Could not query display %x", vgGetError());
vgSetParameteri( vgttpaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
vgSetColor(vgttpaint, 0xffffffff);
- eglSwapInterval(egl_display, 1 );
+ eglSwapInterval(egl_display, 1);
Log::getInstance()->log("OSD", Log::DEBUG, "Making egl current out 1%d", syscall(SYS_gettid));
eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
//Now we will create the Screen
initted = true; // must set this here or create surface won't work
-
/*if (((VideoOMX*)Video::getInstance())->initUsingOSDObjects()!=1) { //call Video for init stuff
return 0;
}*/
-
threadStart();
taskmutex.unlock();
vgmutex.unlock();
reader.addDecoder(imageomx);
#endif
-
return 1;
}
if (!osd)
{
vc_dispmanx_snapshot(display, res,
- (DISPMANX_TRANSFORM_T)(DISPMANX_SNAPSHOT_NO_RGB | DISPMANX_SNAPSHOT_FILL/*|DISPMANX_SNAPSHOT_PACK*/));
+ static_cast<DISPMANX_TRANSFORM_T>(DISPMANX_SNAPSHOT_NO_RGB | DISPMANX_SNAPSHOT_FILL/*|DISPMANX_SNAPSHOT_PACK*/));
}
else
{
vc_dispmanx_snapshot(display, res,
- (DISPMANX_TRANSFORM_T)(DISPMANX_SNAPSHOT_FILL));
+ static_cast<DISPMANX_TRANSFORM_T>(DISPMANX_SNAPSHOT_FILL));
}
vc_dispmanx_rect_set(&rect, 0, 0, width, height);
vc_dispmanx_resource_delete(res);
vc_dispmanx_display_close(display);
return true;
-
}
-
void OsdOpenVG::initPaths()
{
-
-
VGPath current;
current = vgCreatePath(VG_PATH_FORMAT_STANDARD,
VG_PATH_DATATYPE_F, 1.f, 0.f,
vguEllipse(current, 0.f, 0.f, 1.f, 1.f);
// Point
std_paths[PIPoint] = current;
-
}
void OsdOpenVG::destroyPaths()
vgDestroyPath(std_paths[PIVertLine]);
vgDestroyPath(std_paths[PIRectangle]);
vgDestroyPath(std_paths[PIPoint]);
-
}
int OsdOpenVG::stopUpdate()
processTasks();
return 1;
}
+
/*
void OsdOpenVG::purgeAllReferences()
{
int OsdOpenVG::shutdown()
{
reader.shutdown();
-#ifdef PICTURE_DECODER_OMX
+#ifdef PICTURE_DECODER_OMX
if (imageomx) reader.removeDecoder(imageomx);
-
imageomx = NULL;
#endif
taskmutex.lock();
vgmutex.lock();
-
-
//purgeAllReferences();
vgDestroyFont(vgfont);
vc_dispmanx_resource_delete(bcm_backres);
bcm_backres = 0;
vc_dispmanx_display_close(bcm_display);
-
-
-
return 1;
}
-
-
-
void OsdOpenVG::threadMethod()
{
// We have to claim the egl context for this thread
}
}
- eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
+ eglMakeCurrent(egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
void OsdOpenVG::InternalRendering()
vgClear(0, 0, BACKBUFFER_WIDTH, BACKBUFFER_HEIGHT);
vgSeti(VG_BLEND_MODE, VG_BLEND_SRC);
-
drawSurfaces(); //iterate through and draws all commands
//Show it to the user!
eglSwapBuffers(egl_display, egl_surface);
vgmutex.unlock();
-
}
/*font stuff*/
{
return font_height; //dummy
}
+
float OsdOpenVG::getCharWidth(wchar_t c)
{
if (c < 256) return byte_char_width[c];
const VGfloat escapement[] = { 12.f, 0.f };
unsigned int* charmap = GetFontChar(c, buffer);
- if (!charmap) //invalid char
- {
- return 0;
- }
+ if (!charmap) return 0; //invalid char
for (int i = 0; i < 10; i++)
{
vgSetGlyphToImage(
vgttfont,
glyph_index,
- handle, (VGfloat*)glyphOrigin, (VGfloat*)escapement);
+ handle, const_cast<VGfloat*>(glyphOrigin), const_cast<VGfloat*>(escapement));
vgDestroyImage(handle);
tt_font_chars[glyph_index] = 1;
return glyph_index;
}
-int OsdOpenVG::getFontNames(const char*** names, const char*** names_keys)
+int OsdOpenVG::getFontNames(const char*** names, const char*** names_keys)
{
- *names = (const char**) & (fontnames[0]);
- *names_keys = (const char**) & (fontnames_keys[0]);
+ *names = const_cast<const char**>(&(fontnames[0]));
+ *names_keys = const_cast<const char**>(&(fontnames_keys[0]));
return fontnames.size();
}
void OsdOpenVG::setFont(const char* fontname)
{
-
if (strcmp(fontname, cur_fontname))
{
// new font!
struct OpenVGCommand comm;
comm.task = OVGreplacefont;
putOpenVGCommand(comm, false);
-
-
}
}
-
-int OsdOpenVG::loadFont(bool newfont)
+int OsdOpenVG::loadFont(bool newfont)
{
int error;
float font_size = 16.f;
{
//first get the filename algorith extracted from vdr by Klaus Schmidinger
FcInit();
- FcPattern* pattern = FcNameParse((FcChar8*)cur_fontname);
+ FcPattern* pattern = FcNameParse(reinterpret_cast<FcChar8*>(cur_fontname));
FcPatternAddBool(pattern, FC_SCALABLE, FcTrue);
FcConfigSubstitute(NULL, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
Log::getInstance()->log("OSD", Log::NOTICE, "Load Font %s: %s", cur_fontname, filename);
// second load the font
- FT_Face new_ft_face;
- error = FT_New_Face(ft_library, (const char*)filename, 0, &new_ft_face );
+ FT_Face new_ft_face;
+ error = FT_New_Face(ft_library, reinterpret_cast<const char*>(filename), 0, &new_ft_face);
if (error)
{
coord.push_back(y);
}
}
-
-
}
last_tag = tag;
}
//segments.push_back(VG_CLOSE_PATH);
-
-
}
vgAppendPathData(path, segments.size(), &segments[0], &coord[0]);
return 1;
}
-
void OsdOpenVG::drawSetTrans(SurfaceInfo& sc)
{
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
clip_shift_x = sc.x;
clip_shift_y = sc.y;
-
-
//vgTranslate(0.f+sc.x,576.f-sc.y);
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw Translate %g %g",sc.x,sc.y);
-
}
+
void OsdOpenVG::executeDrawCommand(SVGCommand& command)
{
-
- VGfloat save_matrix[9];
- VGfloat save_matrix2[9];
+ VGfloat save_matrix[9];
+ VGfloat save_matrix2[9];
switch (command.instr)
{
//vgSeti(VG_FILL_RULE,);
vgGetMatrix(save_matrix);
- vgSetPaint((VGPaint) command.handle, VG_FILL_PATH);
- vgSetPaint((VGPaint) command.handle, VG_STROKE_PATH);
+ vgSetPaint(static_cast<VGPaint>(command.handle), VG_FILL_PATH);
+ vgSetPaint(static_cast<VGPaint>(command.handle), VG_STROKE_PATH);
vgTranslate(command.x, command.y);
vgScale(command.w, command.h);
vgDrawPath(std_paths[command.target.path_index], VG_FILL_PATH);
vgLoadMatrix(save_matrix);
- } break;
-
+ break;
+ }
case DrawImage:
{
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
VGfloat imagewidth = vgGetParameteri((VGImage) command.target.image, VG_IMAGE_WIDTH);
VGfloat imageheight = vgGetParameteri((VGImage) command.target.image, VG_IMAGE_HEIGHT);
-
//vgScale(command.w,command.h);
if (command.handle) //special behaviout for bw images they act as a mask on the current paint
{
vgTranslate(command.x, command.y);
- vgSetPaint((VGPaint) command.handle, VG_FILL_PATH);
- vgSetPaint((VGPaint) command.handle, VG_STROKE_PATH);
+ vgSetPaint(static_cast<VGPaint>(command.handle), VG_FILL_PATH);
+ vgSetPaint(static_cast<VGPaint>(command.handle), VG_STROKE_PATH);
vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);
vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
vgScale(aspect_correction, 1.f);
}
else
{
-
//vgScale(720.f/((float)BACKBUFFER_WIDTH), 576.f/((float)BACKBUFFER_HEIGHT));
float scalex = command.w / imagewidth;
float scaley = command.h / imageheight;
scalex = 0.f;
tx += (command.w - imagewidth * scaley * aspect_correction) * 0.5f;
}
-
}
-
}
if (scalex == 0.f && scaley == 0.f)
scaley = scalex / aspect_correction;
}
-
if (command.corner == BottomRight || command.corner == BottomLeft || command.corner == BottomMiddle)
{
ty -= imageheight * scaley;
//Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia Draw Image Scale %g %g %g %g %g %g",command.w,imagewidth,command.h,imageheight,scalex,scaley);
}
-
//vgLoadIdentity();
//vgTranslate(200.f,500.f);
//vgScale(100.f,100.f);
- vgDrawImage((VGImage) command.target.image);
+ vgDrawImage(static_cast<VGImage>(command.target.image));
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw Image %d %x %g %g %g %g %x",command.handle,command.target.image,command.x,command.y,command.w,command.h,
// vgGetError());
vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE);
vgLoadMatrix(save_matrix);
- } break;
-
+ break;
+ }
case DrawGlyph:
{
vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE);
vgGetMatrix(save_matrix);
- vgSetPaint((VGPaint) command.handle, VG_FILL_PATH);
- vgSetPaint((VGPaint) command.handle, VG_STROKE_PATH);
+ vgSetPaint(static_cast<VGPaint>(command.handle), VG_FILL_PATH);
+ vgSetPaint(static_cast<VGPaint>(command.handle), VG_STROKE_PATH);
vgTranslate(command.x, command.y);
vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER);
vgGetMatrix(save_matrix2);
unsigned int glyph_index = FT_Get_Char_Index(ft_face, command.target.textchar);
vgScale(font_exp_x[glyph_index], font_height);
-
VGfloat gori[] = {0., 0.};
vgSetfv(VG_GLYPH_ORIGIN, 2, gori);
-
vgDrawGlyph(vgfont, glyph_index, VG_FILL_PATH, VG_FALSE);
//vgDrawPath(std_paths[Rectangle],VG_FILL_PATH);
/* Log::getInstance()->log("OSD", Log::DEBUG, "Draw Glyph %d %c %d %g %g %x",command.handle,command.target.textchar,glyph_index,command.x,command.y,
vgLoadMatrix(save_matrix2);
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
- } break;
-
+ break;
+ }
case DrawTTchar:
{
cTeletextChar tchar;
vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_STENCIL);
vgSeti(VG_BLEND_MODE, VG_BLEND_SRC_OVER);
-
vgTranslate(command.x + command.w * 11.85f * 1.4f, command.y + command.h * 19.75f);
VGfloat gori[] = {0., 0.};
vgSetfv(VG_GLYPH_ORIGIN, 2, gori);
unsigned int color = Surface::enumTeletextColorToCoulour(ttbackgcolour).rgba();
color = color << 8 | (color & 0xff000000) >> 24;
vgSetColor(vgttpaint, color);
- vgSetPaint((VGPaint) vgttpaint, VG_FILL_PATH);
- vgSetPaint((VGPaint) vgttpaint, VG_STROKE_PATH);
+ vgSetPaint(static_cast<VGPaint>(vgttpaint), VG_FILL_PATH);
+ vgSetPaint(static_cast<VGPaint>(vgttpaint), VG_STROKE_PATH);
cTeletextChar filled;
filled.setInternal(0x187f);
unsigned int glyph_index = loadTTchar(filled);
color = Surface::enumTeletextColorToCoulour(ttforegcolour).rgba();
color = color << 8 | (color & 0xff000000) >> 24;
vgSetColor(vgttpaint, color);
- vgSetPaint((VGPaint) vgttpaint, VG_FILL_PATH);
- vgSetPaint((VGPaint) vgttpaint, VG_STROKE_PATH);
+ vgSetPaint(static_cast<VGPaint>(vgttpaint), VG_FILL_PATH);
+ vgSetPaint(static_cast<VGPaint>(vgttpaint), VG_STROKE_PATH);
glyph_index = loadTTchar(tchar);
vgDrawGlyph(vgttfont, glyph_index, VG_FILL_PATH, VG_FALSE);
/* Log::getInstance()->log("OSD", Log::DEBUG, "Draw TTchar %x %x %x %x",glyph_index,ttforegcolour,Surface::enumTeletextColorToCoulour(ttforegcolour).rgba(),
vgGetColor(vgttpaint));*/
-
vgLoadMatrix(save_matrix);
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
vgSeti(VG_IMAGE_MODE, VG_DRAW_IMAGE_NORMAL);
vgSeti(VG_BLEND_MODE, VG_BLEND_SRC);
-
- } break;
-
+ break;
+ }
case DrawClipping:
{
VGint coords[4] = {0, 0, 0, 0};
if (command.w == 0.f && command.h == 0.f)
vgSeti(VG_SCISSORING, VG_FALSE);
- else vgSeti(VG_SCISSORING, VG_TRUE);
- } break;
+ else
+ vgSeti(VG_SCISSORING, VG_TRUE);
+ break;
+ }
case DrawImageLoading:
case DrawNoop:
{}
}
}
+
//int imcount=0;// this is debug code and should not go into release
unsigned int OsdOpenVG::handleTask(OpenVGCommand& command)
{
vgDestroyFont(vgfont);
loadFont(true);
return 0;
- } break;
-
+ }
case OVGdestroyImageRef: //imcount--;
{
//Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia Draw Image Destroy %x %d",command.param1,imcount);
- vgDestroyImage((VGImage)command.param1);
+ vgDestroyImage(static_cast<VGImage>(command.param1));
return 0;
- } break;
-
+ }
case OVGdestroyPaint:
{
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw Paint Destroy %d ",command.param1);
- vgDestroyPaint((VGPaint)command.param1);
+ vgDestroyPaint(static_cast<VGPaint>(command.param1));
return 0;
- } break;
-
+ }
case OVGcreateImagePalette: //imcount++;
{
VGImage input = vgCreateImage(VG_A_8, command.param1, command.param2,
VGImage handle = vgCreateImage(VG_sRGBA_8888, command.param1, command.param2,
VG_IMAGE_QUALITY_NONANTIALIASED |
VG_IMAGE_QUALITY_FASTER | VG_IMAGE_QUALITY_BETTER);
- VGuint* palette = (VGuint*)malloc(256 * sizeof(VGuint));
- VGuint* in_palette = (VGuint*)command.data2;
+ VGuint* palette = static_cast<VGuint*>(malloc(256 * sizeof(VGuint)));
+ const VGuint* in_palette = static_cast<const VGuint*>(command.data2);
for (int i = 0; i < 256; i++)
{
vgDestroyImage(input);
return handle;
- } break;
-
+ }
case OVGcreateMonoBitmap: //imcount++;
{
VGImage handle = vgCreateImage(VG_A_1, command.param1, command.param2,
VG_IMAGE_QUALITY_FASTER);
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw create mono %d %d %x %d",command.param1,command.param2,vgGetError(),handle);
unsigned int buffer_len = (command.param1 * command.param2) >> 3;
- unsigned char* buffer = (unsigned char*)malloc(buffer_len);
+ unsigned char* buffer = static_cast<unsigned char*>(malloc(buffer_len));
unsigned char* r_buffer1 = buffer;
const unsigned char* r_buffer2 = static_cast<const unsigned char*>(command.data);
unsigned char* buffer_end = buffer + buffer_len;
r_buffer1++; r_buffer2++;
}
-
- vgImageSubData(handle, buffer, command.param1 >> 3,
- VG_A_1, 0, 0, command.param1, command.param2);
+ vgImageSubData(handle, buffer, command.param1 >> 3, VG_A_1, 0, 0, command.param1, command.param2);
free(buffer);
// Log::getInstance()->log("OSD", Log::DEBUG, "Draw create mono2 %d %d %x %d",command.param1,command.param2,vgGetError(),handle);
return handle;
- } break;
-
+ }
/*case OVGcreateImageFile: {
VGImage handle;
try{
Blob imageblob;
imagefile->write(&imageblob,"RGBA");
-
handle=vgCreateImage(VG_sXBGR_8888,imagefile->columns(),imagefile->rows(),
VG_IMAGE_QUALITY_BETTER);
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw create image details %d %d %x mark1",imagefile->columns(),imagefile->rows(),(unsigned int*)imageblob.data());
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw create file %d %d %x %d",command.param1,command.param2,vgGetError(),handle);
return handle;
- } break;*/
+ } */
case OVGcreateImageMemory: //imcount++;
{
- PictureInfo* info = (PictureInfo*) command.data;
+ const PictureInfo* info = static_cast<const PictureInfo*>(command.data);
VGImage handle;
//Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia OVGcreateImageMemory %d",imcount);
handle = vgCreateImage(VG_sABGR_8888, info->width, info->height, VG_IMAGE_QUALITY_BETTER);
MessageQueue::getInstance()->postMessage(m); // inform command about new picture
delete info;
-
- } break;
-
+ break;
+ }
case OVGcreateEGLImage: //imcount++;
{
- PictureInfo* info = (PictureInfo*) command.data;
+ PictureInfo* info = const_cast<PictureInfo*>(static_cast<const PictureInfo*>(command.data));
VGImage handle;
handle = vgCreateImage(VG_sABGR_8888, info->width, info->height, VG_IMAGE_QUALITY_BETTER);
// Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia OVGcreateEGLImage %d %d %x %d",info->width,info->height, handle,imcount);
info->handle = handle;
- info->reference = eglCreateImageKHR(egl_display, egl_context, EGL_VG_PARENT_IMAGE_KHR, (EGLClientBuffer)handle, NULL);
+ info->reference = eglCreateImageKHR(egl_display, egl_context, EGL_VG_PARENT_IMAGE_KHR, reinterpret_cast<EGLClientBuffer>(handle), NULL);
if (info->reference) return true;
else
{
Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia OVGcreateEGLImage %d %d %x Fail!", info->width, info->height, handle);
-
if (handle) vgDestroyImage(handle);
-
return false;
}
-
- } break;
-
+ break;
+ }
case OVGreadyEGLImage:
{
- PictureInfo* info = (PictureInfo*) command.data;
+ PictureInfo* info = const_cast<PictureInfo*>(static_cast<const PictureInfo*>(command.data));
eglDestroyImageKHR(egl_display, info->reference);
bool static_image = true;
MessageQueue::getInstance()->postMessage(m); // inform command about new picture
delete info;
- } break;
-
-
-
- case OVGcreateColorRef :
+ break;
+ }
+ case OVGcreateColorRef:
{
VGPaint handle;
handle = vgCreatePaint();
- DrawStyle* style = (DrawStyle*)command.data;
+ const DrawStyle* style = static_cast<const DrawStyle*>(command.data);
switch (style->ft)
{
//VGuint rgba;
//rgba = vgGetColor((VGPaint)handle);
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw Paint %d %x %x",handle,command.param1,rgba);
- } break;
-
+ break;
+ }
case DrawStyle::GradientLinear:
{
vgSetParameteri(handle, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
VGfloat params[] = {style->x1, style->y1, style->x2, style->y2, style->r};
//Log::getInstance()->log("OSD", Log::DEBUG, "Draw Gradient %d %g %g %g %g",handle,params[0],params[1],params[2],params[3]);
vgSetParameterfv(handle, VG_PAINT_LINEAR_GRADIENT, 4, params);
-
-
-
- } break;
-
+ break;
+ }
case DrawStyle::GradientRadial:
{
vgSetParameteri(handle, VG_PAINT_TYPE, VG_PAINT_TYPE_RADIAL_GRADIENT);
VGfloat params[] = {style->x1, style->y1, style->x2, style->y2, style->r};
vgSetParameterfv(handle, VG_PAINT_RADIAL_GRADIENT, 5, params);
-
-
-
- } break;
- };
+ break;
+ }
+ }
if (style->ft == DrawStyle::GradientLinear || style->ft == DrawStyle::GradientRadial)
{
VGfloat colorramp[5 * 5];
colorramp[0 + 0 * 5] = 0.f;
- colorramp[1 + 0 * 5] = ((float)style->red) / 255.f;
- colorramp[2 + 0 * 5] = ((float)style->green) / 255.f;
- colorramp[3 + 0 * 5] = ((float)style->blue) / 255.f;
- colorramp[4 + 0 * 5] = ((float)style->alpha) / 255.f;
+ colorramp[1 + 0 * 5] = style->red / 255.f;
+ colorramp[2 + 0 * 5] = style->green / 255.f;
+ colorramp[3 + 0 * 5] = style->blue / 255.f;
+ colorramp[4 + 0 * 5] = style->alpha / 255.f;
for (int i = 0; i < (style->num_colors - 1); i++)
{
colorramp[0 + (i + 1) * 5] = style->grad_pos[i];
- colorramp[1 + (i + 1) * 5] = ((float)style->grad_col[i].red) / 255.f;
- colorramp[2 + (i + 1) * 5] = ((float)style->grad_col[i].green) / 255.f;
- colorramp[3 + (i + 1) * 5] = ((float)style->grad_col[i].blue) / 255.f;
- colorramp[4 + (i + 1) * 5] = ((float)style->grad_col[i].alpha) / 255.f;
+ colorramp[1 + (i + 1) * 5] = style->grad_col[i].red / 255.f;
+ colorramp[2 + (i + 1) * 5] = style->grad_col[i].green / 255.f;
+ colorramp[3 + (i + 1) * 5] = style->grad_col[i].blue / 255.f;
+ colorramp[4 + (i + 1) * 5] = style->grad_col[i].alpha / 255.f;
}
colorramp[0 + (style->num_colors) * 5] = 1.f;
- colorramp[1 + (style->num_colors) * 5] = ((float)style->grad_col[style->num_colors - 1].red) / 255.f;
- colorramp[2 + (style->num_colors) * 5] = ((float)style->grad_col[style->num_colors - 1].green) / 255.f;
- colorramp[3 + (style->num_colors) * 5] = ((float)style->grad_col[style->num_colors - 1].blue) / 255.f;
- colorramp[4 + (style->num_colors) * 5] = ((float)style->grad_col[style->num_colors - 1].alpha) / 255.f;
+ colorramp[1 + (style->num_colors) * 5] = style->grad_col[style->num_colors - 1].red / 255.f;
+ colorramp[2 + (style->num_colors) * 5] = style->grad_col[style->num_colors - 1].green / 255.f;
+ colorramp[3 + (style->num_colors) * 5] = style->grad_col[style->num_colors - 1].blue / 255.f;
+ colorramp[4 + (style->num_colors) * 5] = style->grad_col[style->num_colors - 1].alpha / 255.f;
vgSetParameteri(handle, VG_PAINT_COLOR_RAMP_SPREAD_MODE, VG_COLOR_RAMP_SPREAD_REFLECT);
vgSetParameteri(handle, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, VG_FALSE);
vgSetParameterfv(handle, VG_PAINT_COLOR_RAMP_STOPS, 5 + (style->num_colors) * 5, colorramp);
}
return handle;
- } break;
-
-
+ break;
+ }
case OVGimageUploadLine:
{}
-
}
return 0;
return false;
}
-
unsigned int OsdOpenVG::putOpenVGCommand(OpenVGCommand& comm, bool wait)
{
taskmutex.lock();
}
vgtaskSignal.waitForSignalTimed(&target_time);
*/
-
-
}
else
{
return 0;
}
-
-
void OsdOpenVG::destroyImageRef(ImageIndex index)
{
struct OpenVGCommand comm;
putOpenVGCommand(comm, false);
}
-
bool OsdOpenVG::getStaticImageData(unsigned int static_id, UCHAR** userdata, ULONG* length)
{
if (sa_MAX > static_id)
*userdata = NULL;
*length = 0;
return false;
-
}
-void OsdOpenVG::createPicture(struct PictureInfo& pict_inf)
+void OsdOpenVG::createPicture(struct PictureInfo& pict_inf)
{
struct OpenVGCommand comm;
Log::getInstance()->log("OsdOpenVG", Log::DEBUG, "TVMedia Create Picture %d", pict_inf.type);
{
// unsupported
pict_inf.decoder->freeReference(pict_inf.reference);
-
-
}
}
return putOpenVGCommand(comm, true);
}
-
-
ImageIndex OsdOpenVG::createMonoBitmap(void* base, int width, int height)
{
struct OpenVGCommand comm;
comm.data = &c;
return putOpenVGCommand(comm, true);
}
-
-
-
-