From a63505b3f7c21a007ba93a99f6991876c3df292c Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 11 May 2020 23:51:03 +0100 Subject: [PATCH] Reshuffle OsdVector header a bit --- osdvector.cc | 5 --- osdvector.h | 112 ++++++++++++++++++--------------------------------- 2 files changed, 40 insertions(+), 77 deletions(-) diff --git a/osdvector.cc b/osdvector.cc index e662afc..3cfad72 100644 --- a/osdvector.cc +++ b/osdvector.cc @@ -117,11 +117,6 @@ OsdVector::OsdVector() #ifdef PICTURE_DECODER_MAGICK reader.addDecoder(new MagickDecoder(&reader)); #endif - - for (int i = 0; i < 256; i++) - { - byte_char_width[i] = 0.f; - } } void OsdVector::screenShot(const char* fileName) diff --git a/osdvector.h b/osdvector.h index 6695e99..269651c 100644 --- a/osdvector.h +++ b/osdvector.h @@ -17,9 +17,9 @@ along with VOMP. If not, see . */ - #ifndef OSDVECTOR_H #define OSDVECTOR_H + #include #include #include @@ -34,7 +34,6 @@ #include "colour.h" #include "tvmedia.h" #include "vdr.h" - #include "teletextdecodervbiebu.h" enum SVGCommandInstr @@ -47,6 +46,7 @@ enum SVGCommandInstr DrawClipping, DrawImageLoading }; + enum PathIndex { PIHorzLine, @@ -66,19 +66,12 @@ enum Corner TopLeftLimited }; -typedef VectorHandle ImageIndex; +typedef VectorHandle ImageIndex; typedef unsigned long long LoadIndex; class SVGCommand { public: - SVGCommand() - { - instr = DrawNoop; - x = y = w = h = 0; - reference = VECTOR_HANDLE_INIT; - }; - inline static SVGCommand PaintPath(float ix, float iy, float iw, float ih, PathIndex path, VectorHandle ref) { SVGCommand nc; @@ -120,8 +113,6 @@ class SVGCommand return nc; }; - - inline static SVGCommand PaintTTchar(float ix, float iy, float iw, float ih, unsigned int ttchar_in) { SVGCommand nc; @@ -135,6 +126,7 @@ class SVGCommand nc.corner = TopLeft; return nc; }; + inline static SVGCommand PaintClipping(float ix, float iy, float iw, float ih) { SVGCommand nc; @@ -148,7 +140,6 @@ class SVGCommand return nc; }; - inline static void PaintGlyph(SVGCommand& nc, float ix, float iy, wchar_t char_in, VectorHandle ref) { nc.instr = DrawGlyph; @@ -164,41 +155,46 @@ class SVGCommand { return (x >= tx) && (y >= ty) && ((x + w) <= (tx + tw)) && ((y + h) <= (ty + th)); } + bool TTTest(float tox, float toy, float tx, float ty) { return (x == tox) && (toy == y) && (w == tx) && (h == ty); } + bool Outside(float tx, float ty, float tw, float th) { return ((x + w) < tx) || ((y + h) < ty) || ((tx + tw) < x) || ((ty + th) < y); } - VectorHandle getRef() { return reference; }; + VectorHandle getRef() + { + return reference; + }; + ImageIndex getImageIndex() { if (instr != DrawImage) return 0; else return target.image; }; + LoadIndex getLoadIndex() { if (instr != DrawImageLoading) return 0; else return target.loadindex; }; - SVGCommandInstr instr; + SVGCommandInstr instr{DrawNoop}; Corner corner; - float x, y, w, h; - VectorHandle reference; + float x{}, y{}, w{}, h{}; + VectorHandle reference{VECTOR_HANDLE_INIT}; union { - PathIndex path_index; //path_index + PathIndex path_index; wchar_t textchar; ImageIndex image; unsigned int ttchar; LoadIndex loadindex; } target; - - }; class SurfaceVector; @@ -211,7 +207,6 @@ struct SurfaceInfo float x, y, w, h; }; - class OsdVector : public Osd { public: @@ -254,8 +249,6 @@ class OsdVector : public Osd void informPicture(LoadIndex index, ImageIndex i_index); - - int charSet() {return 2;}; //UTF-8 @@ -306,30 +299,20 @@ class OsdVector : public Osd class PictureReader: public Thread_TYPE { public: - ~PictureReader(); - void init(); void addDecoder(PictureDecoder*); void removeDecoder(PictureDecoder*); - void shutdown(); - - bool processReceivedPictures(); // should be called from control thread void receivePicture(VDR_ResponsePacket* vresp); void addStaticImage(unsigned int id); - void invalidateLoadIndex(LoadIndex index); - void informFallback(LoadIndex index, int fallback); - - - protected: void threadMethod(); @@ -343,52 +326,24 @@ class OsdVector : public Osd std::set invalid_loadindex; bool picture_update; - }; - PictureReader* getPictReader() { return &reader;}; - - + PictureReader* getPictReader() { return &reader; }; protected: PictureReader reader; - void incImageRef(ImageIndex index); - int getImageRef(ImageIndex index); - virtual void destroyImageRef(ImageIndex index) = 0; - void incLoadIndexRef(LoadIndex index); - int getLoadIndexRef(LoadIndex index); - - - //virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0; - virtual ImageIndex createMonoBitmap(void* base, int width, int height) = 0; - virtual ImageIndex createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data) = 0; - virtual void createPicture(struct PictureInfo& pict_inf) = 0; - - virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia); - - - std::map images_ref; std::map monobitmaps; //map jpegs; std::map tvmedias; std::list palettepics; - - - std::map loadindex_ref; std::map tvmedias_load; std::map tvmedias_load_inv; std::map tvmedias_loaded; - - - void incrementStyleRefCount(VectorHandle index); - virtual void destroyStyleRef(VectorHandle index) = 0; - - std::map styles; std::map styles_ref; std::map::iterator styles_lastit; @@ -396,24 +351,37 @@ class OsdVector : public Osd std::map::iterator styles_ref_lastit; bool styles_ref_lastit_valid{}; - virtual VectorHandle createStyleRef(const DrawStyle& c) = 0; + std::list surfaces; + using SurfacesIterator = std::list::iterator; - void decrementAllRefCounts(std::vector& commands); - void incrementAllRefCounts(std::vector& commands); - void cleanupOrphanedRefs(); + std::mutex surfaces_mutex; + float byte_char_width[256]{}; + void incImageRef(ImageIndex index); + int getImageRef(ImageIndex index); + virtual void destroyImageRef(ImageIndex index) = 0; + void incLoadIndexRef(LoadIndex index); + int getLoadIndexRef(LoadIndex index); - virtual void drawSetTrans(SurfaceInfo& sc) = 0; - virtual void executeDrawCommand(SVGCommand& command) = 0; + //virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0; + virtual ImageIndex createMonoBitmap(void* base, int width, int height) = 0; + virtual ImageIndex createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data) = 0; + virtual void createPicture(struct PictureInfo& pict_inf) = 0; + virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia); - std::list surfaces; - using SurfacesIterator = std::list::iterator; + void incrementStyleRefCount(VectorHandle index); + virtual void destroyStyleRef(VectorHandle index) = 0; - std::mutex surfaces_mutex; + virtual VectorHandle createStyleRef(const DrawStyle& c) = 0; - float byte_char_width[256]; + void decrementAllRefCounts(std::vector& commands); + void incrementAllRefCounts(std::vector& commands); + void cleanupOrphanedRefs(); + + virtual void drawSetTrans(SurfaceInfo& sc) = 0; + virtual void executeDrawCommand(SVGCommand& command) = 0; void drawSurfaces(); }; -- 2.39.5