]> git.vomp.tv Git - vompclient.git/blob - osdopenvg.h
Switch to OpenVG based OSD, note Teletext and Subtitle rendering not working and...
[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         OVGcreateImageRGBA,\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         unsigned int param1,param2,param3;\r
61         unsigned int id; //only set an id if you are waiting\r
62 };\r
63 \r
64 struct OpenVGResponse{\r
65         unsigned int id;\r
66         unsigned int result;\r
67 };\r
68 \r
69 \r
70 class OsdOpenVG : public OsdVector, public Thread_TYPE\r
71 {\r
72   public:\r
73     OsdOpenVG();\r
74     virtual ~OsdOpenVG();\r
75 \r
76     int init(void* device);\r
77     int shutdown();\r
78 \r
79 \r
80     float getFontHeight();\r
81     float getCharWidth(wchar_t c);\r
82     void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data);\r
83 \r
84 \r
85 protected:\r
86    /*osd vector implementation*/\r
87     void destroyImageRef(ImageIndex index);\r
88     ImageIndex createJpeg(const char* fileName, int *width,int *height);\r
89     ImageIndex createMonoBitmap(void *base,int width,int height);\r
90     ImageIndex createImageRGBA(int width,int height);\r
91     void destroyStyleRef(unsigned int index);\r
92         unsigned int createStyleRef(const DrawStyle &c);\r
93         unsigned int createColorRef(const Colour &c);\r
94 \r
95         void drawSetTrans(SurfaceCommands & sc);\r
96         void executeDrawCommand(SVGCommand & command);\r
97 \r
98         void initPaths();\r
99         void destroyPaths();\r
100         VGPath std_paths[Point+1];\r
101         long long  lastrendertime;\r
102         void InternalRendering();\r
103 \r
104 \r
105 \r
106         Mutex vgmutex;\r
107         Mutex taskmutex;\r
108     pthread_cond_t vgtaskCond;\r
109     pthread_mutex_t vgtaskCondMutex;\r
110     deque<OpenVGCommand> vgcommands;\r
111     deque<OpenVGResponse> vgresponses;\r
112     bool processTasks();\r
113     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);\r
114     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);\r
115     unsigned int handleTask(OpenVGCommand& command);\r
116     unsigned int wait_id;\r
117 \r
118     FT_Library  ft_library;\r
119     FT_Face     ft_face;\r
120     VGFont vgfont;\r
121     int  loadFont();\r
122     map<unsigned int,float> font_exp_x;\r
123 \r
124 \r
125 \r
126         void threadMethod();\r
127     void threadPostStopCleanup();\r
128 \r
129 \r
130          /* BCM specific */\r
131 \r
132     uint32_t display_height;\r
133         uint32_t display_width;\r
134         DISPMANX_DISPLAY_HANDLE_T bcm_display;\r
135         DISPMANX_ELEMENT_HANDLE_T bcm_element;\r
136         DISPMANX_ELEMENT_HANDLE_T bcm_background;\r
137         DISPMANX_RESOURCE_HANDLE_T bcm_backres;\r
138 \r
139         uint32_t mode;\r
140 \r
141 \r
142         EGLDisplay egl_display;\r
143         EGLSurface egl_surface;\r
144         EGLContext egl_context;\r
145         EGLConfig egl_ourconfig;\r
146         float font_height;\r
147         float aspect_correction;\r
148 \r
149 \r
150 };\r
151 \r
152 #endif\r