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