]> git.vomp.tv Git - vompclient.git/blob - osdopenvg.h
More compiler warning fixes
[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 "signal.h"
40 #include "videoomx.h"
41 #include "staticartwork.h"
42 #ifdef PICTURE_DECODER_OMX
43 #include "imageomx.h"
44 #endif
45
46 #include <deque>
47
48 #include <ft2build.h>
49 #include FT_FREETYPE_H
50
51 enum OpenVGTask {
52         OVGdestroyImageRef,
53         OVGdestroyPaint,
54         OVGcreateImagePalette,
55         OVGcreateMonoBitmap,
56         OVGcreateColorRef,
57         OVGimageUploadLine,
58         //OVGcreateImageFile,
59         OVGreplacefont,
60         OVGcreateImageMemory,
61         OVGcreateEGLImage,
62         OVGreadyEGLImage
63 };
64
65 struct OpenVGCommand
66 {
67         enum OpenVGTask task;
68         const void *data;
69         const void *data2;
70         unsigned int param1,param2,param3;
71         unsigned int id; //only set an id if you are waiting
72 };
73
74 struct OpenVGResponse{
75         unsigned int id;
76         unsigned int result;
77 };
78
79
80 class OsdOpenVG : public OsdVector, public Thread_TYPE, public EGLPictureCreator
81 {
82   public:
83     OsdOpenVG();
84     virtual ~OsdOpenVG();
85
86     int init(void* device);
87     int shutdown();
88     int stopUpdate();
89
90     bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/);
91
92
93
94     float getFontHeight();
95     float getCharWidth(wchar_t c);
96
97     int getFontNames(const char *** names,const char *** names_keys);
98
99     virtual void setFont(const char * fontname);
100
101     virtual float getPixelAspect() {return aspect_correction;};
102
103     bool getEGLPicture(struct OsdVector::PictureInfo & info, EGLDisplay * display);
104
105     void updateBackgroundColor(DrawStyle bg);
106
107
108 protected:
109
110
111    /*osd vector implementation*/
112     void destroyImageRef(ImageIndex index);
113    // ImageIndex createJpeg(const char* fileName, int *width,int *height);
114     ImageIndex createMonoBitmap(void *base,int width,int height);
115     ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
116     void createPicture(struct PictureInfo& pict_inf);
117         void destroyStyleRef(VectorHandle index);
118         VectorHandle createStyleRef(const DrawStyle &c);
119         bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length);
120
121         void drawSetTrans(SurfaceCommands & sc);
122         void executeDrawCommand(SVGCommand & command);
123
124         void initPaths();
125         void destroyPaths();
126         VGPath std_paths[PIPoint+1];
127         long long  lastrendertime;
128         void InternalRendering();
129         void getScreenSize(int &width, int &height);
130         void getRealScreenSize(int &width, int &height);
131
132
133
134         Mutex vgmutex;
135         Mutex taskmutex;
136         Signal vgtaskSignal;
137     deque<OpenVGCommand> vgcommands;
138     deque<OpenVGResponse> vgresponses;
139     bool processTasks();
140     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);
141     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);
142     unsigned int handleTask(OpenVGCommand& command);
143     //void purgeAllReferences();
144     unsigned int wait_id;
145
146     FT_Library  ft_library;
147     FT_Face     ft_face;
148     VGFont vgfont;
149     VGFont vgttfont;
150     VGPaint vgttpaint;
151     int  loadFont(bool fontchange);
152     map<unsigned int,float> font_exp_x;
153     vector<char*> fontnames;
154     vector<char*> fontnames_keys;
155     char * cur_fontname;
156
157     int clip_shift_x;
158     int clip_shift_y;
159
160     unsigned int loadTTchar(cTeletextChar c);
161     map<unsigned int,int> tt_font_chars;
162
163
164
165         void threadMethod();
166     void threadPostStopCleanup();
167
168
169          /* BCM specific */
170
171     uint32_t display_height;
172         uint32_t display_width;
173         DISPMANX_DISPLAY_HANDLE_T bcm_display;
174         DISPMANX_ELEMENT_HANDLE_T bcm_element;
175         DISPMANX_ELEMENT_HANDLE_T bcm_background;
176         DISPMANX_RESOURCE_HANDLE_T bcm_backres;
177
178         uint32_t mode;
179
180
181         EGLDisplay egl_display;
182         EGLSurface egl_surface;
183         EGLContext egl_context;
184         EGLConfig egl_ourconfig;
185         float font_height;
186         float aspect_correction;
187         bool freetype_inited;
188
189         uint8_t *static_artwork_begin[sa_MAX];
190         uint8_t *static_artwork_end[sa_MAX];
191
192 #ifdef PICTURE_DECODER_OMX
193         ImageOMX *imageomx;
194 #endif
195
196 };
197
198 #endif