]> git.vomp.tv Git - vompclient.git/blob - osdvector.h
Fixed Scaling in Jpeg handling, add Subtitles handling for HD resolutions(untested...
[vompclient.git] / osdvector.h
1 /*\r
2     Copyright 2004-2005 Chris Tallon, 2006,2011-2012 Marten Richter\r
3 \r
4     This file is part of VOMP.\r
5 \r
6     VOMP is free software; you can redistribute it and/or modify\r
7     it under the terms of the GNU General Public License as published by\r
8     the Free Software Foundation; either version 2 of the License, or\r
9     (at your option) any later version.\r
10 \r
11     VOMP is distributed in the hope that it will be useful,\r
12     but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14     GNU General Public License for more details.\r
15 \r
16     You should have received a copy of the GNU General Public License\r
17     along with VOMP; if not, write to the Free Software\r
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
19 */\r
20 \r
21 #ifndef OSDVECTOR_H\r
22 #define OSDVECTOR_H\r
23 #include "osd.h"\r
24 #include "mutex.h"\r
25 #include "colour.h"\r
26 #include <list>\r
27 #include <map>\r
28 #include <string>\r
29 \r
30 #include "teletextdecodervbiebu.h"\r
31 \r
32 enum SVGCommandInstr {\r
33         DrawPath,\r
34         DrawGlyph,\r
35         DrawImage,\r
36         DrawTTchar\r
37 };\r
38 enum PathIndex {\r
39         HorzLine,\r
40         VertLine,\r
41         Rectangle,\r
42         Point\r
43 };\r
44 \r
45 typedef  unsigned int ImageIndex;\r
46 \r
47 class SVGCommand\r
48 {\r
49 public:\r
50         SVGCommand(float ix, float iy,float iw,float ih,PathIndex path,unsigned int ref)\r
51         {\r
52                 instr=DrawPath;\r
53                 x=ix;\r
54                 y=iy;\r
55                 w=iw;\r
56                 h=ih;\r
57                 target.path_index=path;\r
58                 reference=ref;\r
59         };\r
60         SVGCommand(float ix, float iy,float iw,float ih,ImageIndex image_in,unsigned int ref)\r
61         {\r
62                 instr=DrawImage;\r
63                 x=ix;\r
64                 y=iy;\r
65                 w=iw;\r
66                 h=ih;\r
67                 target.image=image_in;\r
68                 reference=ref;\r
69         };\r
70         SVGCommand(float ix, float iy,float iw,float ih,unsigned int ttchar_in)\r
71         {\r
72                 instr=DrawTTchar;\r
73                 x=ix;\r
74                 y=iy;\r
75                 w=iw;\r
76                 h=ih;\r
77                 reference=0;\r
78                 target.ttchar=ttchar_in;\r
79         };\r
80         SVGCommand(float ix, float iy,wchar_t char_in,unsigned int ref)\r
81         {\r
82                 instr=DrawGlyph;\r
83                 x=ix;\r
84                 y=iy;\r
85                 w=0;\r
86                 h=0;\r
87                 reference=ref;\r
88                 target.textchar=char_in;\r
89         };\r
90 \r
91         bool Test(float tx,float ty,float tw, float th)\r
92         {\r
93                 return (x>=tx) && (y>=ty) && ((x+w)<=(tx+tw)) && ((y+h)<=(ty+th));\r
94         }\r
95         bool TTTest(float tox,float toy,float tx, float ty)\r
96         {\r
97                 return (x==tox) && (toy==y) && (w==tx) && (h==ty);\r
98         }\r
99         unsigned int getRef(){return reference;};\r
100         ImageIndex getImageIndex() {\r
101                 if (instr!=DrawImage) return 0;\r
102                 else return target.image;\r
103         };\r
104         SVGCommandInstr instr;\r
105         float x,y,w,h;\r
106         unsigned int reference;\r
107         union {\r
108                 PathIndex path_index; //path_index\r
109                 wchar_t textchar;\r
110                 ImageIndex image;\r
111                 unsigned int ttchar;\r
112         } target;\r
113 };\r
114 \r
115 class SurfaceVector;\r
116 \r
117 struct SurfaceCommands{\r
118         const SurfaceVector* surf;\r
119         list<SVGCommand> commands;\r
120         float x,y,w,h;\r
121 };\r
122 \r
123 \r
124 class OsdVector : public Osd\r
125 {\r
126   public:\r
127     OsdVector();\r
128     virtual ~OsdVector();\r
129 \r
130 \r
131     int getFD();\r
132 \r
133     void screenShot(const char* fileName);\r
134 \r
135     Surface * createNewSurface();\r
136         void BeginPainting();\r
137         void EndPainting();\r
138 \r
139         void Blank();\r
140 \r
141         void updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width,\r
142                         list<SVGCommand>& commands);\r
143         void removeSurface(const SurfaceVector *surf);\r
144 \r
145         virtual float getFontHeight()=0;\r
146         virtual float getCharWidth(wchar_t c)=0;\r
147 \r
148         virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);\r
149         virtual ImageIndex getMonoBitmapRef(void *base,int width,int height);\r
150         virtual ImageIndex getImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);\r
151         virtual void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data)=0;\r
152         void removeImageRef(const ImageIndex ref);\r
153         unsigned int getColorRef(const Colour &c); //internally this is the same as getStyleRef\r
154         unsigned int getStyleRef(const DrawStyle &c);\r
155         virtual void removeStyleRef(unsigned int ref);\r
156 \r
157 \r
158     int charSet() {return 2;}; //UTF-8\r
159 \r
160 \r
161 \r
162 protected:\r
163 \r
164         void incImageRef(ImageIndex index);\r
165         unsigned int getImageRef(ImageIndex index);\r
166         virtual void destroyImageRef(ImageIndex index)=0;\r
167         virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;\r
168         virtual ImageIndex createMonoBitmap(void *base,int width,int height)=0;\r
169         virtual ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data)=0;\r
170 \r
171         map<ImageIndex,unsigned int> images_ref;\r
172         map<void *,ImageIndex> monobitmaps;\r
173         map<string,ImageIndex> jpegs;\r
174 \r
175         void incStyleRef(unsigned int index);\r
176         unsigned int getStyleRef(ImageIndex index);\r
177         virtual void destroyStyleRef(unsigned int index)=0;\r
178         map<pair<Colour*,unsigned int>,unsigned int> styles;\r
179         map<unsigned int,unsigned int> styles_ref;\r
180         virtual unsigned int createStyleRef(const DrawStyle &c)=0;\r
181         virtual unsigned int createColorRef(const Colour &c)=0;\r
182 \r
183         void dereferenceSVGCommand(list<SVGCommand>& commands );\r
184         void referenceSVGCommand(list<SVGCommand>& commands );\r
185         void cleanupOrphanedRefs();\r
186 \r
187 \r
188 \r
189         virtual void drawSetTrans(SurfaceCommands & sc)=0;\r
190         virtual void executeDrawCommand(SVGCommand & command)=0;\r
191 \r
192 \r
193 \r
194 \r
195         list<SurfaceCommands> scommands;\r
196 \r
197         Mutex surfaces_mutex;\r
198 \r
199         void drawSurfaces();\r
200 };\r
201 \r
202 \r
203 \r
204 \r
205 #endif\r