]> git.vomp.tv Git - vompclient-marten.git/blob - osdopenvg.h
Remove unnecessary dependencies
[vompclient-marten.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
41 #include <deque>
42
43 #include <ft2build.h>
44 #include FT_FREETYPE_H
45
46 enum OpenVGTask {
47         OVGdestroyImageRef,
48         OVGdestroyPaint,
49         OVGcreateImagePalette,
50         OVGcreateMonoBitmap,
51         OVGcreateColorRef,
52         OVGimageUploadLine,
53         OVGcreateImageFile
54 };
55
56 struct OpenVGCommand
57 {
58         enum OpenVGTask task;
59         const void *data;
60         const void *data2;
61         unsigned int param1,param2,param3;
62         unsigned int id; //only set an id if you are waiting
63 };
64
65 struct OpenVGResponse{
66         unsigned int id;
67         unsigned int result;
68 };
69
70
71 class OsdOpenVG : public OsdVector, public Thread_TYPE
72 {
73   public:
74     OsdOpenVG();
75     virtual ~OsdOpenVG();
76
77     int init(void* device);
78     int shutdown();
79     int stopUpdate();
80
81
82
83
84     float getFontHeight();
85     float getCharWidth(wchar_t c);
86     void imageUploadLine(ImageIndex index,unsigned int j,unsigned int width,void *data);
87
88
89 protected:
90    /*osd vector implementation*/
91     void destroyImageRef(ImageIndex index);
92     ImageIndex createJpeg(const char* fileName, int *width,int *height);
93     ImageIndex createMonoBitmap(void *base,int width,int height);
94     ImageIndex createImagePalette(int width,int height,const unsigned char *image_data,const unsigned int*palette_data);
95     void destroyStyleRef(unsigned int index);
96         unsigned int createStyleRef(const DrawStyle &c);
97         unsigned int createColorRef(const Colour &c);
98
99         void drawSetTrans(SurfaceCommands & sc);
100         void executeDrawCommand(SVGCommand & command);
101
102         void initPaths();
103         void destroyPaths();
104         VGPath std_paths[Point+1];
105         long long  lastrendertime;
106         void InternalRendering();
107
108
109
110         Mutex vgmutex;
111         Mutex taskmutex;
112     pthread_cond_t vgtaskCond;
113     pthread_mutex_t vgtaskCondMutex;
114     deque<OpenVGCommand> vgcommands;
115     deque<OpenVGResponse> vgresponses;
116     bool processTasks();
117     bool haveOpenVGResponse(unsigned int id,unsigned int * resp);
118     unsigned int  putOpenVGCommand(OpenVGCommand& comm,bool wait);
119     unsigned int handleTask(OpenVGCommand& command);
120     unsigned int wait_id;
121
122     FT_Library  ft_library;
123     FT_Face     ft_face;
124     VGFont vgfont;
125     VGFont vgttfont;
126     VGPaint vgttpaint;
127     int  loadFont();
128     map<unsigned int,float> font_exp_x;
129
130     unsigned int loadTTchar(cTeletextChar c);
131     map<unsigned int,int> tt_font_chars;
132
133
134
135         void threadMethod();
136     void threadPostStopCleanup();
137
138
139          /* BCM specific */
140
141     uint32_t display_height;
142         uint32_t display_width;
143         DISPMANX_DISPLAY_HANDLE_T bcm_display;
144         DISPMANX_ELEMENT_HANDLE_T bcm_element;
145 //      DISPMANX_ELEMENT_HANDLE_T bcm_background;
146 //      DISPMANX_RESOURCE_HANDLE_T bcm_backres;
147
148         uint32_t mode;
149
150
151         EGLDisplay egl_display;
152         EGLSurface egl_surface;
153         EGLContext egl_context;
154         EGLConfig egl_ourconfig;
155         float font_height;
156         float aspect_correction;
157         bool freetype_inited;
158
159
160 };
161
162 #endif