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;
266 PictureDecoder* decoder;
275 PictureDecoder(PictureReader * treader) {reader=treader;};
276 virtual ~PictureDecoder() {};
278 // its is always guaranted, that after getDecodedPicture a call to decodePicture follows, if the return value was true;
279 virtual bool decodePicture(LoadIndex index, unsigned char * buffer, unsigned int length)=0;
281 virtual bool getDecodedPicture(struct PictureInfo& pict_inf)=0;
282 virtual void freeReference(void * ref)=0;
284 virtual void init() {};
285 virtual void shutdown() {};
288 PictureReader * reader;
291 class PictureReader: public Thread_TYPE {
297 void addDecoder(PictureDecoder*);
298 void removeDecoder(PictureDecoder*);
303 bool processReceivedPictures();
305 // should be called from command thread
306 void receivePicture(VDR_ResponsePacket *vresp);
308 void invalidateLoadIndex(LoadIndex index);
316 void threadPostStopCleanup();
318 Mutex pict_lock_incoming; //locks
320 std::queue<VDR_ResponsePacket*> pict_incoming;
321 std::list<PictureDecoder*> decoders;
322 set<LoadIndex> invalid_loadindex;
328 PictureReader *getPictReader() { return &reader;};
334 PictureReader reader;
336 void incImageRef(ImageIndex index);
337 int getImageRef(ImageIndex index);
338 virtual void destroyImageRef(ImageIndex index)=0;
339 void incLoadIndexRef(LoadIndex index);
340 int getLoadIndexRef(LoadIndex index);
343 virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;
344 virtual ImageIndex createMonoBitmap(void *base,int width,int height)=0;
345 virtual ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data)=0;
346 virtual void createPicture(struct PictureInfo& pict_inf)=0;
348 virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia);
352 map<ImageIndex,int> images_ref;
353 map<void *,ImageIndex> monobitmaps;
354 map<string,ImageIndex> jpegs;
355 map<TVMediaInfo,ImageIndex> tvmedias;
363 map<LoadIndex,int> loadindex_ref;
364 map<TVMediaInfo,LoadIndex> tvmedias_load;
365 map<LoadIndex,TVMediaInfo> tvmedias_load_inv;
366 map<LoadIndex,ImageIndex> tvmedias_loaded;
370 void incStyleRef(unsigned int index);
371 int getStyleRef(ImageIndex index);
372 virtual void destroyStyleRef(unsigned int index)=0;
373 map<pair<Colour*,unsigned int>,unsigned int> styles;
374 map<unsigned int,int> styles_ref;
375 virtual unsigned int createStyleRef(const DrawStyle &c)=0;
376 virtual unsigned int createColorRef(const Colour &c)=0;
378 void dereferenceSVGCommand(list<SVGCommand>& commands );
379 void referenceSVGCommand(list<SVGCommand>& commands );
380 void cleanupOrphanedRefs();
384 virtual void drawSetTrans(SurfaceCommands & sc)=0;
385 virtual void executeDrawCommand(SVGCommand & command)=0;
390 list<SurfaceCommands> scommands;
392 Mutex surfaces_mutex;