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.
34 #include "teletextdecodervbiebu.h"
36 enum SVGCommandInstr {
61 typedef unsigned int ImageIndex;
62 typedef unsigned int LoadIndex;
73 static SVGCommand PaintPath(float ix, float iy,float iw,float ih,PathIndex path,unsigned int ref)
81 nc.target.path_index=path;
86 static SVGCommand PaintImageLoading(LoadIndex load_in,float ix, float iy,float iw,float ih,unsigned int ref, Corner corner=TopLeft)
89 nc.instr=DrawImageLoading;
94 nc.target.loadindex=load_in;
100 static SVGCommand PaintImage(float ix, float iy,float iw,float ih,ImageIndex image_in,unsigned int ref, Corner corner=TopLeft)
108 nc.target.image=image_in;
116 static SVGCommand PaintTTchar(float ix, float iy,float iw,float ih,unsigned int ttchar_in)
125 nc.target.ttchar=ttchar_in;
129 static SVGCommand PaintClipping(float ix, float iy,float iw,float ih)
132 nc.instr=DrawClipping;
143 static SVGCommand PaintGlyph(float ix, float iy,wchar_t char_in,unsigned int ref)
152 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 ImageIndex getLoadIndex() {
175 if (instr!=DrawImageLoading) return 0;
176 else return target.loadindex;
179 SVGCommandInstr instr;
181 unsigned int reference;
183 PathIndex path_index; //path_index
194 class VDR_ResponsePacket;
196 struct SurfaceCommands{
197 const SurfaceVector* surf;
198 list<SVGCommand> commands;
203 class OsdVector : public Osd
207 virtual ~OsdVector();
214 void screenShot(const char* fileName);
216 Surface * createNewSurface();
217 void BeginPainting();
222 void updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width,
223 list<SVGCommand>& commands);
224 void removeSurface(const SurfaceVector *surf);
226 virtual float getFontHeight()=0;
227 virtual float getCharWidth(wchar_t c)=0;
229 virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);
230 virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia,ImageIndex& image);
231 virtual ImageIndex getMonoBitmapRef(void *base,int width,int height);
232 virtual ImageIndex getImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
233 virtual void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data)=0;
234 void removeImageRef(const ImageIndex ref);
235 void removeLoadIndexRef(const LoadIndex ref);
236 unsigned int getColorRef(const Colour &c); //internally this is the same as getStyleRef
237 unsigned int getStyleRef(const DrawStyle &c);
238 virtual void removeStyleRef(unsigned int ref);
239 virtual void getScreenSize(int &width, int &height)=0;
241 // should be only called from command thread
242 void informPicture(LoadIndex index, ImageIndex i_index);
247 int charSet() {return 2;}; //UTF-8
250 class PictureDecoder;
263 PictureDecoder* decoder;
272 PictureDecoder(PictureReader * treader) {reader=treader;};
274 // its is always guaranted, that after getDecodedPicture a call to decodePicture follows, if the return value was true;
275 virtual bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length)=0;
277 virtual bool getDecodedPicture(struct PictureInfo& pict_inf)=0;
278 virtual void freeReference(void * ref)=0;
281 PictureReader * reader;
284 class PictureReader: public Thread_TYPE {
290 void addDecoder(PictureDecoder*);
295 bool processReceivedPictures();
297 // should be called from command thread
298 void receivePicture(VDR_ResponsePacket *vresp);
300 void invalidateLoadIndex(LoadIndex index);
308 void threadPostStopCleanup();
310 Mutex pict_lock_incoming; //locks
312 std::queue<VDR_ResponsePacket*> pict_incoming;
313 std::list<PictureDecoder*> decoders;
314 set<LoadIndex> invalid_loadindex;
320 PictureReader *getPictReader() { return &reader;};
326 PictureReader reader;
328 void incImageRef(ImageIndex index);
329 int getImageRef(ImageIndex index);
330 virtual void destroyImageRef(ImageIndex index)=0;
331 void incLoadIndexRef(LoadIndex index);
332 int getLoadIndexRef(LoadIndex index);
335 virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;
336 virtual ImageIndex createMonoBitmap(void *base,int width,int height)=0;
337 virtual ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data)=0;
338 virtual void createPicture(struct PictureInfo& pict_inf)=0;
340 virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia);
344 map<ImageIndex,int> images_ref;
345 map<void *,ImageIndex> monobitmaps;
346 map<string,ImageIndex> jpegs;
347 map<TVMediaInfo,ImageIndex> tvmedias;
355 map<LoadIndex,int> loadindex_ref;
356 map<TVMediaInfo,LoadIndex> tvmedias_load;
357 map<LoadIndex,TVMediaInfo> tvmedias_load_inv;
358 map<LoadIndex,ImageIndex> tvmedias_loaded;
362 void incStyleRef(unsigned int index);
363 int getStyleRef(ImageIndex index);
364 virtual void destroyStyleRef(unsigned int index)=0;
365 map<pair<Colour*,unsigned int>,unsigned int> styles;
366 map<unsigned int,int> styles_ref;
367 virtual unsigned int createStyleRef(const DrawStyle &c)=0;
368 virtual unsigned int createColorRef(const Colour &c)=0;
370 void dereferenceSVGCommand(list<SVGCommand>& commands );
371 void referenceSVGCommand(list<SVGCommand>& commands );
372 void cleanupOrphanedRefs();
376 virtual void drawSetTrans(SurfaceCommands & sc)=0;
377 virtual void executeDrawCommand(SVGCommand & command)=0;
382 list<SurfaceCommands> scommands;
384 Mutex surfaces_mutex;