gtk-gl-area.c (9b9fbe8a4e9eec9072ee2697a6af59144442785f) gtk-gl-area.c (a4f113fd691899d926425ffd74b8f341cebf672c)
1/*
2 * GTK UI -- glarea opengl code.
3 *
4 * Requires 3.16+ (GtkGLArea widget).
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */

--- 12 unchanged lines hidden (view full) ---

21static void gtk_gl_area_set_scanout_mode(VirtualConsole *vc, bool scanout)
22{
23 if (vc->gfx.scanout_mode == scanout) {
24 return;
25 }
26
27 vc->gfx.scanout_mode = scanout;
28 if (!vc->gfx.scanout_mode) {
1/*
2 * GTK UI -- glarea opengl code.
3 *
4 * Requires 3.16+ (GtkGLArea widget).
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */

--- 12 unchanged lines hidden (view full) ---

21static void gtk_gl_area_set_scanout_mode(VirtualConsole *vc, bool scanout)
22{
23 if (vc->gfx.scanout_mode == scanout) {
24 return;
25 }
26
27 vc->gfx.scanout_mode = scanout;
28 if (!vc->gfx.scanout_mode) {
29 if (vc->gfx.fbo_id) {
30 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
31 GL_COLOR_ATTACHMENT0_EXT,
32 GL_TEXTURE_2D, 0, 0);
33 glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
34 glDeleteFramebuffers(1, &vc->gfx.fbo_id);
35 vc->gfx.fbo_id = 0;
36 }
29 egl_fb_destroy(&vc->gfx.guest_fb);
37 if (vc->gfx.surface) {
38 surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
39 surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
40 }
41 }
42}
43
44/** DisplayState Callbacks (opengl version) **/

--- 6 unchanged lines hidden (view full) ---

51 return;
52 }
53
54 gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
55 ww = gtk_widget_get_allocated_width(vc->gfx.drawing_area);
56 wh = gtk_widget_get_allocated_height(vc->gfx.drawing_area);
57
58 if (vc->gfx.scanout_mode) {
30 if (vc->gfx.surface) {
31 surface_gl_destroy_texture(vc->gfx.gls, vc->gfx.ds);
32 surface_gl_create_texture(vc->gfx.gls, vc->gfx.ds);
33 }
34 }
35}
36
37/** DisplayState Callbacks (opengl version) **/

--- 6 unchanged lines hidden (view full) ---

44 return;
45 }
46
47 gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
48 ww = gtk_widget_get_allocated_width(vc->gfx.drawing_area);
49 wh = gtk_widget_get_allocated_height(vc->gfx.drawing_area);
50
51 if (vc->gfx.scanout_mode) {
59 if (!vc->gfx.fbo_id) {
52 if (!vc->gfx.guest_fb.framebuffer) {
60 return;
61 }
62
53 return;
54 }
55
63 glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.fbo_id);
56 glBindFramebuffer(GL_READ_FRAMEBUFFER, vc->gfx.guest_fb.framebuffer);
64 /* GtkGLArea sets GL_DRAW_FRAMEBUFFER for us */
65
66 glViewport(0, 0, ww, wh);
67 y1 = vc->gfx.y0_top ? 0 : vc->gfx.h;
68 y2 = vc->gfx.y0_top ? vc->gfx.h : 0;
69 glBlitFramebuffer(0, y1, vc->gfx.w, y2,
70 0, 0, ww, wh,
71 GL_COLOR_BUFFER_BIT, GL_NEAREST);

--- 104 unchanged lines hidden (view full) ---

176 uint32_t w, uint32_t h)
177{
178 VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
179
180 vc->gfx.x = x;
181 vc->gfx.y = y;
182 vc->gfx.w = w;
183 vc->gfx.h = h;
57 /* GtkGLArea sets GL_DRAW_FRAMEBUFFER for us */
58
59 glViewport(0, 0, ww, wh);
60 y1 = vc->gfx.y0_top ? 0 : vc->gfx.h;
61 y2 = vc->gfx.y0_top ? vc->gfx.h : 0;
62 glBlitFramebuffer(0, y1, vc->gfx.w, y2,
63 0, 0, ww, wh,
64 GL_COLOR_BUFFER_BIT, GL_NEAREST);

--- 104 unchanged lines hidden (view full) ---

169 uint32_t w, uint32_t h)
170{
171 VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
172
173 vc->gfx.x = x;
174 vc->gfx.y = y;
175 vc->gfx.w = w;
176 vc->gfx.h = h;
184 vc->gfx.tex_id = backing_id;
185 vc->gfx.y0_top = backing_y_0_top;
186
187 gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
188
177 vc->gfx.y0_top = backing_y_0_top;
178
179 gtk_gl_area_make_current(GTK_GL_AREA(vc->gfx.drawing_area));
180
189 if (vc->gfx.tex_id == 0 || vc->gfx.w == 0 || vc->gfx.h == 0) {
181 if (vc->gfx.guest_fb.framebuffer == 0 ||
182 vc->gfx.w == 0 || vc->gfx.h == 0) {
190 gtk_gl_area_set_scanout_mode(vc, false);
191 return;
192 }
193
194 gtk_gl_area_set_scanout_mode(vc, true);
183 gtk_gl_area_set_scanout_mode(vc, false);
184 return;
185 }
186
187 gtk_gl_area_set_scanout_mode(vc, true);
195 if (!vc->gfx.fbo_id) {
196 glGenFramebuffers(1, &vc->gfx.fbo_id);
197 }
198
199 glBindFramebuffer(GL_FRAMEBUFFER_EXT, vc->gfx.fbo_id);
200 glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
201 GL_TEXTURE_2D, vc->gfx.tex_id, 0);
188 egl_fb_create_for_tex(&vc->gfx.guest_fb, backing_width, backing_height,
189 backing_id);
202}
203
204void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
205 uint32_t x, uint32_t y, uint32_t w, uint32_t h)
206{
207 VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
208
209 gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));

--- 18 unchanged lines hidden ---
190}
191
192void gd_gl_area_scanout_flush(DisplayChangeListener *dcl,
193 uint32_t x, uint32_t y, uint32_t w, uint32_t h)
194{
195 VirtualConsole *vc = container_of(dcl, VirtualConsole, gfx.dcl);
196
197 gtk_gl_area_queue_render(GTK_GL_AREA(vc->gfx.drawing_area));

--- 18 unchanged lines hidden ---