]> git.vomp.tv Git - vompclient.git/blob - osdopengl.h
Switch to smaller OSD rendering buffer
[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 #include "glosdshader.h"\r
40 #include "glyuv400shader.h"\r
41 #include "glyuv444shader.h"\r
42 \r
43 \r
44 \r
45 \r
46 \r
47 \r
48 struct OSDCOLOR{\r
49         GLfloat r;\r
50         GLfloat g;\r
51         GLfloat b;\r
52         GLfloat a;\r
53 };\r
54 \r
55 \r
56 struct OSDVERTEX {\r
57         GLfloat x;\r
58         GLfloat y;\r
59         GLfloat z;\r
60 /*      OSDCOLOR c;*/\r
61         GLfloat u;\r
62         GLfloat v;\r
63 };\r
64 \r
65 \r
66 \r
67 \r
68 \r
69 \r
70 class OsdOpenGL : public Osd, public Thread_TYPE\r
71 {\r
72   public:\r
73     OsdOpenGL();\r
74     virtual ~OsdOpenGL();\r
75 \r
76     int init(void* device);\r
77     int shutdown();\r
78 \r
79     int getFD();\r
80 \r
81     void screenShot(const char* fileName);\r
82 \r
83     Surface * createNewSurface();\r
84 \r
85 \r
86         void BeginPainting();\r
87         void EndPainting();\r
88 \r
89         void Blank();\r
90 \r
91         void getEGLObjs(EGLDisplay *i_egl_display,EGLSurface *i_egl_surface,EGLContext *i_egl_context, EGLConfig *i_egl_config){\r
92                 *i_egl_display=egl_display;\r
93                 *i_egl_surface=egl_surface;\r
94                 *i_egl_context=egl_context;\r
95                 *i_egl_config=egl_ourconfig;\r
96         };\r
97 \r
98         EGLConfig getEGLConfig() {return egl_ourconfig;};\r
99 \r
100         void AdviseAboutNewFrame() {threadSignal();};\r
101 \r
102 \r
103 \r
104 private:\r
105 \r
106         //Maybe move the following stuff to a generic opengl object also for boosting DCT etc.\r
107 \r
108 \r
109 \r
110         void threadMethod();\r
111     void threadPostStopCleanup();\r
112 \r
113         // This indicates, that currently a video is played, thus the osd updates are driven by the Videosystem\r
114         bool external_driving;\r
115         Mutex glmutex;\r
116         long long  lastrendertime;\r
117         void InternalRendering(VPEOGLFrame* frame);\r
118         void InitVertexBuffer(float  scalex,float scaley);\r
119         OSDVERTEX osdvertices[4];\r
120         GLubyte osdindices[6];\r
121 \r
122         GLOsdShader osd_shader;\r
123         GLYuv400Shader yuv400_shader;\r
124         GLYuv444Shader yuv444_shader;\r
125 \r
126 \r
127 \r
128 \r
129          /* BCM specific */\r
130 \r
131     uint32_t display_height;\r
132         uint32_t display_width;\r
133 \r
134         EGLDisplay egl_display;\r
135         EGLSurface egl_surface;\r
136         EGLContext egl_context;\r
137         EGLConfig egl_ourconfig;\r
138 #ifdef BENCHMARK_FPS\r
139         long long last_benchmark_time;\r
140         unsigned int num_benchmark_frames;\r
141 #endif\r
142 \r
143 };\r
144 \r
145 #endif\r