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.
33 #include "teletextdecodervbiebu.h"
35 enum SVGCommandInstr {
60 typedef unsigned int ImageIndex;
61 typedef unsigned int LoadIndex;
72 static SVGCommand PaintPath(float ix, float iy,float iw,float ih,PathIndex path,unsigned int ref)
80 nc.target.path_index=path;
85 static SVGCommand PaintImageLoading(LoadIndex load_in,float ix, float iy,float iw,float ih,unsigned int ref, Corner corner=TopLeft)
88 nc.instr=DrawImageLoading;
93 nc.target.loadindex=load_in;
99 static SVGCommand PaintImage(float ix, float iy,float iw,float ih,ImageIndex image_in,unsigned int ref, Corner corner=TopLeft)
107 nc.target.image=image_in;
115 static SVGCommand PaintTTchar(float ix, float iy,float iw,float ih,unsigned int ttchar_in)
124 nc.target.ttchar=ttchar_in;
128 static SVGCommand PaintClipping(float ix, float iy,float iw,float ih)
131 nc.instr=DrawClipping;
142 static SVGCommand PaintGlyph(float ix, float iy,wchar_t char_in,unsigned int ref)
151 nc.target.textchar=char_in;
155 bool Test(float tx,float ty,float tw, float th)
157 return (x>=tx) && (y>=ty) && ((x+w)<=(tx+tw)) && ((y+h)<=(ty+th));
159 bool TTTest(float tox,float toy,float tx, float ty)
161 return (x==tox) && (toy==y) && (w==tx) && (h==ty);
163 bool Outside(float tx,float ty,float tw, float th)
165 return ((x+w)<tx) || ((y+h)<ty) || ((tx+tw) < x) || ((ty+th) < y);
168 unsigned int getRef(){return reference;};
169 ImageIndex getImageIndex() {
170 if (instr!=DrawImage) return 0;
171 else return target.image;
173 ImageIndex getLoadIndex() {
174 if (instr!=DrawImageLoading) return 0;
175 else return target.loadindex;
178 SVGCommandInstr instr;
180 unsigned int reference;
182 PathIndex path_index; //path_index
193 class VDR_ResponsePacket;
195 struct SurfaceCommands{
196 const SurfaceVector* surf;
197 list<SVGCommand> commands;
202 class OsdVector : public Osd
206 virtual ~OsdVector();
213 void screenShot(const char* fileName);
215 Surface * createNewSurface();
216 void BeginPainting();
221 void updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width,
222 list<SVGCommand>& commands);
223 void removeSurface(const SurfaceVector *surf);
225 virtual float getFontHeight()=0;
226 virtual float getCharWidth(wchar_t c)=0;
228 virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);
229 virtual LoadIndex getTVMediaRef(TVMediaInfo& tvmedia,ImageIndex& image);
230 virtual ImageIndex getMonoBitmapRef(void *base,int width,int height);
231 virtual ImageIndex getImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
232 virtual void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data)=0;
233 void removeImageRef(const ImageIndex ref);
234 void removeLoadIndexRef(const LoadIndex ref);
235 unsigned int getColorRef(const Colour &c); //internally this is the same as getStyleRef
236 unsigned int getStyleRef(const DrawStyle &c);
237 virtual void removeStyleRef(unsigned int ref);
238 virtual void getScreenSize(int &width, int &height)=0;
240 // should be called from command thread
241 bool processReceivedPictures();
243 void receivePicture(VDR_ResponsePacket *vresp);
246 int charSet() {return 2;}; //UTF-8
252 void incImageRef(ImageIndex index);
253 unsigned int getImageRef(ImageIndex index);
254 virtual void destroyImageRef(ImageIndex index)=0;
255 void incLoadIndexRef(LoadIndex index);
256 unsigned int getLoadIndexRef(LoadIndex index);
259 virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;
260 virtual ImageIndex createMonoBitmap(void *base,int width,int height)=0;
261 virtual ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data)=0;
262 virtual ImageIndex createPicture(unsigned char *data, unsigned int length)=0;
264 virtual LoadIndex loadTVMedia(TVMediaInfo& tvmedia);
268 map<ImageIndex,unsigned int> images_ref;
269 map<void *,ImageIndex> monobitmaps;
270 map<string,ImageIndex> jpegs;
271 map<TVMediaInfo,ImageIndex> tvmedias;
275 void setTVMedia(LoadIndex index, unsigned char * buffer, unsigned int length);
276 Mutex pict_lock_incoming; //locks
277 std::queue<VDR_ResponsePacket*> pict_incoming;
281 map<LoadIndex,unsigned int> loadindex_ref;
282 map<TVMediaInfo,LoadIndex> tvmedias_load;
283 map<LoadIndex,TVMediaInfo> tvmedias_load_inv;
284 map<LoadIndex,ImageIndex> tvmedias_loaded;
286 void incStyleRef(unsigned int index);
287 unsigned int getStyleRef(ImageIndex index);
288 virtual void destroyStyleRef(unsigned int index)=0;
289 map<pair<Colour*,unsigned int>,unsigned int> styles;
290 map<unsigned int,unsigned int> styles_ref;
291 virtual unsigned int createStyleRef(const DrawStyle &c)=0;
292 virtual unsigned int createColorRef(const Colour &c)=0;
294 void dereferenceSVGCommand(list<SVGCommand>& commands );
295 void referenceSVGCommand(list<SVGCommand>& commands );
296 void cleanupOrphanedRefs();
300 virtual void drawSetTrans(SurfaceCommands & sc)=0;
301 virtual void executeDrawCommand(SVGCommand & command)=0;
306 list<SurfaceCommands> scommands;
308 Mutex surfaces_mutex;