]> git.vomp.tv Git - vompclient.git/blob - osdopenvg.h
Preparations for dynamic mode switching
[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     int stopUpdate();\r
80 \r
81 \r
82 \r
83 \r
84     float getFontHeight();\r
85     float getCharWidth(wchar_t c);\r
86     void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data);\r
87 \r
88 \r
89 protected:\r
90    /*osd vector implementation*/\r
91     void destroyImageRef(ImageIndex index);\r
92     ImageIndex createJpeg(const char* fileName, int *width,int *height);\r
93     ImageIndex createMonoBitmap(void *base,int width,int height);\r
94     ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);\r
95     void destroyStyleRef(unsigned int index);\r
96         unsigned int createStyleRef(const DrawStyle &c);\r
97         unsigned int createColorRef(const Colour &c);\r
98 \r
99         void drawSetTrans(SurfaceCommands & sc);\r
100         void executeDrawCommand(SVGCommand & command);\r
101 \r
102         void initPaths();\r
103         void destroyPaths();\r
104         VGPath std_paths[Point+1];\r
105         long long  lastrendertime;\r
106         void InternalRendering();\r
107 \r
108 \r
109 \r
110         Mutex vgmutex;\r
111         Mutex taskmutex;\r
112     pthread_cond_t vgtaskCond;\r
113     pthread_mutex_t vgtaskCondMutex;\r
114     deque<OpenVGCommand> vgcommands;\r
115     deque<OpenVGResponse> vgresponses;\r
116     bool processTasks();\r
117     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);\r
118     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);\r
119     unsigned int handleTask(OpenVGCommand& command);\r
120     unsigned int wait_id;\r
121 \r
122     FT_Library  ft_library;\r
123     FT_Face     ft_face;\r
124     VGFont vgfont;\r
125     VGFont vgttfont;\r
126     VGPaint vgttpaint;\r
127     int  loadFont();\r
128     map<unsigned int,float> font_exp_x;\r
129 \r
130     unsigned int loadTTchar(cTeletextChar c);\r
131     map<unsigned int,int> tt_font_chars;\r
132 \r
133 \r
134 \r
135         void threadMethod();\r
136     void threadPostStopCleanup();\r
137 \r
138 \r
139          /* BCM specific */\r
140 \r
141     uint32_t display_height;\r
142         uint32_t display_width;\r
143         DISPMANX_DISPLAY_HANDLE_T bcm_display;\r
144         DISPMANX_ELEMENT_HANDLE_T bcm_element;\r
145 //      DISPMANX_ELEMENT_HANDLE_T bcm_background;\r
146 //      DISPMANX_RESOURCE_HANDLE_T bcm_backres;\r
147 \r
148         uint32_t mode;\r
149 \r
150 \r
151         EGLDisplay egl_display;\r
152         EGLSurface egl_surface;\r
153         EGLContext egl_context;\r
154         EGLConfig egl_ourconfig;\r
155         float font_height;\r
156         float aspect_correction;\r
157         bool freetype_inited;\r
158 \r
159 \r
160 };\r
161 \r
162 #endif\r