From 8bb5db0b49feb3e713bb2532b35c79a87b8700c6 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Wed, 20 May 2020 14:11:16 +0100 Subject: [PATCH] OsdOpenVG: Some renames, some CWFs --- osdopenvg.cc | 57 +++++++++++++++------------------------------------- osdopenvg.h | 4 ++-- osdvector.cc | 2 ++ 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/osdopenvg.cc b/osdopenvg.cc index f1fa056..ac2bd0d 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -72,33 +72,8 @@ OsdOpenVG::~OsdOpenVG() if (freetype_inited) FT_Done_Face(ft_face); - // I think the following is broken as it is, but also possibly it shouldn't be free()ing the memory - // pointed at anyway, so it's correctly not working?! - - if (!fontnames.size()) - { - std::vector::iterator itty = fontnames.begin(); - - while (itty != fontnames.end()) - { - free(*itty); - itty++; - } - } - - // end - - - if (fontnames_keys.size()) - { - std::vector::iterator itty = fontnames_keys.begin(); - - while (itty != fontnames_keys.end()) - { - free(*itty); - itty++; - } - } + for (char* c : fontnames) free(c); + for (char* c : fontnames_keys) free(c); vgmutex.unlock(); taskmutex.unlock(); @@ -455,7 +430,7 @@ void OsdOpenVG::destroyPaths() int OsdOpenVG::stopUpdate() { threadStop(); - processTasks(); + processOpenVGCommands(); return 1; } @@ -524,7 +499,7 @@ int OsdOpenVG::shutdown() } Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark2"); - processTasks(); + processOpenVGCommands(); Log::getInstance()->log("OSD", Log::DEBUG, "shutdown mark3"); taskmutex.lock(); @@ -613,7 +588,7 @@ void OsdOpenVG::threadMethod() ts = time1 - lastrendertime; } - if (processTasks()) ts = 0; + if (processOpenVGCommands()) ts = 0; } if (!threadIsActive()) @@ -1241,7 +1216,7 @@ void OsdOpenVG::executeDrawCommand(SVGCommand& command) } //int imcount=0;// this is debug code and should not go into release -unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) +unsigned int OsdOpenVG::handleOpenVGCommand(OpenVGCommand& command) { switch (command.task) { @@ -1463,17 +1438,17 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) for (int i = 0; i < (style->num_colors - 1); i++) { colorramp[0 + (i + 1) * 5] = style->grad_pos[i]; - 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[1 + (i + 1) * 5] = static_cast(style->grad_col[i].red) / 255.f; + colorramp[2 + (i + 1) * 5] = static_cast(style->grad_col[i].green) / 255.f; + colorramp[3 + (i + 1) * 5] = static_cast(style->grad_col[i].blue) / 255.f; + colorramp[4 + (i + 1) * 5] = static_cast(style->grad_col[i].alpha) / 255.f; } colorramp[0 + (style->num_colors) * 5] = 1.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; + colorramp[1 + (style->num_colors) * 5] = static_cast(style->grad_col[style->num_colors - 1].red) / 255.f; + colorramp[2 + (style->num_colors) * 5] = static_cast(style->grad_col[style->num_colors - 1].green) / 255.f; + colorramp[3 + (style->num_colors) * 5] = static_cast(style->grad_col[style->num_colors - 1].blue) / 255.f; + colorramp[4 + (style->num_colors) * 5] = static_cast(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); @@ -1489,7 +1464,7 @@ unsigned int OsdOpenVG::handleTask(OpenVGCommand& command) return 0; } -bool OsdOpenVG::processTasks() +bool OsdOpenVG::processOpenVGCommands() { bool worked = false; taskmutex.lock(); @@ -1502,7 +1477,7 @@ bool OsdOpenVG::processTasks() taskmutex.unlock(); OpenVGResponse resp; - resp.result = handleTask(comm); + resp.result = handleOpenVGCommand(comm); resp.id = comm.id; taskmutex.lock(); diff --git a/osdopenvg.h b/osdopenvg.h index c66469c..df91d52 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -131,9 +131,9 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE std::deque vgcommands; std::deque vgresponses; - bool processTasks(); + bool processOpenVGCommands(); unsigned int putOpenVGCommand(OpenVGCommand& comm, bool wait); - unsigned int handleTask(OpenVGCommand& command); + unsigned int handleOpenVGCommand(OpenVGCommand& command); //void purgeAllReferences(); unsigned int wait_id{1}; diff --git a/osdvector.cc b/osdvector.cc index 9657d8a..453be13 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -670,6 +670,8 @@ VectorHandle OsdVector::getDrawStyleHandle(const DrawStyle& c) #if DEV void OsdVector::dumpStyles() { + return; + std::map::iterator i; for(i = drawstyleHandles.begin(); i != drawstyleHandles.end(); i++) { -- 2.39.5