]> git.vomp.tv Git - vompclient.git/blob - osdopenvg.h
WIN32 compatibility
[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, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef OSDOPENVG_H
21 #define OSDOPENVG_H
22
23 #include <stdio.h>
24 #include <mutex>
25
26 #include <EGL/egl.h>
27 #include <EGL/eglext.h>
28 #include <VG/openvg.h>
29 #include <VG/vgu.h>
30
31
32
33 #include "osdvector.h"
34 #include "defines.h"
35 #include "log.h"
36 #include "threadp.h"
37 #include "signal.h"
38 #include "videoomx.h"
39 #include "staticartwork.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
79 #ifdef PICTURE_DECODER_OMX
80         , public EGLPictureCreator
81 #endif
82 {
83   public:
84     OsdOpenVG();
85     virtual ~OsdOpenVG();
86
87     int init();
88     int shutdown();
89     int stopUpdate();
90
91     bool screenShot(void *buffer, int width, int height, bool osd /*include osd*/);
92
93
94
95     float getFontHeight();
96     float getCharWidth(wchar_t c);
97
98     int getFontNames(const char *** names,const char *** names_keys);
99
100     virtual void setFont(const char * fontname);
101
102     virtual float getPixelAspect() {return aspect_correction;};
103
104     bool getEGLPicture(struct OsdVector::PictureInfo & info, EGLDisplay * display);
105
106     void updateBackgroundColor(DrawStyle bg);
107
108
109 protected:
110
111
112    /*osd vector implementation*/
113     void destroyImageRef(ImageIndex index);
114    // ImageIndex createJpeg(const char* fileName, int *width,int *height);
115     ImageIndex createMonoBitmap(void *base,int width,int height);
116     ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
117     void createPicture(struct PictureInfo& pict_inf);
118     void destroyStyleRef(VectorHandle index);
119     VectorHandle createStyleRef(const DrawStyle &c);
120     bool getStaticImageData(unsigned int static_id, UCHAR **userdata, ULONG *length);
121
122     void drawSetTrans(SurfaceCommands & sc);
123     void executeDrawCommand(SVGCommand & command);
124
125     void initPaths();
126     void destroyPaths();
127     VGPath std_paths[PIPoint+1];
128     long long  lastrendertime;
129     void InternalRendering();
130     void getScreenSize(int &width, int &height);
131     void getRealScreenSize(int &width, int &height);
132
133
134
135     std::mutex vgmutex;
136     std::mutex taskmutex;
137     Signal vgtaskSignal;
138     std::deque<OpenVGCommand> vgcommands;
139     std::deque<OpenVGResponse> vgresponses;
140     bool processTasks();
141     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);
142     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);
143     unsigned int handleTask(OpenVGCommand& command);
144     //void purgeAllReferences();
145     unsigned int wait_id;
146
147     FT_Library  ft_library;
148     FT_Face     ft_face;
149     VGFont vgfont;
150     VGFont vgttfont;
151     VGPaint vgttpaint;
152     int loadFont(bool fontchange);
153     std::map<unsigned int,float> font_exp_x;
154     std::vector<char*> fontnames;
155     std::vector<char*> fontnames_keys;
156     char* cur_fontname;
157
158     int clip_shift_x;
159     int clip_shift_y;
160
161     unsigned int loadTTchar(cTeletextChar c);
162     std::map<unsigned int,int> tt_font_chars;
163
164
165     void threadMethod();
166
167     /* BCM specific */
168
169     uint32_t display_height;
170     uint32_t display_width;
171     DISPMANX_DISPLAY_HANDLE_T bcm_display;
172     DISPMANX_ELEMENT_HANDLE_T bcm_element;
173     DISPMANX_ELEMENT_HANDLE_T bcm_background;
174     DISPMANX_RESOURCE_HANDLE_T bcm_backres;
175
176     uint32_t mode;
177
178
179         EGLDisplay egl_display;
180         EGLSurface egl_surface;
181         EGLContext egl_context;
182         EGLConfig egl_ourconfig;
183         float font_height;
184         float aspect_correction;
185         bool freetype_inited;
186
187         uint8_t *static_artwork_begin[sa_MAX];
188         uint8_t *static_artwork_end[sa_MAX];
189
190 #ifdef PICTURE_DECODER_OMX
191         ImageOMX *imageomx;
192 #endif
193
194 };
195
196 #endif