From 3f876cb0bf9d2283b7ffcfbfe68a91dfca1e7a5f Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sat, 16 May 2020 00:58:38 +0100 Subject: [PATCH] 36 CWFs --- osdopenvg.cc | 312 +++++++++++++++++---------------------------------- osdopenvg.h | 36 ++---- 2 files changed, 111 insertions(+), 237 deletions(-) diff --git a/osdopenvg.cc b/osdopenvg.cc index 4fdb27f..372e898 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -17,10 +17,10 @@ along with VOMP. If not, see . */ +#include // really? #include #include #include -#include #include #include @@ -32,7 +32,6 @@ #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"); @@ -40,27 +39,17 @@ EXTERNAL_PICTS #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(malloc(strlen(fontname) + 1)); strcpy(cur_fontname, fontname); #define EXTERNALPICTURE(name, fname, fileextension) static_artwork_begin[sa_ ## name]=name ## _data; @@ -77,11 +66,7 @@ OsdOpenVG::OsdOpenVG() OsdOpenVG::~OsdOpenVG() { - - if (initted) - { - shutdown(); - } + if (initted) shutdown(); if (cur_fontname) free(cur_fontname); @@ -96,8 +81,7 @@ OsdOpenVG::~OsdOpenVG() while (itty != fontnames.end()) { - free((void*)*itty); - + free(*itty); itty++; } } @@ -105,14 +89,13 @@ OsdOpenVG::~OsdOpenVG() // end - if (fontnames_keys.size()) { std::vector::iterator itty = fontnames_keys.begin(); while (itty != fontnames_keys.end()) { - free((void*)*itty); + free(*itty); itty++; } } @@ -121,20 +104,14 @@ OsdOpenVG::~OsdOpenVG() 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()); @@ -142,8 +119,6 @@ int OsdOpenVG::init() return 0; } - - if (eglInitialize(egl_display, NULL, NULL) == EGL_FALSE) { Log::getInstance()->log("OSD", Log::WARN, "Initialising display failed! %x", eglGetError()); @@ -151,7 +126,6 @@ int OsdOpenVG::init() return 0; } - const char* query_str = eglQueryString(egl_display, EGL_CLIENT_APIS); if (query_str) Log::getInstance()->logLongString("OSD", Log::NOTICE, query_str); @@ -159,7 +133,7 @@ int OsdOpenVG::init() 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) @@ -177,7 +151,6 @@ int OsdOpenVG::init() EGL_NONE }; // Here, we might have to select the resolution! - EGLint number; if (eglChooseConfig(egl_display, attributs, &egl_ourconfig, 1, &number) == EGL_FALSE) @@ -187,8 +160,6 @@ int OsdOpenVG::init() return 0; } - - egl_context = eglCreateContext(egl_display, egl_ourconfig, NULL, NULL); if (egl_context == EGL_NO_CONTEXT) @@ -217,11 +188,8 @@ int OsdOpenVG::init() 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); @@ -236,15 +204,12 @@ int OsdOpenVG::init() 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!"); @@ -263,22 +228,22 @@ int OsdOpenVG::init() // Test stuff - query_str = (const char*)vgGetString(VG_VERSION) ; + query_str = reinterpret_cast(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(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(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(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()); @@ -347,19 +312,17 @@ int OsdOpenVG::init() 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(); @@ -369,7 +332,6 @@ int OsdOpenVG::init() reader.addDecoder(imageomx); #endif - return 1; } @@ -433,12 +395,12 @@ bool OsdOpenVG::screenShot(void* buffer, int width, int height, bool osd /*inclu if (!osd) { vc_dispmanx_snapshot(display, res, - (DISPMANX_TRANSFORM_T)(DISPMANX_SNAPSHOT_NO_RGB | DISPMANX_SNAPSHOT_FILL/*|DISPMANX_SNAPSHOT_PACK*/)); + static_cast(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_SNAPSHOT_FILL)); } vc_dispmanx_rect_set(&rect, 0, 0, width, height); @@ -446,14 +408,10 @@ bool OsdOpenVG::screenShot(void* buffer, int width, int height, bool osd /*inclu 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, @@ -484,7 +442,6 @@ void OsdOpenVG::initPaths() vguEllipse(current, 0.f, 0.f, 1.f, 1.f); // Point std_paths[PIPoint] = current; - } void OsdOpenVG::destroyPaths() @@ -493,7 +450,6 @@ void OsdOpenVG::destroyPaths() vgDestroyPath(std_paths[PIVertLine]); vgDestroyPath(std_paths[PIRectangle]); vgDestroyPath(std_paths[PIPoint]); - } int OsdOpenVG::stopUpdate() @@ -502,6 +458,7 @@ int OsdOpenVG::stopUpdate() processTasks(); return 1; } + /* void OsdOpenVG::purgeAllReferences() { @@ -542,10 +499,9 @@ void OsdOpenVG::purgeAllReferences() int OsdOpenVG::shutdown() { reader.shutdown(); -#ifdef PICTURE_DECODER_OMX +#ifdef PICTURE_DECODER_OMX if (imageomx) reader.removeDecoder(imageomx); - imageomx = NULL; #endif @@ -574,8 +530,6 @@ int OsdOpenVG::shutdown() taskmutex.lock(); vgmutex.lock(); - - //purgeAllReferences(); vgDestroyFont(vgfont); @@ -613,15 +567,9 @@ int OsdOpenVG::shutdown() 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 @@ -696,7 +644,7 @@ void OsdOpenVG::threadMethod() } } - 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() @@ -711,13 +659,11 @@ 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*/ @@ -726,6 +672,7 @@ float OsdOpenVG::getFontHeight() { return font_height; //dummy } + float OsdOpenVG::getCharWidth(wchar_t c) { if (c < 256) return byte_char_width[c]; @@ -748,10 +695,7 @@ unsigned int OsdOpenVG::loadTTchar(cTeletextChar 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++) { @@ -768,23 +712,22 @@ unsigned int OsdOpenVG::loadTTchar(cTeletextChar c) vgSetGlyphToImage( vgttfont, glyph_index, - handle, (VGfloat*)glyphOrigin, (VGfloat*)escapement); + handle, const_cast(glyphOrigin), const_cast(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(&(fontnames[0])); + *names_keys = const_cast(&(fontnames_keys[0])); return fontnames.size(); } void OsdOpenVG::setFont(const char* fontname) { - if (strcmp(fontname, cur_fontname)) { // new font! @@ -796,13 +739,10 @@ void OsdOpenVG::setFont(const char* fontname) 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; @@ -822,7 +762,7 @@ int OsdOpenVG::loadFont(bool newfont) { //first get the filename algorith extracted from vdr by Klaus Schmidinger FcInit(); - FcPattern* pattern = FcNameParse((FcChar8*)cur_fontname); + FcPattern* pattern = FcNameParse(reinterpret_cast(cur_fontname)); FcPatternAddBool(pattern, FC_SCALABLE, FcTrue); FcConfigSubstitute(NULL, pattern, FcMatchPattern); FcDefaultSubstitute(pattern); @@ -856,8 +796,8 @@ int OsdOpenVG::loadFont(bool newfont) 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(filename), 0, &new_ft_face); if (error) { @@ -975,8 +915,6 @@ int OsdOpenVG::loadFont(bool newfont) coord.push_back(y); } } - - } last_tag = tag; @@ -1001,8 +939,6 @@ int OsdOpenVG::loadFont(bool newfont) } //segments.push_back(VG_CLOSE_PATH); - - } vgAppendPathData(path, segments.size(), &segments[0], &coord[0]); @@ -1051,7 +987,6 @@ int OsdOpenVG::loadFont(bool newfont) return 1; } - void OsdOpenVG::drawSetTrans(SurfaceInfo& sc) { vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); @@ -1071,17 +1006,14 @@ void OsdOpenVG::drawSetTrans(SurfaceInfo& sc) 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) { @@ -1094,14 +1026,14 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) //vgSeti(VG_FILL_RULE,); vgGetMatrix(save_matrix); - vgSetPaint((VGPaint) command.handle, VG_FILL_PATH); - vgSetPaint((VGPaint) command.handle, VG_STROKE_PATH); + vgSetPaint(static_cast(command.handle), VG_FILL_PATH); + vgSetPaint(static_cast(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); @@ -1109,14 +1041,13 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) 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(command.handle), VG_FILL_PATH); + vgSetPaint(static_cast(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); @@ -1126,7 +1057,6 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) } else { - //vgScale(720.f/((float)BACKBUFFER_WIDTH), 576.f/((float)BACKBUFFER_HEIGHT)); float scalex = command.w / imagewidth; float scaley = command.h / imageheight; @@ -1150,9 +1080,7 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) scalex = 0.f; tx += (command.w - imagewidth * scaley * aspect_correction) * 0.5f; } - } - } if (scalex == 0.f && scaley == 0.f) @@ -1169,7 +1097,6 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) scaley = scalex / aspect_correction; } - if (command.corner == BottomRight || command.corner == BottomLeft || command.corner == BottomMiddle) { ty -= imageheight * scaley; @@ -1193,12 +1120,11 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) //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(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()); @@ -1213,25 +1139,23 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) 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(command.handle), VG_FILL_PATH); + vgSetPaint(static_cast(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, @@ -1242,8 +1166,8 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) vgLoadMatrix(save_matrix2); vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); - } break; - + break; + } case DrawTTchar: { cTeletextChar tchar; @@ -1262,7 +1186,6 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) 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); @@ -1271,8 +1194,8 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) 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(vgttpaint), VG_FILL_PATH); + vgSetPaint(static_cast(vgttpaint), VG_STROKE_PATH); cTeletextChar filled; filled.setInternal(0x187f); unsigned int glyph_index = loadTTchar(filled); @@ -1281,22 +1204,20 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) 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(vgttpaint), VG_FILL_PATH); + vgSetPaint(static_cast(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}; @@ -1308,14 +1229,17 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) 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) { @@ -1326,22 +1250,19 @@ 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(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(command.param1)); return 0; - } break; - + } case OVGcreateImagePalette: //imcount++; { VGImage input = vgCreateImage(VG_A_8, command.param1, command.param2, @@ -1353,8 +1274,8 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) 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(malloc(256 * sizeof(VGuint))); + const VGuint* in_palette = static_cast(command.data2); for (int i = 0; i < 256; i++) { @@ -1367,15 +1288,14 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) 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(malloc(buffer_len)); unsigned char* r_buffer1 = buffer; const unsigned char* r_buffer2 = static_cast(command.data); unsigned char* buffer_end = buffer + buffer_len; @@ -1387,14 +1307,11 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) 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{ @@ -1402,7 +1319,6 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) 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()); @@ -1419,10 +1335,10 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) //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(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); @@ -1454,35 +1370,31 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) 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(static_cast(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(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(static_cast(command.data)); eglDestroyImageKHR(egl_display, info->reference); bool static_image = true; @@ -1507,15 +1419,13 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) 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(command.data); switch (style->ft) { @@ -1526,65 +1436,58 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) //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; @@ -1660,7 +1563,6 @@ bool OsdOpenVG::haveOpenVGResponse(unsigned int id, unsigned int* resp) return false; } - unsigned int OsdOpenVG::putOpenVGCommand(OpenVGCommand& comm, bool wait) { taskmutex.lock(); @@ -1706,8 +1608,6 @@ unsigned int OsdOpenVG::putOpenVGCommand(OpenVGCommand& comm, bool wait) } vgtaskSignal.waitForSignalTimed(&target_time); */ - - } else { @@ -1718,8 +1618,6 @@ unsigned int OsdOpenVG::putOpenVGCommand(OpenVGCommand& comm, bool wait) return 0; } - - void OsdOpenVG::destroyImageRef(ImageIndex index) { struct OpenVGCommand comm; @@ -1728,7 +1626,6 @@ void OsdOpenVG::destroyImageRef(ImageIndex index) putOpenVGCommand(comm, false); } - bool OsdOpenVG::getStaticImageData(unsigned int static_id, UCHAR** userdata, ULONG* length) { if (sa_MAX > static_id) @@ -1741,10 +1638,9 @@ bool OsdOpenVG::getStaticImageData(unsigned int static_id, UCHAR** userdata, ULO *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); @@ -1765,8 +1661,6 @@ void OsdOpenVG::createPicture(struct PictureInfo& pict_inf) { // unsupported pict_inf.decoder->freeReference(pict_inf.reference); - - } } @@ -1780,8 +1674,6 @@ bool OsdOpenVG::getEGLPicture(struct OsdVector::PictureInfo& info, EGLDisplay* d return putOpenVGCommand(comm, true); } - - ImageIndex OsdOpenVG::createMonoBitmap(void* base, int width, int height) { struct OpenVGCommand comm; @@ -1820,7 +1712,3 @@ VectorHandle OsdOpenVG::createDrawStyleHandle(const DrawStyle& c) comm.data = &c; return putOpenVGCommand(comm, true); } - - - - diff --git a/osdopenvg.h b/osdopenvg.h index 4a3711c..194dec1 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -20,7 +20,8 @@ #ifndef OSDOPENVG_H #define OSDOPENVG_H -#include +#include +#include #include #include @@ -29,10 +30,8 @@ #include #include - - -#include "osdvector.h" #include "defines.h" +#include "osdvector.h" #include "log.h" #include "threadp.h" #include "videoomx.h" @@ -41,8 +40,6 @@ #include "imageomx.h" #endif -#include - #include #include FT_FREETYPE_H @@ -76,7 +73,6 @@ struct OpenVGResponse unsigned int result; }; - class OsdOpenVG : public OsdVector, public Thread_TYPE #ifdef PICTURE_DECODER_OMX , public EGLPictureCreator @@ -92,8 +88,6 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE bool screenShot(void* buffer, int width, int height, bool osd /*include osd*/); - - float getFontHeight(); float getCharWidth(wchar_t c); @@ -107,10 +101,7 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE void updateBackgroundColor(DrawStyle bg); - protected: - - /*osd vector implementation*/ void destroyImageRef(ImageIndex index); // ImageIndex createJpeg(const char* fileName, int *width,int *height); @@ -132,11 +123,8 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE void getScreenSize(int& width, int& height); void getRealScreenSize(int& width, int& height); - - std::mutex vgmutex; std::mutex taskmutex; - std::mutex vgTaskSignalMutex; std::condition_variable vgTaskSignal; @@ -144,10 +132,10 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE std::deque vgresponses; bool processTasks(); bool haveOpenVGResponse(unsigned int id, unsigned int* resp); - unsigned int putOpenVGCommand(OpenVGCommand& comm, bool wait); + unsigned int putOpenVGCommand(OpenVGCommand& comm, bool wait); unsigned int handleTask(OpenVGCommand& command); //void purgeAllReferences(); - unsigned int wait_id; + unsigned int wait_id{1}; FT_Library ft_library; FT_Face ft_face; @@ -166,28 +154,26 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE unsigned int loadTTchar(cTeletextChar c); std::map tt_font_chars; - void threadMethod(); /* BCM specific */ - uint32_t display_height; - uint32_t display_width; + uint32_t display_height{}; + uint32_t display_width{}; DISPMANX_DISPLAY_HANDLE_T bcm_display; DISPMANX_ELEMENT_HANDLE_T bcm_element; DISPMANX_ELEMENT_HANDLE_T bcm_background; - DISPMANX_RESOURCE_HANDLE_T bcm_backres; - - uint32_t mode; + DISPMANX_RESOURCE_HANDLE_T bcm_backres{}; + uint32_t mode{}; EGLDisplay egl_display; EGLSurface egl_surface; EGLContext egl_context; EGLConfig egl_ourconfig; float font_height; - float aspect_correction; - bool freetype_inited; + float aspect_correction{1.}; + bool freetype_inited{}; uint8_t* static_artwork_begin[sa_MAX]; uint8_t* static_artwork_end[sa_MAX]; -- 2.39.5