]> git.vomp.tv Git - vompclient.git/blob - osdopenvg.h
Move Pictureading to separate thread, prepare for HW accelarated Image reading
[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         OVGcreateImageMemory
56 };
57
58 struct OpenVGCommand
59 {
60         enum OpenVGTask task;
61         const void *data;
62         const void *data2;
63         unsigned int param1,param2,param3;
64         unsigned int id; //only set an id if you are waiting
65 };
66
67 struct OpenVGResponse{
68         unsigned int id;
69         unsigned int result;
70 };
71
72
73 class OsdOpenVG : public OsdVector, public Thread_TYPE
74 {
75   public:
76     OsdOpenVG();
77     virtual ~OsdOpenVG();
78
79     int init(void* device);
80     int shutdown();
81     int stopUpdate();
82
83
84
85
86     float getFontHeight();
87     float getCharWidth(wchar_t c);
88     void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data);
89
90     int getFontNames(const char *** names,const char *** names_keys);
91
92     virtual void setFont(const char * fontname);
93
94     virtual float getPixelAspect() {return aspect_correction;};
95
96
97 protected:
98
99
100    /*osd vector implementation*/
101     void destroyImageRef(ImageIndex index);
102     ImageIndex createJpeg(const char* fileName, int *width,int *height);
103     ImageIndex createMonoBitmap(void *base,int width,int height);
104     ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
105     void createPicture(struct PictureInfo& pict_inf);
106     void destroyStyleRef(unsigned int index);
107         unsigned int createStyleRef(const DrawStyle &c);
108         unsigned int createColorRef(const Colour &c);
109
110         void drawSetTrans(SurfaceCommands & sc);
111         void executeDrawCommand(SVGCommand & command);
112
113         void initPaths();
114         void destroyPaths();
115         VGPath std_paths[Point+1];
116         long long  lastrendertime;
117         void InternalRendering();
118         void getScreenSize(int &width, int &height);
119
120
121
122         Mutex vgmutex;
123         Mutex taskmutex;
124     pthread_cond_t vgtaskCond;
125     pthread_mutex_t vgtaskCondMutex;
126     deque<OpenVGCommand> vgcommands;
127     deque<OpenVGResponse> vgresponses;
128     bool processTasks();
129     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);
130     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);
131     unsigned int handleTask(OpenVGCommand& command);
132     void purgeAllReferences();
133     unsigned int wait_id;
134
135     FT_Library  ft_library;
136     FT_Face     ft_face;
137     VGFont vgfont;
138     VGFont vgttfont;
139     VGPaint vgttpaint;
140     int  loadFont(bool fontchange);
141     map<unsigned int,float> font_exp_x;
142     vector<char*> fontnames;
143     vector<char*> fontnames_keys;
144     char * cur_fontname;
145
146     int clip_shift_x;
147     int clip_shift_y;
148
149     unsigned int loadTTchar(cTeletextChar c);
150     map<unsigned int,int> tt_font_chars;
151
152
153
154         void threadMethod();
155     void threadPostStopCleanup();
156
157
158          /* BCM specific */
159
160     uint32_t display_height;
161         uint32_t display_width;
162         DISPMANX_DISPLAY_HANDLE_T bcm_display;
163         DISPMANX_ELEMENT_HANDLE_T bcm_element;
164 //      DISPMANX_ELEMENT_HANDLE_T bcm_background;
165 //      DISPMANX_RESOURCE_HANDLE_T bcm_backres;
166
167         uint32_t mode;
168
169
170         EGLDisplay egl_display;
171         EGLSurface egl_surface;
172         EGLContext egl_context;
173         EGLConfig egl_ourconfig;
174         float font_height;
175         float aspect_correction;
176         bool freetype_inited;
177
178
179 };
180
181 #endif