2 Copyright 2004-2005 Chris Tallon, 2006,2011-2012 Marten Richter
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
35 #include "teletextdecodervbiebu.h"
37 enum SVGCommandInstr {
63 typedef unsigned int ImageIndex;
64 typedef unsigned long long LoadIndex;
75 inline static SVGCommand PaintPath(float ix, float iy,float iw,float ih,PathIndex path,unsigned int ref)
83 nc.target.path_index=path;
88 inline static SVGCommand PaintImageLoading(LoadIndex load_in,float ix, float iy,float iw,float ih,unsigned int ref, Corner corner=TopLeft)
91 nc.instr=DrawImageLoading;
96 nc.target.loadindex=load_in;
102 inline static SVGCommand PaintImage(float ix, float iy,float iw,float ih,ImageIndex image_in,unsigned int ref, Corner corner=TopLeft)
110 nc.target.image=image_in;
118 inline static SVGCommand PaintTTchar(float ix, float iy,float iw,float ih,unsigned int ttchar_in)
127 nc.target.ttchar=ttchar_in;
131 inline static SVGCommand PaintClipping(float ix, float iy,float iw,float ih)
134 nc.instr=DrawClipping;
145 inline static void PaintGlyph(SVGCommand& nc, float ix, float iy,wchar_t char_in,unsigned int ref)
153 nc.target.textchar=char_in;
156 bool Test(float tx,float ty,float tw, float th)
158 return (x>=tx) && (y>=ty) && ((x+w)<=(tx+tw)) && ((y+h)<=(ty+th));
160 bool TTTest(float tox,float toy,float tx, float ty)
162 return (x==tox) && (toy==y) && (w==tx) && (h==ty);
164 bool Outside(float tx,float ty,float tw, float th)
166 return ((x+w)<tx) || ((y+h)<ty) || ((tx+tw) < x) || ((ty+th) < y);
169 unsigned int getRef(){return reference;};
170 ImageIndex getImageIndex() {
171 if (instr!=DrawImage) return 0;
172 else return target.image;
174 LoadIndex getLoadIndex() {
175 if (instr!=DrawImageLoading) return 0;
176 else return target.loadindex;
179 SVGCommandInstr instr;
182 unsigned int reference;
184 PathIndex path_index; //path_index
195 class VDR_ResponsePacket;
197 struct SurfaceCommands{
198 const SurfaceVector* surf;
199 vector<SVGCommand> commands;
204 class OsdVector : public Osd
208 virtual ~OsdVector();
215 void screenShot(const char* fileName);
216 virtual bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/)=0;
218 Surface * createNewSurface();
222 void updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width,
223 std::vector<SVGCommand>& commands);
224 void removeSurface(const SurfaceVector *surf);
226 virtual float getFontHeight()=0;
227 virtual float getCharWidth(wchar_t c)=0;
228 float *getCharWidthArray() {return byte_char_width;};
230 //virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);
231 virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia,ImageIndex& image);
232 virtual ImageIndex getMonoBitmapRef(void *base,int width,int height);
233 virtual ImageIndex getImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
234 virtual void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data)=0;
237 virtual bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length)=0;
239 void removeImageRef(const ImageIndex ref);
240 void removeLoadIndexRef(const LoadIndex ref);
241 unsigned int getStyleRef(const DrawStyle &c);
242 virtual void removeStyleRef(unsigned int ref);
243 virtual void getScreenSize(int &width, int &height)=0;
244 virtual void getRealScreenSize(int &width, int &height)=0;
246 // should be only called from command thread
247 void informPicture(LoadIndex index, ImageIndex i_index);
252 int charSet() {return 2;}; //UTF-8
255 class PictureDecoder;
271 PictureDecoder* decoder;
280 PictureDecoder(PictureReader * treader) {reader=treader;};
281 virtual ~PictureDecoder() {};
283 // its is always guaranted, that after getDecodedPicture a call to decodePicture follows, if the return value was true;
284 virtual unsigned char * decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length, bool freemem=true)=0;
286 virtual bool getDecodedPicture(struct PictureInfo& pict_inf)=0;
287 virtual void freeReference(void * ref)=0;
289 virtual void init() {};
290 virtual void shutdown() {};
293 PictureReader * reader;
296 class PictureReader: public Thread_TYPE {
302 void addDecoder(PictureDecoder*);
303 void removeDecoder(PictureDecoder*);
308 bool processReceivedPictures();
310 // should be called from command thread
311 void receivePicture(VDR_ResponsePacket *vresp);
313 void addStaticImage(unsigned int id);
315 void invalidateLoadIndex(LoadIndex index);
317 void informFallback(LoadIndex index, int fallback);
325 void threadPostStopCleanup();
327 Mutex pict_lock_incoming; //locks
329 std::queue<VDR_ResponsePacket*> pict_incoming;
330 std::queue<unsigned int> pict_incoming_static;
331 std::list<PictureDecoder*> decoders;
332 std::map<LoadIndex,int> inform_fallback;
333 set<LoadIndex> invalid_loadindex;
339 PictureReader *getPictReader() { return &reader;};
345 PictureReader reader;
347 void incImageRef(ImageIndex index);
348 int getImageRef(ImageIndex index);
349 virtual void destroyImageRef(ImageIndex index)=0;
350 void incLoadIndexRef(LoadIndex index);
351 int getLoadIndexRef(LoadIndex index);
354 //virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;
355 virtual ImageIndex createMonoBitmap(void *base,int width,int height)=0;
356 virtual ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data)=0;
357 virtual void createPicture(struct PictureInfo& pict_inf)=0;
359 virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia);
363 map<ImageIndex,int> images_ref;
364 map<void *,ImageIndex> monobitmaps;
365 //map<string,ImageIndex> jpegs;
366 map<TVMediaInfo,ImageIndex> tvmedias;
367 list<ImageIndex> palettepics;
375 map<LoadIndex,int> loadindex_ref;
376 map<TVMediaInfo,LoadIndex> tvmedias_load;
377 map<LoadIndex,TVMediaInfo> tvmedias_load_inv;
378 map<LoadIndex,ImageIndex> tvmedias_loaded;
382 void incStyleRef(unsigned int index);
383 int getStyleRef(unsigned int index);
384 virtual void destroyStyleRef(unsigned int index)=0;
387 map<DrawStyle,unsigned int> styles;
388 map<unsigned int,int> styles_ref;
389 map<DrawStyle,unsigned int>::iterator styles_lastit;
390 bool styles_lastit_valid;
391 map<unsigned int,int>::iterator styles_ref_lastit;
392 bool styles_ref_lastit_valid;
394 virtual unsigned int createStyleRef(const DrawStyle &c)=0;
396 void dereferenceSVGCommand(std::vector<SVGCommand>& commands );
397 void referenceSVGCommand(std::vector<SVGCommand>& commands );
398 void cleanupOrphanedRefs();
402 virtual void drawSetTrans(SurfaceCommands & sc)=0;
403 virtual void executeDrawCommand(SVGCommand & command)=0;
408 std::list<SurfaceCommands> scommands;
410 Mutex surfaces_mutex;
412 float byte_char_width[256];