]> git.vomp.tv Git - vompclient.git/commitdiff
Reorganized handling of static pictures
authorMarten Richter <marten.richter@freenet.de>
Sun, 5 Oct 2014 18:12:31 +0000 (20:12 +0200)
committerMarten Richter <marten.richter@freenet.de>
Sun, 5 Oct 2014 18:12:31 +0000 (20:12 +0200)
osdopenvg.cc
osdopenvg.h
surfacevector.cc
tvmedia.cc
tvmedia.h

index d170c6d472ebeaefca983cb689a50a5acd9ed27d..fd1a02846e6cea9166ebad47439d9139d90ffb3e 100644 (file)
@@ -23,7 +23,6 @@
 #include "mtd.h"
 #include "videoomx.h"
 #include "surface.h"
-//#include <Magick++.h>
 
 #include "message.h"
 #include "command.h"
 #include <math.h>
 #include <bcm_host.h>
 
-//using namespace Magick;
+#define EXTERNAL_PICTS \
+       EXTERNALPICTURE(vdrlogo, vdrhires, jpg) \
+       EXTERNALPICTURE(wallpaper, wallpaper720p, jpg)
 
-extern uint8_t vdr_data[]     asm("_binary_other_vdrhires_jpg_start");
-extern uint8_t vdr_data_end[] asm("_binary_other_vdrhires_jpg_end");
-extern uint8_t wallpaper_data[]     asm("_binary_other_wallpaper720p_jpg_start");
-extern uint8_t wallpaper_data_end[] asm("_binary_other_wallpaper720p_jpg_end");
+
+
+#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");
+
+EXTERNAL_PICTS
+
+#undef EXTERNALPICTURES
 
 
 #define  BACKBUFFER_WIDTH 1280
@@ -63,6 +68,16 @@ OsdOpenVG::OsdOpenVG()
   cur_fontname=(char*)malloc(strlen(fontname)+1);
   strcpy(cur_fontname,fontname);
 
+#define EXTERNALPICTURE(name, fname, fileextension) static_artwork_begin[sa_ ## name]=name ## _data;
+
+  EXTERNAL_PICTS
+
+#undef EXTERNALPICTURE
+#define EXTERNALPICTURE(name, fname, fileextension) static_artwork_end[sa_ ## name]=name ## _data_end;
+
+  EXTERNAL_PICTS
+
+#undef EXTERNALPICTURE
 }
 
 OsdOpenVG::~OsdOpenVG()
@@ -1401,62 +1416,20 @@ void OsdOpenVG::destroyImageRef(ImageIndex index)
        comm.param1=index;
        putOpenVGCommand(comm,false);
 }
-/*
-ImageIndex OsdOpenVG::createJpeg(const char* fileName, int *width,int *height)
-{
-       Image* magicimage=NULL;
-       struct OpenVGCommand comm;
-       comm.task=OVGcreateImageFile;
-
-       try{
-               // Now figure out, if it is a special case
-               if (strcmp(fileName,"/vdr.jpg")==0) {
-                       magicimage=new Image(Blob(vdr_data,vdr_data_end-vdr_data));
-                       *height=100; // this is faked so that the system does use the old coordinate system
-                       *width=ceil(190.f*aspect_correction);
-                       Log::getInstance()->log("OSD", Log::DEBUG, "LoadIm vdr.jpg");
-               } else if (strcmp(fileName,"/wallpaperPAL.jpg")==0) {
-                       magicimage=new Image(Blob(wallpaper_data,wallpaper_data_end-wallpaper_data));
-                       *width=720; // this is faked so that the system does use the old coordinate system
-                       *height=576;
-                       Log::getInstance()->log("OSD", Log::DEBUG, "LoadIm wallpaperPAL.jpg");
-               } else {
-                       magicimage=new Image();
-                       magicimage->read(fileName);
-                       Log::getInstance()->log("OSD", Log::DEBUG, "LoadIm file: %s",fileName);
-                       *width=ceil(magicimage->baseColumns()*aspect_correction); // this is faked so that the system does use the old coordinate system
-                       *height=magicimage->baseRows();
-               }
 
-       }catch( Exception &error_ )
-       {
-               Log::getInstance()->log("OSD", Log::DEBUG, "Libmagick: %s",error_.what());
-
-               return 0;
-       }
-       comm.data=magicimage;
-       return putOpenVGCommand(comm,true);
-}*/
 
 bool OsdOpenVG::getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length)
 {
-       switch (static_id) {
-       case 1: {
-               *userdata = vdr_data;
-               *length = vdr_data_end-vdr_data;
-               return true;
-       } break;
-       case 2: {
-               *userdata = wallpaper_data;
-               *length = wallpaper_data_end-wallpaper_data;
+       if (sa_MAX>static_id) {
+               *userdata = static_artwork_begin[static_id];
+               *length = static_artwork_end[static_id] - static_artwork_begin[static_id];
                return true;
-       } break;
-       default: {
-               *userdata = NULL;
-               *length = 0;
-               return false;
-       } break;
-       };
+       }
+
+       *userdata = NULL;
+       *length = 0;
+       return false;
+
 }
 
 void  OsdOpenVG::createPicture(struct PictureInfo& pict_inf)
index cd21c3d0f454263646014742d9ea8445fcd61e49..c502ded81988462562507b2fb9fd4dfc0aff1d3e 100644 (file)
@@ -185,6 +185,9 @@ protected:
        float aspect_correction;
        bool freetype_inited;
 
+       uint8_t *static_artwork_begin[sa_MAX];
+       uint8_t *static_artwork_end[sa_MAX];
+
 #ifdef PICTURE_DECODER_OMX
        ImageOMX *imageomx;
 #endif
index 29bee4d59ca93ea444769627ad72d1178b3d71f0..bb8ce08f1aee513dc2144ceb0b168f680dcab6fb 100644 (file)
@@ -161,19 +161,19 @@ int SurfaceVector::drawTextCentre(const char* text, int x, int y, const DrawStyl
 
 void SurfaceVector::drawJpeg(const char *fileName,int x, int y,int *width, int *height)
 {
-       int jpeg_index=-1; // This is for compatibility only
+       StaticArtwork index=sa_MAX; // This is for compatibility only
        if (strcmp(fileName,"/vdr.jpg")==0) {
-               jpeg_index=1;
+               index=sa_vdrlogo;
                *height=100; // this is faked so that the system does use the old coordinate system
                *width=ceil(190.f*osd->getPixelAspect());
        } else if (strcmp(fileName,"/wallpaperPAL.jpg")==0) {
-               jpeg_index=2;
+               index=sa_wallpaper;
                *width=720; // this is faked so that the system does use the old coordinate system
                *height=576;
        }
-       if (jpeg_index>0) {
+       if (index!=sa_MAX) {
                TVMediaInfo info;
-               info.setDefaultJpeg(jpeg_index);
+               info.setStaticArtwork(index);
                drawTVMedia(info,x,y,*width,*height,TopLeft);
        }
 }
index fb0ab22561375ed91a4a80c9b1ea012ee236f62a..4f79a0965deef8bebd8587eda2a71d5c7c4fb8d8 100644 (file)
@@ -67,10 +67,10 @@ void TVMediaInfo::setPosterThumb(const char* recname)
        primary_name=recname;
 }
 
-void TVMediaInfo::setDefaultJpeg(int jpeg_index)
+void TVMediaInfo::setStaticArtwork(StaticArtwork id)
 {
        type=4;
-       primary_id=jpeg_index;
+       primary_id=id;
 }
 
 void TVMediaInfo::setPosterThumb(int channel, int eventid)
index 42af1eaadd3b98e0cd11e099ceaf545c0df0e18c..50156afce47a0abf306df4c82b0d5a07f053b60d 100644 (file)
--- a/tvmedia.h
+++ b/tvmedia.h
 class MovieInfo;
 class SeriesInfo;
 
+typedef enum tStaticArtwork
+{
+       sa_wallpaper,
+       sa_vdrlogo,
+       sa_MAX
+} StaticArtwork;
+
 class TVMediaInfo
 {
 friend class VDR;
@@ -46,7 +53,7 @@ public:
        void setPosterThumb(const char* recname);
        void setPosterThumb(int channel, int eventid);
        void setChannelLogo(int channel);
-       void setDefaultJpeg(int jpeg_index);
+       void setStaticArtwork(StaticArtwork artwork);
        int getType() {return type;};
        int getPrimaryID() {return primary_id;};
        int getSecondaryID() {return secondary_id;};