From 07c323b52ea86d1bc329bcb9100d765c26678eea Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 15 May 2020 18:08:32 +0100 Subject: [PATCH] Rename some methods and variables * styles -> drawstyleHandles * styles_lastit -> drawstyleHandles_lastit * styles_lastit_valid -> drawstyleHandles_lastit_valid * styles_ref -> drawstyleHandlesRefCounts * styles_ref_lastit -> drawstyleHandlesRefCounts_lastit * styles_ref_lastit_valid -> drawstyleHandlesRefCounts_lastit_valid * getStyleRef -> getDrawStyleHandle * destroyStyleRef -> destroyDrawStyleHandle * createStyleRef -> createDrawStyleHandle * incrementStyleRefCount -> incrementDrawStyleHandleRefCount * decrementStyleRefCount -> decrementDrawStyleHandleRefCount --- osdopenvg.cc | 12 +++---- osdopenvg.h | 4 +-- osdvector.cc | 86 ++++++++++++++++++++++++------------------------ osdvector.h | 23 ++++++------- osdwinvector.cc | 4 +-- osdwinvector.h | 4 +-- surfacevector.cc | 20 +++++------ 7 files changed, 77 insertions(+), 76 deletions(-) diff --git a/osdopenvg.cc b/osdopenvg.cc index d416b19..faa4c43 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -506,7 +506,7 @@ int OsdOpenVG::stopUpdate() void OsdOpenVG::purgeAllReferences() { images_ref.clear(); - styles_ref.clear(); // remove all references + drawstyleHandlesRefCounts.clear(); // remove all references map::iterator mitty=monobitmaps.begin(); @@ -530,12 +530,12 @@ void OsdOpenVG::purgeAllReferences() } tvmedias.clear(); - map,unsigned int>::iterator sitty=styles.begin(); - while (sitty!=styles.end()) { + map,unsigned int>::iterator sitty=drawstyleHandles.begin(); + while (sitty!=drawstyleHandles.end()) { vgDestroyPaint((VGPaint)(*sitty).second); sitty++; } - styles.clear(); + drawstyleHandles.clear(); }*/ @@ -1799,7 +1799,7 @@ ImageIndex OsdOpenVG::createImagePalette(int width, int height, const unsigned c return putOpenVGCommand(comm, true); } -void OsdOpenVG::destroyStyleRef(VectorHandle index) +void OsdOpenVG::destroyDrawStyleHandle(VectorHandle index) { struct OpenVGCommand comm; comm.task = OVGdestroyPaint; @@ -1807,7 +1807,7 @@ void OsdOpenVG::destroyStyleRef(VectorHandle index) putOpenVGCommand(comm, false); } -VectorHandle OsdOpenVG::createStyleRef(const DrawStyle& c) +VectorHandle OsdOpenVG::createDrawStyleHandle(const DrawStyle& c) { unsigned int col = c.rgba(); struct OpenVGCommand comm; diff --git a/osdopenvg.h b/osdopenvg.h index a06182e..4a3711c 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -117,8 +117,8 @@ class OsdOpenVG : public OsdVector, public Thread_TYPE ImageIndex createMonoBitmap(void* base, int width, int height); ImageIndex createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data); void createPicture(struct PictureInfo& pict_inf); - void destroyStyleRef(VectorHandle index); - VectorHandle createStyleRef(const DrawStyle& c); + void destroyDrawStyleHandle(VectorHandle index); + VectorHandle createDrawStyleHandle(const DrawStyle& c); bool getStaticImageData(unsigned int static_id, UCHAR** userdata, ULONG* length); void drawSetTrans(SurfaceInfo& sc); diff --git a/osdvector.cc b/osdvector.cc index 3cfad72..2994fa8 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -178,9 +178,9 @@ int OsdVector::restore() images_ref.clear(); monobitmaps.clear(); //jpegs.clear(); - styles.clear(); - styles_ref.clear(); - styles_lastit_valid = styles_ref_lastit_valid = false; + drawstyleHandles.clear(); + drawstyleHandlesRefCounts.clear(); + drawstyleHandles_lastit_valid = drawstyleHandlesRefCounts_lastit_valid = false; palettepics.clear(); tvmedias.clear(); @@ -344,7 +344,7 @@ void OsdVector::decrementAllRefCounts(std::vector& commands) { for (SVGCommand& command : commands) { - decrementStyleRefCount(command.getRef()); + decrementDrawStyleHandleRefCount(command.getRef()); // FIXME BUG BUG BUG ImageIndex ii = command.getImageIndex(); if (ii) removeImageRef(ii); @@ -358,7 +358,7 @@ void OsdVector::incrementAllRefCounts(std::vector& commands) { for (SVGCommand& command : commands) { - incrementStyleRefCount(command.getRef()); + incrementDrawStyleHandleRefCount(command.getRef()); // FIXME BUG BUG BUG ImageIndex ii = command.getImageIndex(); if (ii) incImageRef(ii); @@ -536,20 +536,20 @@ void OsdVector::cleanupOrphanedRefs() } - std::map::iterator sitty = styles.begin(); + std::map::iterator sitty = drawstyleHandles.begin(); - while (sitty != styles.end()) + while (sitty != drawstyleHandles.end()) { - std::map::iterator curitty = styles_ref.find((*sitty).second); + std::map::iterator curitty = drawstyleHandlesRefCounts.find((*sitty).second); int count = (*curitty).second; if (count == 0) { VectorHandle ref = (*curitty).first; - styles.erase(sitty++); - styles_ref.erase(curitty++); - styles_lastit_valid = styles_ref_lastit_valid = false; - destroyStyleRef(ref); + drawstyleHandles.erase(sitty++); + drawstyleHandlesRefCounts.erase(curitty++); + drawstyleHandles_lastit_valid = drawstyleHandlesRefCounts_lastit_valid = false; + destroyDrawStyleHandle(ref); } else ++sitty; @@ -573,78 +573,78 @@ int OsdVector::getImageRef(ImageIndex index) surfaces_mutex.unlock(); } -void OsdVector::incrementStyleRefCount(VectorHandle index) +void OsdVector::incrementDrawStyleHandleRefCount(VectorHandle index) { - if (!styles_ref_lastit_valid || (styles_ref_lastit->first != index)) + if (!drawstyleHandlesRefCounts_lastit_valid || (drawstyleHandlesRefCounts_lastit->first != index)) { - styles_ref_lastit = styles_ref.find(index); - if (styles_ref_lastit == styles_ref.end()) + drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.find(index); + if (drawstyleHandlesRefCounts_lastit == drawstyleHandlesRefCounts.end()) { - styles_ref_lastit = styles_ref.insert(std::pair(index, 0)).first; + drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.insert(std::pair(index, 0)).first; } } - styles_ref_lastit->second++; - styles_ref_lastit_valid = true; + drawstyleHandlesRefCounts_lastit->second++; + drawstyleHandlesRefCounts_lastit_valid = true; } -void OsdVector::decrementStyleRefCount(VectorHandle index) +void OsdVector::decrementDrawStyleHandleRefCount(VectorHandle index) { - if (!styles_ref_lastit_valid || (styles_ref_lastit->first != index)) + if (!drawstyleHandlesRefCounts_lastit_valid || (drawstyleHandlesRefCounts_lastit->first != index)) { - styles_ref_lastit_valid = false; - styles_ref_lastit = styles_ref.find(index); + drawstyleHandlesRefCounts_lastit_valid = false; + drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.find(index); } - if (styles_ref_lastit != styles_ref.end()) + if (drawstyleHandlesRefCounts_lastit != drawstyleHandlesRefCounts.end()) { - styles_ref_lastit_valid = true; - styles_ref_lastit->second--; + drawstyleHandlesRefCounts_lastit_valid = true; + drawstyleHandlesRefCounts_lastit->second--; } } -VectorHandle OsdVector::getStyleRef(const DrawStyle& c) +VectorHandle OsdVector::getDrawStyleHandle(const DrawStyle& c) { surfaces_mutex.lock(); VectorHandle style_handle = 0; - if (!styles_lastit_valid || (styles_lastit->first != c)) + if (!drawstyleHandles_lastit_valid || (drawstyleHandles_lastit->first != c)) { - styles_lastit_valid = false; - styles_lastit = styles.find(c); + drawstyleHandles_lastit_valid = false; + drawstyleHandles_lastit = drawstyleHandles.find(c); } - if (styles_lastit == styles.end()) + if (drawstyleHandles_lastit == drawstyleHandles.end()) { surfaces_mutex.unlock(); - style_handle = createStyleRef(c); + style_handle = createDrawStyleHandle(c); surfaces_mutex.lock(); - styles_lastit = styles.insert(std::pair(c, style_handle)).first; + drawstyleHandles_lastit = drawstyleHandles.insert(std::pair(c, style_handle)).first; } else { - style_handle = styles_lastit->second; + style_handle = drawstyleHandles_lastit->second; //Now check if the handle is valid - if (!styles_ref_lastit_valid || (*styles_ref_lastit).first != style_handle) + if (!drawstyleHandlesRefCounts_lastit_valid || (*drawstyleHandlesRefCounts_lastit).first != style_handle) { - styles_ref_lastit_valid = false; - styles_ref_lastit = styles_ref.find(style_handle); + drawstyleHandlesRefCounts_lastit_valid = false; + drawstyleHandlesRefCounts_lastit = drawstyleHandlesRefCounts.find(style_handle); } - if (styles_ref_lastit == styles_ref.end()) + if (drawstyleHandlesRefCounts_lastit == drawstyleHandlesRefCounts.end()) { //invalid handle recreate surfaces_mutex.unlock(); - style_handle = createStyleRef(c); + style_handle = createDrawStyleHandle(c); surfaces_mutex.lock(); - styles_lastit->second = style_handle; + drawstyleHandles_lastit->second = style_handle; } - else styles_ref_lastit_valid = true; + else drawstyleHandlesRefCounts_lastit_valid = true; } - styles_lastit_valid = true; - incrementStyleRefCount(style_handle); + drawstyleHandles_lastit_valid = true; + incrementDrawStyleHandleRefCount(style_handle); surfaces_mutex.unlock(); return style_handle; } diff --git a/osdvector.h b/osdvector.h index 269651c..ef0ae1e 100644 --- a/osdvector.h +++ b/osdvector.h @@ -240,8 +240,8 @@ class OsdVector : public Osd void removeImageRef(const ImageIndex ref); void removeLoadIndexRef(const LoadIndex ref); - VectorHandle getStyleRef(const DrawStyle& c); - virtual void decrementStyleRefCount(VectorHandle ref); + VectorHandle getDrawStyleHandle(const DrawStyle& c); + virtual void decrementDrawStyleHandleRefCount(VectorHandle ref); virtual void getScreenSize(int& width, int& height) = 0; virtual void getRealScreenSize(int& width, int& height) = 0; @@ -344,12 +344,13 @@ class OsdVector : public Osd std::map tvmedias_load_inv; std::map tvmedias_loaded; - std::map styles; - std::map styles_ref; - std::map::iterator styles_lastit; - bool styles_lastit_valid{}; - std::map::iterator styles_ref_lastit; - bool styles_ref_lastit_valid{}; + std::map drawstyleHandles; + std::map::iterator drawstyleHandles_lastit; + bool drawstyleHandles_lastit_valid{}; + + std::map drawstyleHandlesRefCounts; + std::map::iterator drawstyleHandlesRefCounts_lastit; + bool drawstyleHandlesRefCounts_lastit_valid{}; std::list surfaces; using SurfacesIterator = std::list::iterator; @@ -371,10 +372,10 @@ class OsdVector : public Osd virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia); - void incrementStyleRefCount(VectorHandle index); - virtual void destroyStyleRef(VectorHandle index) = 0; + virtual VectorHandle createDrawStyleHandle(const DrawStyle& c) = 0; + void incrementDrawStyleHandleRefCount(VectorHandle index); + virtual void destroyDrawStyleHandle(VectorHandle index) = 0; - virtual VectorHandle createStyleRef(const DrawStyle& c) = 0; void decrementAllRefCounts(std::vector& commands); void incrementAllRefCounts(std::vector& commands); diff --git a/osdwinvector.cc b/osdwinvector.cc index 64bcd39..9a0292b 100644 --- a/osdwinvector.cc +++ b/osdwinvector.cc @@ -1352,7 +1352,7 @@ ImageIndex OsdWinVector::createImagePalette(int width, int height, const unsigne } -void OsdWinVector::destroyStyleRef(VectorHandle index) +void OsdWinVector::destroyDrawStyleHandle(VectorHandle index) { if (!initted) return; ID2D1Brush *brush = (ID2D1Brush*)(index); @@ -1360,7 +1360,7 @@ void OsdWinVector::destroyStyleRef(VectorHandle index) } -VectorHandle OsdWinVector::createStyleRef(const DrawStyle &c) +VectorHandle OsdWinVector::createDrawStyleHandle(const DrawStyle &c) { LockOsdDrawing(); diff --git a/osdwinvector.h b/osdwinvector.h index e56622d..8318d96 100644 --- a/osdwinvector.h +++ b/osdwinvector.h @@ -73,8 +73,8 @@ protected: ImageIndex createMonoBitmap(void *base, int width, int height); ImageIndex createImagePalette(int width, int height, const unsigned char *image_data, const unsigned int*palette_data); void createPicture(struct PictureInfo& pict_inf); - void destroyStyleRef(VectorHandle index); - VectorHandle createStyleRef(const DrawStyle &c); + void destroyDrawStyleHandle(VectorHandle index); + VectorHandle createDrawStyleHandle(const DrawStyle &c); bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length); diff --git a/surfacevector.cc b/surfacevector.cc index 8f5216f..fa7b61f 100644 --- a/surfacevector.cc +++ b/surfacevector.cc @@ -36,7 +36,7 @@ SurfaceVector::~SurfaceVector() for (SVGCommand& command : commands) { - osd->decrementStyleRefCount(command.getRef()); // We remove the Style reference, so that osd can free stuff + osd->decrementDrawStyleHandleRefCount(command.getRef()); // We remove the Style reference, so that osd can free stuff // FIXME BUG BUG BUG ImageIndex ii = command.getImageIndex(); if (ii) osd->removeImageRef(ii); @@ -84,7 +84,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra while (num_bytes != ((size_t) -1) && num_bytes != ((size_t) -2) && length > 0) { - ref = osd->getStyleRef(c); // Need to call this each time to have OSD get the ref count right. Maybe expose incRefCount sometime + ref = osd->getDrawStyleHandle(c); // Need to call this each time to have OSD get the ref count right. Maybe expose incRefCount sometime SVGCommand::PaintGlyph(commands[commands_size + chars], x + shift, y, tempo, ref); chars++; @@ -112,7 +112,7 @@ int SurfaceVector::drawText(const char* text, int x, int y, int width, const Dra for (int i = 0; i < real_length; i++) { - ref = osd->getStyleRef(c); // Need to call this each time to have OSD get the ref count right. Maybe expose incRefCount sometime + ref = osd->getDrawStyleHandle(c); // Need to call this each time to have OSD get the ref count right. Maybe expose incRefCount sometime SVGCommand::PaintGlyph(commands[commands_size + chars], x + shift, y, temptext[i], ref); chars++; @@ -280,14 +280,14 @@ int SurfaceVector::create(UINT width, UINT height) } void SurfaceVector::display() { - //nothing this is really mvp specific + //nothing this is really mvp specific // FIXME remove? } int SurfaceVector::fillblt(int x, int y, int width, int height, const DrawStyle& c) { command_mutex.lock(); removeCommands(x, y, width, height); // remove commands below the box - VectorHandle ref = osd->getStyleRef(c); + VectorHandle ref = osd->getDrawStyleHandle(c); commands.push_back(SVGCommand::PaintPath(x, y, width, height, PIRectangle, ref)); command_mutex.unlock(); return 1; @@ -296,7 +296,7 @@ int SurfaceVector::fillblt(int x, int y, int width, int height, const DrawStyle& void SurfaceVector::drawHorzLine(int x1, int x2, int y, const DrawStyle& c) { command_mutex.lock(); - VectorHandle ref = osd->getStyleRef(c); + VectorHandle ref = osd->getDrawStyleHandle(c); commands.push_back(SVGCommand::PaintPath(x1, y, x2 - x1, 1, PIHorzLine, ref)); command_mutex.unlock(); } @@ -304,7 +304,7 @@ void SurfaceVector::drawHorzLine(int x1, int x2, int y, const DrawStyle& c) void SurfaceVector::drawVertLine(int x, int y1, int y2, const DrawStyle& c) { command_mutex.lock(); - VectorHandle ref = osd->getStyleRef(c); + VectorHandle ref = osd->getDrawStyleHandle(c); commands.push_back(SVGCommand::PaintPath(x, y1, 1, y2 - y1, PIVertLine, ref)); command_mutex.unlock(); } @@ -345,7 +345,7 @@ void SurfaceVector::drawPoint(int x, int y, DrawStyle& c, bool fastdraw) { if (!fastdraw) command_mutex.lock(); - VectorHandle ref = osd->getStyleRef(c); + VectorHandle ref = osd->getDrawStyleHandle(c); commands.push_back(SVGCommand::PaintPath(x, y, 1, 1, PIPoint, ref)); if (!fastdraw) command_mutex.unlock(); @@ -354,7 +354,7 @@ void SurfaceVector::drawMonoBitmap(UCHAR* base, int dx, int dy, unsigned int hei { command_mutex.lock(); ImageIndex image = osd->getMonoBitmapRef(base, width, height); - VectorHandle ref = osd->getStyleRef(nextColour); + VectorHandle ref = osd->getDrawStyleHandle(nextColour); removeCommands(dx, dy, width, height); commands.push_back(SVGCommand::PaintImage(dx, dy, height, width, image, ref)); command_mutex.unlock(); @@ -381,7 +381,7 @@ int SurfaceVector::removeCommands(float x, float y, float width, float height) { //Log::getInstance()->log("OSD", Log::DEBUG, "Remove command %d %g %g %g %g %d %d",(*itty).instr, //(*itty).x,(*itty).y,(*itty).w,(*itty).h,(*itty).reference,(*itty).target.image); - osd->decrementStyleRefCount((*itty).getRef()); // We remove the Style reference, so that osd can free stuff + osd->decrementDrawStyleHandleRefCount((*itty).getRef()); // We remove the Style reference, so that osd can free stuff // FIXME BUG BUG BUG ImageIndex ii = (*itty).getImageIndex(); if (ii) osd->removeImageRef(ii); -- 2.39.5