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