From edac312df83f0b6b6d5f2f41bdbeb2b76b650140 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Sun, 14 Aug 2022 21:29:57 +0000 Subject: [PATCH] CWFs --- src/osdopenvg.cc | 73 +++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/src/osdopenvg.cc b/src/osdopenvg.cc index 46ee339..7edafce 100644 --- a/src/osdopenvg.cc +++ b/src/osdopenvg.cc @@ -230,7 +230,7 @@ int OsdOpenVG::init() if (query_str) LogNT::getInstance()->info(TAG, query_str); else LogNT::getInstance()->warn(TAG, "Could not query display {:#x}", vgGetError()); - aspect_correction = ((float)BACKBUFFER_HEIGHT) / 576.f / (((float)BACKBUFFER_WIDTH) / 720.f); + aspect_correction = BACKBUFFER_HEIGHT / 576.f / (BACKBUFFER_WIDTH / 720.f); initPaths(); if (!fontnames.size()) @@ -741,7 +741,7 @@ bool OsdOpenVG::screenShotInternal(void* buffer, int width, int height, bool inc uint32_t image_ptr; VC_RECT_T rect; - res = vc_dispmanx_resource_create(VC_IMAGE_RGBA32, width, height, &image_ptr); + res = vc_dispmanx_resource_create(VC_IMAGE_RGBA32, tou4(width), tou4(height), &image_ptr); display = vc_dispmanx_display_open(0); if (!includeOSD) @@ -755,7 +755,7 @@ bool OsdOpenVG::screenShotInternal(void* buffer, int width, int height, bool inc static_cast(DISPMANX_SNAPSHOT_FILL)); } - vc_dispmanx_rect_set(&rect, 0, 0, width, height); + vc_dispmanx_rect_set(&rect, 0, 0, tou4(width), tou4(height)); vc_dispmanx_resource_read_data(res, &rect, buffer, width * 4); vc_dispmanx_resource_delete(res); vc_dispmanx_display_close(display); @@ -861,7 +861,7 @@ int OsdOpenVG::getFontNames(const char*** names, const char*** names_keys) { *names = const_cast(&(fontnames[0])); *names_keys = const_cast(&(fontnames_keys[0])); - return fontnames.size(); + return toi4(fontnames.size()); } void OsdOpenVG::setFont(const char* fontname) @@ -1046,7 +1046,7 @@ int OsdOpenVG::loadFont(bool newfont) if (!(last_tag & 0x1)) { segments.push_back(VG_QUAD_TO); - int coord_size = coord.size(); + u4 coord_size = coord.size(); VGfloat x = (coord[coord_size - 2] + ((float)fpoint.x) / 256.f) * 0.5f * aspect_correction; VGfloat y = (coord[coord_size - 1] + (font_size - ((float)fpoint.y) / 256.f)) * 0.5f; coord.push_back(x); @@ -1116,9 +1116,9 @@ int OsdOpenVG::loadFont(bool newfont) cur_char = FT_Get_Next_Char(ft_face, cur_char, &glyph); } - for (int i = 0; i < 256; i++) + for (u4 i = 0; i < 256; i++) { - unsigned int glyph_index = FT_Get_Char_Index(ft_face, i); + u4 glyph_index = FT_Get_Char_Index(ft_face, i); byte_char_width[i] = font_exp_x[glyph_index]; } @@ -1129,20 +1129,20 @@ void OsdOpenVG::drawSetTrans(SurfaceInfo& sc) { vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE); vgLoadIdentity(); - vgScale(((float)BACKBUFFER_WIDTH) / 720.f, -((float)BACKBUFFER_HEIGHT) / 576.f); + vgScale(BACKBUFFER_WIDTH / 720.f, -BACKBUFFER_HEIGHT / 576.f); vgTranslate(0.f + sc.x, -576.f + sc.y); vgSeti(VG_MATRIX_MODE, VG_MATRIX_GLYPH_USER_TO_SURFACE); vgLoadIdentity(); - vgScale(((float)BACKBUFFER_WIDTH) / 720.f, -((float)BACKBUFFER_HEIGHT) / 576.f); + vgScale(BACKBUFFER_WIDTH / 720.f, -BACKBUFFER_HEIGHT / 576.f); vgTranslate(0.f + sc.x, -576.f + sc.y); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadIdentity(); - vgScale(((float)BACKBUFFER_WIDTH) / 720.f, -((float)BACKBUFFER_HEIGHT) / 576.f); + vgScale(BACKBUFFER_WIDTH / 720.f, -BACKBUFFER_HEIGHT / 576.f); vgTranslate(0.f + sc.x, -576.f + sc.y); - clip_shift_x = sc.x; - clip_shift_y = sc.y; + clip_shift_x = static_cast(sc.x); + clip_shift_y = static_cast(sc.y); //vgTranslate(0.f+sc.x,576.f-sc.y); //LogNT::getInstance()->debug(TAG, "Draw Translate {} {}",sc.x,sc.y); @@ -1176,8 +1176,11 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) case DrawBitmap: { VGImage vgimage; - if (command.instr == DrawBitmap) vgimage = static_cast(command.target.bitmap); - else if (command.instr == DrawImage) + if (command.instr == DrawBitmap) + { + vgimage = static_cast(command.target.bitmap); + } + else // command.instr == DrawImage { // FIXME use shared_ptr for OsdImageOpenVG objects? // -or- @@ -1191,8 +1194,8 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgGetMatrix(save_matrix); - VGfloat imagewidth = vgGetParameteri(vgimage, VG_IMAGE_WIDTH); - VGfloat imageheight = vgGetParameteri(vgimage, VG_IMAGE_HEIGHT); + VGfloat imagewidth = static_cast(vgGetParameteri(vgimage, VG_IMAGE_WIDTH)); + VGfloat imageheight = static_cast(vgGetParameteri(vgimage, VG_IMAGE_HEIGHT)); //vgScale(command.w,command.h); @@ -1374,10 +1377,10 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) case DrawClipping: { VGint coords[4] = {0, 0, 0, 0}; - coords[0] = ((command.x + clip_shift_x) * ((float)BACKBUFFER_WIDTH) / 720.f); - coords[1] = ((576.f - command.y - clip_shift_y - command.h) * ((float)BACKBUFFER_HEIGHT) / 576.f); - coords[2] = ((command.w - 1.f) * ((float)BACKBUFFER_WIDTH) / 720.f); - coords[3] = ((command.h - 1.f) * ((float)BACKBUFFER_HEIGHT) / 576.f); + coords[0] = toi4((command.x + static_cast(clip_shift_x)) * BACKBUFFER_WIDTH / 720.f); + coords[1] = toi4((576.f - command.y - static_cast(clip_shift_y) - command.h) * BACKBUFFER_HEIGHT / 576.f); + coords[2] = toi4((command.w - 1.f) * BACKBUFFER_WIDTH / 720.f); + coords[3] = toi4((command.h - 1.f) * BACKBUFFER_HEIGHT / 576.f); vgSetiv(VG_SCISSOR_RECTS, 4, coords); if (command.w == 0.f && command.h == 0.f) @@ -1418,13 +1421,13 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) } case OVGcreateImagePalette: //imcount++; { - VGImage input = vgCreateImage(VG_A_8, command.param1, command.param2, + VGImage input = vgCreateImage(VG_A_8, toi4(command.param1), toi4(command.param2), VG_IMAGE_QUALITY_NONANTIALIASED | VG_IMAGE_QUALITY_FASTER | VG_IMAGE_QUALITY_BETTER); //LogNT::getInstance()->debug(TAG, "Draw create palette {} {} {:#x} {}",command.param1,command.param2,vgGetError(),input); - vgImageSubData(input, command.data, command.param1, - VG_A_8, 0, 0, command.param1, command.param2); // upload palettized image data - VGImage handle = vgCreateImage(VG_sRGBA_8888, command.param1, command.param2, + vgImageSubData(input, command.data, toi4(command.param1), + VG_A_8, 0, 0, toi4(command.param1), toi4(command.param2)); // upload palettized image data + VGImage handle = vgCreateImage(VG_sRGBA_8888, toi4(command.param1), toi4(command.param2), VG_IMAGE_QUALITY_NONANTIALIASED | VG_IMAGE_QUALITY_FASTER | VG_IMAGE_QUALITY_BETTER); VGuint* palette = static_cast(malloc(256 * sizeof(VGuint))); @@ -1444,7 +1447,7 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) } case OVGcreateMonoBitmap: //imcount++; { - VGImage handle = vgCreateImage(VG_A_1, command.param1, command.param2, + VGImage handle = vgCreateImage(VG_A_1, toi4(command.param1), toi4(command.param2), VG_IMAGE_QUALITY_FASTER); //LogNT::getInstance()->debug(TAG, "Draw create mono {} {} {:#x} {}",command.param1,command.param2,vgGetError(),handle); unsigned int buffer_len = (command.param1 * command.param2) >> 3; @@ -1460,7 +1463,7 @@ unsigned int OsdOpenVG::handleOpenVGCommand(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, toi4(command.param1), toi4(command.param2)); free(buffer); // LogNT::getInstance()->debug(TAG, "Draw create mono2 {} {} {:#x} {}",command.param1,command.param2,vgGetError(),handle); return handle; @@ -1494,9 +1497,9 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) const PictureInfo* info = static_cast(command.data); VGImage handle; //LogNT::getInstance()->debug(TAG, "TVMedia OVGcreateImageMemory {}",imcount); - handle = vgCreateImage(VG_sABGR_8888, info->width, info->height, VG_IMAGE_QUALITY_BETTER); - vgImageSubData(handle, info->image, info->width * 4, - VG_sABGR_8888, 0, 0, info->width, info->height); + handle = vgCreateImage(VG_sABGR_8888, toi4(info->width), toi4(info->height), VG_IMAGE_QUALITY_BETTER); + vgImageSubData(handle, info->image, toi4(info->width) * 4, + VG_sABGR_8888, 0, 0, toi4(info->width), toi4(info->height)); info->decoder->freeReference(info->reference); // We have a pictures! send a message to ourself, to switch to gui thread @@ -1516,7 +1519,7 @@ unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) PictureInfo* info = const_cast(static_cast(command.data)); VGImage handle; - handle = vgCreateImage(VG_sABGR_8888, info->width, info->height, VG_IMAGE_QUALITY_BETTER); + handle = vgCreateImage(VG_sABGR_8888, toi4(info->width), toi4(info->height), VG_IMAGE_QUALITY_BETTER); // LogNT::getInstance()->debug(TAG, "TVMedia OVGcreateEGLImage {} {} {:#x} {}",info->width,info->height, handle,imcount); info->handle = handle; @@ -1628,7 +1631,7 @@ bool OsdOpenVG::getStaticImageData(unsigned int static_id, u1** userdata, u4* le if (sa_MAX > static_id) { *userdata = static_artwork_begin[static_id]; - *length = static_artwork_end[static_id] - static_artwork_begin[static_id]; + *length = tou4(static_artwork_end[static_id] - static_artwork_begin[static_id]); return true; } @@ -1675,8 +1678,8 @@ VectorHandleImage OsdOpenVG::createMonoBitmap(void* base, int width, int height) { struct OpenVGCommand comm; comm.task = OVGcreateMonoBitmap; - comm.param1 = width; - comm.param2 = height; + comm.param1 = tou4(width); + comm.param2 = tou4(height); comm.data = base; return putOpenVGCommand(comm, true); } @@ -1685,8 +1688,8 @@ VectorHandleImage OsdOpenVG::createImagePalette(int width, int height, const uns { struct OpenVGCommand comm; comm.task = OVGcreateImagePalette; - comm.param1 = width; - comm.param2 = height; + comm.param1 = tou4(width); + comm.param2 = tou4(height); comm.data = image_data; comm.data2 = palette_data; return putOpenVGCommand(comm, true); -- 2.39.2