From 84c8e4f5c5095800934b46e05682f73ddf893d7b Mon Sep 17 00:00:00 2001 From: Marten Richter Date: Sun, 5 Oct 2014 20:12:31 +0200 Subject: [PATCH] Reorganized handling of static pictures --- osdopenvg.cc | 87 +++++++++++++++++------------------------------- osdopenvg.h | 3 ++ surfacevector.cc | 10 +++--- tvmedia.cc | 4 +-- tvmedia.h | 9 ++++- 5 files changed, 48 insertions(+), 65 deletions(-) diff --git a/osdopenvg.cc b/osdopenvg.cc index d170c6d..fd1a028 100644 --- a/osdopenvg.cc +++ b/osdopenvg.cc @@ -23,7 +23,6 @@ #include "mtd.h" #include "videoomx.h" #include "surface.h" -//#include #include "message.h" #include "command.h" @@ -35,12 +34,18 @@ #include #include -//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) diff --git a/osdopenvg.h b/osdopenvg.h index cd21c3d..c502ded 100644 --- a/osdopenvg.h +++ b/osdopenvg.h @@ -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 diff --git a/surfacevector.cc b/surfacevector.cc index 29bee4d..bb8ce08 100644 --- a/surfacevector.cc +++ b/surfacevector.cc @@ -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); } } diff --git a/tvmedia.cc b/tvmedia.cc index fb0ab22..4f79a09 100644 --- a/tvmedia.cc +++ b/tvmedia.cc @@ -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) diff --git a/tvmedia.h b/tvmedia.h index 42af1ea..50156af 100644 --- a/tvmedia.h +++ b/tvmedia.h @@ -28,6 +28,13 @@ 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;}; -- 2.39.5