]> git.vomp.tv Git - vompclient.git/blob - osdopenvg.h
Remove thread from videoomx, Code cleanup, Fix remote keys (could crash server!).
[vompclient.git] / osdopenvg.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 OSDOPENVG_H\r
22 #define OSDOPENVG_H\r
23 \r
24 #include <stdio.h>\r
25 \r
26 \r
27 #include <EGL/egl.h>\r
28 #include <EGL/eglext.h>\r
29 #include <VG/openvg.h>\r
30 #include <VG/vgu.h>\r
31 \r
32 \r
33 \r
34 #include "osdvector.h"\r
35 #include "defines.h"\r
36 #include "log.h"\r
37 #include "threadp.h"\r
38 #include "mutex.h"\r
39 #include "videoomx.h"\r
40 \r
41 #include <deque>\r
42 \r
43 #include <ft2build.h>\r
44 #include FT_FREETYPE_H\r
45 \r
46 enum OpenVGTask {\r
47         OVGdestroyImageRef,\r
48         OVGdestroyPaint,\r
49         OVGcreateImagePalette,\r
50         OVGcreateMonoBitmap,\r
51         OVGcreateColorRef,\r
52         OVGimageUploadLine,\r
53         OVGcreateImageFile\r
54 };\r
55 \r
56 struct OpenVGCommand\r
57 {\r
58         enum OpenVGTask task;\r
59         const void *data;\r
60         const void *data2;\r
61         unsigned int param1,param2,param3;\r
62         unsigned int id; //only set an id if you are waiting\r
63 };\r
64 \r
65 struct OpenVGResponse{\r
66         unsigned int id;\r
67         unsigned int result;\r
68 };\r
69 \r
70 \r
71 class OsdOpenVG : public OsdVector, public Thread_TYPE\r
72 {\r
73   public:\r
74     OsdOpenVG();\r
75     virtual ~OsdOpenVG();\r
76 \r
77     int init(void* device);\r
78     int shutdown();\r
79 \r
80 \r
81     float getFontHeight();\r
82     float getCharWidth(wchar_t c);\r
83     void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data);\r
84 \r
85 \r
86 protected:\r
87    /*osd vector implementation*/\r
88     void destroyImageRef(ImageIndex index);\r
89     ImageIndex createJpeg(const char* fileName, int *width,int *height);\r
90     ImageIndex createMonoBitmap(void *base,int width,int height);\r
91     ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);\r
92     void destroyStyleRef(unsigned int index);\r
93         unsigned int createStyleRef(const DrawStyle &c);\r
94         unsigned int createColorRef(const Colour &c);\r
95 \r
96         void drawSetTrans(SurfaceCommands & sc);\r
97         void executeDrawCommand(SVGCommand & command);\r
98 \r
99         void initPaths();\r
100         void destroyPaths();\r
101         VGPath std_paths[Point+1];\r
102         long long  lastrendertime;\r
103         void InternalRendering();\r
104 \r
105 \r
106 \r
107         Mutex vgmutex;\r
108         Mutex taskmutex;\r
109     pthread_cond_t vgtaskCond;\r
110     pthread_mutex_t vgtaskCondMutex;\r
111     deque<OpenVGCommand> vgcommands;\r
112     deque<OpenVGResponse> vgresponses;\r
113     bool processTasks();\r
114     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);\r
115     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);\r
116     unsigned int handleTask(OpenVGCommand& command);\r
117     unsigned int wait_id;\r
118 \r
119     FT_Library  ft_library;\r
120     FT_Face     ft_face;\r
121     VGFont vgfont;\r
122     VGFont vgttfont;\r
123     VGPaint vgttpaint;\r
124     int  loadFont();\r
125     map<unsigned int,float> font_exp_x;\r
126 \r
127     unsigned int loadTTchar(cTeletextChar c);\r
128     map<unsigned int,int> tt_font_chars;\r
129 \r
130 \r
131 \r
132         void threadMethod();\r
133     void threadPostStopCleanup();\r
134 \r
135 \r
136          /* BCM specific */\r
137 \r
138     uint32_t display_height;\r
139         uint32_t display_width;\r
140         DISPMANX_DISPLAY_HANDLE_T bcm_display;\r
141         DISPMANX_ELEMENT_HANDLE_T bcm_element;\r
142 //      DISPMANX_ELEMENT_HANDLE_T bcm_background;\r
143 //      DISPMANX_RESOURCE_HANDLE_T bcm_backres;\r
144 \r
145         uint32_t mode;\r
146 \r
147 \r
148         EGLDisplay egl_display;\r
149         EGLSurface egl_surface;\r
150         EGLContext egl_context;\r
151         EGLConfig egl_ourconfig;\r
152         float font_height;\r
153         float aspect_correction;\r
154 \r
155 \r
156 };\r
157 \r
158 #endif\r