2 Copyright 2004-2005 Chris Tallon, 2006,2011-2012 Marten Richter
4 This file is part of VOMP.
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.
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.
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/>.
27 #include <condition_variable>
30 #include <EGL/eglext.h>
31 #include <VG/openvg.h>
35 #include "osdvector.h"
37 #include "messagequeue.h"
38 #include "staticartwork.h"
39 #ifdef PICTURE_DECODER_OMX
40 //#include "imageomx.h"
41 #include "imageomx2.h"
45 #include FT_FREETYPE_H
51 OVGcreateImagePalette,
66 std::condition_variable doneCond;
74 unsigned int param1, param2, param3;
76 struct OpenVGResponse* response{}; // If !NULL, a thread is waiting
81 #include "eglpicturecreator.h"
83 class OsdImageOpenVG : public OsdImageBase
85 friend class OsdOpenVG;
87 OsdImageOpenVG(VGImage vgi)
90 VGImage getVGImage() { return vgimage; }
95 class OsdOpenVG : public OsdVector, public MessageReceiver
96 #ifdef PICTURE_DECODER_OMX
97 , public EGLPictureCreator
102 virtual ~OsdOpenVG();
108 bool screenShotInternal(void* buffer, int width, int height, bool includeOSD);
110 float getFontHeight();
111 float getCharWidth(wchar_t c);
113 int getFontNames(const char*** names, const char*** names_keys);
115 virtual void setFont(const char* fontname);
117 virtual float getPixelAspect() {return aspect_correction;};
119 bool getEGLPicture(struct PictureInfo& info, EGLDisplay* display);
121 void updateBackgroundColor(DrawStyle bg);
123 void createPicture(struct PictureInfo& pict_inf);
125 void processMessage(Message* m);
127 void garbageCollectOsdImages();
131 // OSDOVG-ROD-EXPERIMENT
134 /*osd vector implementation*/
135 void destroyImageRef(VectorHandleImage handle);
136 // VectorHandleImage createJpeg(const char* fileName, int *width,int *height);
137 VectorHandleImage createMonoBitmap(void* base, int width, int height);
138 VectorHandleImage createImagePalette(int width, int height, const unsigned char* image_data, const unsigned int* palette_data);
139 void destroyDrawStyleHandle(VectorHandle index);
140 VectorHandle createDrawStyleHandle(const DrawStyle& c);
141 bool getStaticImageData(unsigned int static_id, u1** userdata, u4* length);
143 void drawSetTrans(SurfaceInfo& sc);
144 void executeDrawCommand(SVGCommand& command);
148 VGPath std_paths[PIPoint + 1];
149 long long lastrendertime;
150 void InternalRendering();
151 void getScreenSize(int& width, int& height);
152 void getRealScreenSize(int& width, int& height);
155 std::mutex taskmutex;
157 std::deque<OpenVGCommand> vgcommands;
158 bool processOpenVGCommands();
159 unsigned int putOpenVGCommand(OpenVGCommand& comm, bool wait);
160 unsigned int handleOpenVGCommand(OpenVGCommand& command);
161 //void purgeAllReferences();
163 FT_Library ft_library;
168 int loadFont(bool fontchange);
169 std::map<unsigned int, float> font_exp_x;
170 std::vector<char*> fontnames;
171 std::vector<char*> fontnames_keys;
177 unsigned int loadTTchar(cTeletextChar c);
178 std::map<unsigned int, int> tt_font_chars;
180 std::thread renderThread;
181 std::mutex renderThreadMutex; // used for start-protect, go-around signal, quit signal
182 std::condition_variable renderThreadCond;
183 int renderThreadReq; // 1 - do update, 2 - stop
185 void renderThreadStop();
189 int32_t display_height{};
190 int32_t display_width{};
191 DISPMANX_DISPLAY_HANDLE_T bcm_display;
192 DISPMANX_ELEMENT_HANDLE_T bcm_element;
193 DISPMANX_ELEMENT_HANDLE_T bcm_background;
194 DISPMANX_RESOURCE_HANDLE_T bcm_backres{};
198 EGLDisplay egl_display;
199 EGLSurface egl_surface;
200 EGLContext egl_context;
201 EGLConfig egl_ourconfig;
203 float aspect_correction{1.};
204 bool freetype_inited{};
206 uint8_t* static_artwork_begin[sa_MAX];
207 uint8_t* static_artwork_end[sa_MAX];
209 #ifdef PICTURE_DECODER_OMX
210 ImageOMX2* imageomx2;