]> git.vomp.tv Git - vompclient.git/blob - osdopenvg.h
Merge branch 'master' of ssh://git.vomp.tv:20022/vompclient into scraper_support
[vompclient.git] / osdopenvg.h
1 /*
2     Copyright 2004-2005 Chris Tallon, 2006,2011-2012 Marten Richter
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef OSDOPENVG_H
22 #define OSDOPENVG_H
23
24 #include <stdio.h>
25
26
27 #include <EGL/egl.h>
28 #include <EGL/eglext.h>
29 #include <VG/openvg.h>
30 #include <VG/vgu.h>
31
32
33
34 #include "osdvector.h"
35 #include "defines.h"
36 #include "log.h"
37 #include "threadp.h"
38 #include "mutex.h"
39 #include "videoomx.h"
40
41 #include <deque>
42
43 #include <ft2build.h>
44 #include FT_FREETYPE_H
45
46 enum OpenVGTask {
47         OVGdestroyImageRef,
48         OVGdestroyPaint,
49         OVGcreateImagePalette,
50         OVGcreateMonoBitmap,
51         OVGcreateColorRef,
52         OVGimageUploadLine,
53         OVGcreateImageFile,
54         OVGreplacefont
55 };
56
57 struct OpenVGCommand
58 {
59         enum OpenVGTask task;
60         const void *data;
61         const void *data2;
62         unsigned int param1,param2,param3;
63         unsigned int id; //only set an id if you are waiting
64 };
65
66 struct OpenVGResponse{
67         unsigned int id;
68         unsigned int result;
69 };
70
71
72 class OsdOpenVG : public OsdVector, public Thread_TYPE
73 {
74   public:
75     OsdOpenVG();
76     virtual ~OsdOpenVG();
77
78     int init(void* device);
79     int shutdown();
80     int stopUpdate();
81
82
83
84
85     float getFontHeight();
86     float getCharWidth(wchar_t c);
87     void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data);
88
89     int getFontNames(const char *** names,const char *** names_keys);
90
91     virtual void setFont(const char * fontname);
92
93     virtual float getPixelAspect() {return aspect_correction;};
94
95
96 protected:
97    /*osd vector implementation*/
98     void destroyImageRef(ImageIndex index);
99     ImageIndex createJpeg(const char* fileName, int *width,int *height);
100     ImageIndex createMonoBitmap(void *base,int width,int height);
101     ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
102     ImageIndex createPicture(unsigned char *data, unsigned int length);
103     void destroyStyleRef(unsigned int index);
104         unsigned int createStyleRef(const DrawStyle &c);
105         unsigned int createColorRef(const Colour &c);
106
107         void drawSetTrans(SurfaceCommands & sc);
108         void executeDrawCommand(SVGCommand & command);
109
110         void initPaths();
111         void destroyPaths();
112         VGPath std_paths[Point+1];
113         long long  lastrendertime;
114         void InternalRendering();
115         void getScreenSize(int &width, int &height);
116
117
118
119         Mutex vgmutex;
120         Mutex taskmutex;
121     pthread_cond_t vgtaskCond;
122     pthread_mutex_t vgtaskCondMutex;
123     deque<OpenVGCommand> vgcommands;
124     deque<OpenVGResponse> vgresponses;
125     bool processTasks();
126     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);
127     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);
128     unsigned int handleTask(OpenVGCommand& command);
129     void purgeAllReferences();
130     unsigned int wait_id;
131
132     FT_Library  ft_library;
133     FT_Face     ft_face;
134     VGFont vgfont;
135     VGFont vgttfont;
136     VGPaint vgttpaint;
137     int  loadFont(bool fontchange);
138     map<unsigned int,float> font_exp_x;
139     vector<char*> fontnames;
140     vector<char*> fontnames_keys;
141     char * cur_fontname;
142
143     int clip_shift_x;
144     int clip_shift_y;
145
146     unsigned int loadTTchar(cTeletextChar c);
147     map<unsigned int,int> tt_font_chars;
148
149
150
151         void threadMethod();
152     void threadPostStopCleanup();
153
154
155          /* BCM specific */
156
157     uint32_t display_height;
158         uint32_t display_width;
159         DISPMANX_DISPLAY_HANDLE_T bcm_display;
160         DISPMANX_ELEMENT_HANDLE_T bcm_element;
161 //      DISPMANX_ELEMENT_HANDLE_T bcm_background;
162 //      DISPMANX_RESOURCE_HANDLE_T bcm_backres;
163
164         uint32_t mode;
165
166
167         EGLDisplay egl_display;
168         EGLSurface egl_surface;
169         EGLContext egl_context;
170         EGLConfig egl_ourconfig;
171         float font_height;
172         float aspect_correction;
173         bool freetype_inited;
174
175
176 };
177
178 #endif