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