]> git.vomp.tv Git - vompclient.git/blob - osdopengl.h
FFMPEG decoding in color at 7 fps
[vompclient.git] / osdopengl.h
1 /*\r
2     Copyright 2004-2005 Chris Tallon, 2006,2011-2012 Marten Richter\r
3 \r
4     This file is part of VOMP.\r
5 \r
6     VOMP is free software; you can redistribute it and/or modify\r
7     it under the terms of the GNU General Public License as published by\r
8     the Free Software Foundation; either version 2 of the License, or\r
9     (at your option) any later version.\r
10 \r
11     VOMP is distributed in the hope that it will be useful,\r
12     but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14     GNU General Public License for more details.\r
15 \r
16     You should have received a copy of the GNU General Public License\r
17     along with VOMP; if not, write to the Free Software\r
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\r
19 */\r
20 \r
21 #ifndef OSDOPENGL_H\r
22 #define OSDOPENGL_H\r
23 \r
24 #include <stdio.h>\r
25 \r
26 #include <bcm_host.h>\r
27 \r
28 #include <GLES2/gl2.h>\r
29 #include <EGL/egl.h>\r
30 #include <EGL/eglext.h>\r
31 \r
32 #include "osd.h"\r
33 #include "defines.h"\r
34 #include "log.h"\r
35 #include "threadp.h"\r
36 #include "mutex.h"\r
37 #include "videovpeogl.h"\r
38 \r
39 \r
40 \r
41 \r
42 \r
43 \r
44 struct OSDCOLOR{\r
45         GLfloat r;\r
46         GLfloat g;\r
47         GLfloat b;\r
48         GLfloat a;\r
49 };\r
50 \r
51 \r
52 struct OSDVERTEX {\r
53         GLfloat x;\r
54         GLfloat y;\r
55         GLfloat z;\r
56 /*      OSDCOLOR c;*/\r
57         GLfloat u;\r
58         GLfloat v;\r
59 };\r
60 \r
61 \r
62 \r
63 \r
64 \r
65 \r
66 class OsdOpenGL : public Osd, public Thread_TYPE\r
67 {\r
68   public:\r
69     OsdOpenGL();\r
70     virtual ~OsdOpenGL();\r
71 \r
72     int init(void* device);\r
73     int shutdown();\r
74 \r
75     int getFD();\r
76 \r
77     void screenShot(const char* fileName);\r
78 \r
79     Surface * createNewSurface();\r
80 \r
81 \r
82 \r
83 \r
84         // This function is called from the threadMethod function in order to get Screen updates\r
85 /*      void Render();\r
86         void RenderDS(VPEOGLFrame* frame);*/\r
87         void BeginPainting();\r
88         void EndPainting();\r
89 \r
90         void setExternalDriving(/*DsAllocator* dsall,*/ unsigned int width, unsigned int height);\r
91         void Blank();\r
92 \r
93         void getEGLObjs(EGLDisplay *i_egl_display,EGLSurface *i_egl_surface,EGLContext *i_egl_context, EGLConfig *i_egl_config){\r
94                 *i_egl_display=egl_display;\r
95                 *i_egl_surface=egl_surface;\r
96                 *i_egl_context=egl_context;\r
97                 *i_egl_config=egl_ourconfig;\r
98         };\r
99 \r
100         EGLConfig getEGLConfig() {return egl_ourconfig;};\r
101 \r
102         void AdviseAboutNewFrame() {threadSignal();};\r
103 \r
104 \r
105 \r
106 private:\r
107 \r
108         //Maybe move the following stuff to a generic opengl object also for boosting DCT etc.\r
109 \r
110    GLuint CreateShader(const GLchar * source, GLenum type);\r
111 \r
112         void threadMethod();\r
113     void threadPostStopCleanup();\r
114 \r
115         // This indicates, that currently a video is played, thus the osd updates are driven by the Videosystem\r
116         bool external_driving;\r
117         Mutex glmutex;\r
118         long long  lastrendertime;\r
119         void InternalRendering(VPEOGLFrame* frame);\r
120         bool DoLost();\r
121         void InitVertexBuffer(float  scalex,float scaley);\r
122         OSDVERTEX osdvertices[4];\r
123         GLubyte osdindices[6];\r
124 \r
125 \r
126         GLuint osd_shader;\r
127         GLuint gen_shader;\r
128 \r
129         GLuint osd_program;\r
130 \r
131         GLuint frame_shader;\r
132         GLuint frame_program;\r
133 \r
134         GLint frame_sampler_locY;\r
135         GLint frame_sampler_locU;\r
136         GLint frame_sampler_locV;\r
137 \r
138         GLint osd_sampler_loc;\r
139 \r
140 \r
141 \r
142          /* BCM specific */\r
143 \r
144     uint32_t display_height;\r
145         uint32_t display_width;\r
146 \r
147         EGLDisplay egl_display;\r
148         EGLSurface egl_surface;\r
149         EGLContext egl_context;\r
150         EGLConfig egl_ourconfig;\r
151 #ifdef BENCHMARK_FPS\r
152         long long last_benchmark_time;\r
153         unsigned int num_benchmark_frames;\r
154 #endif\r
155 \r
156 };\r
157 \r
158 #endif\r