]> git.vomp.tv Git - vompclient.git/blob - osdvector.h
Switch to OpenVG based OSD, note Teletext and Subtitle rendering not working and...
[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         unsigned int getRef(){return reference;};\r
96         ImageIndex getImageIndex() {\r
97                 if (instr!=DrawImage) return 0;\r
98                 else return target.image;\r
99         };\r
100         SVGCommandInstr instr;\r
101         float x,y,w,h;\r
102         unsigned int reference;\r
103         union {\r
104                 PathIndex path_index; //path_index\r
105                 wchar_t textchar;\r
106                 ImageIndex image;\r
107                 unsigned int ttchar;\r
108         } target;\r
109 };\r
110 \r
111 class SurfaceVector;\r
112 \r
113 struct SurfaceCommands{\r
114         const SurfaceVector* surf;\r
115         list<SVGCommand> commands;\r
116         float x,y,w,h;\r
117 };\r
118 \r
119 \r
120 class OsdVector : public Osd\r
121 {\r
122   public:\r
123     OsdVector();\r
124     virtual ~OsdVector();\r
125 \r
126 \r
127     int getFD();\r
128 \r
129     void screenShot(const char* fileName);\r
130 \r
131     Surface * createNewSurface();\r
132         void BeginPainting();\r
133         void EndPainting();\r
134 \r
135         void Blank();\r
136 \r
137         void updateOrAddSurface(const SurfaceVector *surf,float x,float y,float height,float width,\r
138                         list<SVGCommand>& commands);\r
139         void removeSurface(const SurfaceVector *surf);\r
140 \r
141         virtual float getFontHeight()=0;\r
142         virtual float getCharWidth(wchar_t c)=0;\r
143 \r
144         virtual ImageIndex getJpegRef(const char* fileName, int *width,int *height);\r
145         virtual ImageIndex getMonoBitmapRef(void *base,int width,int height);\r
146         virtual ImageIndex getImageRGBA(int width,int height);\r
147         virtual void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data)=0;\r
148         void removeImageRef(const ImageIndex ref);\r
149         unsigned int getColorRef(const Colour &c); //internally this is the same as getStyleRef\r
150         unsigned int getStyleRef(const DrawStyle &c);\r
151         virtual void removeStyleRef(unsigned int ref);\r
152 \r
153 \r
154     int charSet() {return 2;}; //UTF-8\r
155 \r
156 \r
157 \r
158 protected:\r
159 \r
160         void incImageRef(ImageIndex index);\r
161         unsigned int getImageRef(ImageIndex index);\r
162         virtual void destroyImageRef(ImageIndex index)=0;\r
163         virtual ImageIndex createJpeg(const char* fileName, int *width,int *height)=0;\r
164         virtual ImageIndex createMonoBitmap(void *base,int width,int height)=0;\r
165         virtual ImageIndex createImageRGBA(int width,int height)=0;\r
166 \r
167         map<ImageIndex,unsigned int> images_ref;\r
168         map<void *,ImageIndex> monobitmaps;\r
169         map<string,ImageIndex> jpegs;\r
170 \r
171         void incStyleRef(unsigned int index);\r
172         unsigned int getStyleRef(ImageIndex index);\r
173         virtual void destroyStyleRef(unsigned int index)=0;\r
174         map<pair<Colour*,unsigned int>,unsigned int> styles;\r
175         map<unsigned int,unsigned int> styles_ref;\r
176         virtual unsigned int createStyleRef(const DrawStyle &c)=0;\r
177         virtual unsigned int createColorRef(const Colour &c)=0;\r
178 \r
179         void dereferenceSVGCommand(list<SVGCommand>& commands );\r
180         void referenceSVGCommand(list<SVGCommand>& commands );\r
181         void cleanupOrphanedRefs();\r
182 \r
183 \r
184 \r
185         virtual void drawSetTrans(SurfaceCommands & sc)=0;\r
186         virtual void executeDrawCommand(SVGCommand & command)=0;\r
187 \r
188 \r
189 \r
190 \r
191         list<SurfaceCommands> scommands;\r
192 \r
193         Mutex surfaces_mutex;\r
194 \r
195         void drawSurfaces();\r
196 };\r
197 \r
198 \r
199 \r
200 \r
201 #endif\r