summaryrefslogtreecommitdiff
path: root/hw/vigs
diff options
context:
space:
mode:
authorJinhyung Jo <jinhyung.jo@samsung.com>2016-06-22 19:32:42 +0900
committerJinhyung Jo <jinhyung.jo@samsung.com>2016-09-08 17:18:41 +0900
commit99ffcba1997dade13316bd09023f93597db0f2df (patch)
tree9e7f04991cf9972aef91c4df47dfe9e5b4a4cd57 /hw/vigs
parentdd1b27089951e80641465215c87b1bfd97f648b8 (diff)
downloadqemu-99ffcba1997dade13316bd09023f93597db0f2df.tar.gz
qemu-99ffcba1997dade13316bd09023f93597db0f2df.tar.bz2
qemu-99ffcba1997dade13316bd09023f93597db0f2df.zip
display: move display functionality to Qt5 GUI
Qt5 GUI paints final display with all processing, not in VIGS. The followings are in this commit. - VIGS: remove the code about display rendering - VIGS: modify the code about onscreen rendering server - VIGS: add functions to delivery the texture id to Qt5 UI - Qt5 UI: change the deprecated classes to the new classes - Qt5 UI: add OpenGL rendering functionality - Qt5 UI: fix the transparent issue with OpenGL - Qt5 UI: bug fix caused by image formats - etc. : minor modifications Change-Id: I39471237b5d526751fac95e9fe88f05f6939142c Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
Diffstat (limited to 'hw/vigs')
-rw-r--r--hw/vigs/vigs_gl_backend.c576
-rw-r--r--hw/vigs/vigs_gl_backend.h32
-rw-r--r--hw/vigs/vigs_gl_backend_cgl.c10
-rw-r--r--hw/vigs/vigs_gl_backend_glx.c75
-rw-r--r--hw/vigs/vigs_gl_backend_wgl.c9
-rw-r--r--hw/vigs/vigs_onscreen_server.c92
-rw-r--r--hw/vigs/vigs_onscreen_server.h6
-rw-r--r--hw/vigs/vigs_qt5.cpp96
-rw-r--r--hw/vigs/vigs_qt5.h4
-rw-r--r--hw/vigs/vigs_qt5_stub.c19
10 files changed, 128 insertions, 791 deletions
diff --git a/hw/vigs/vigs_gl_backend.c b/hw/vigs/vigs_gl_backend.c
index 7fcd2c092f..9995d1c15a 100644
--- a/hw/vigs/vigs_gl_backend.c
+++ b/hw/vigs/vigs_gl_backend.c
@@ -36,20 +36,8 @@
#include "vigs_ref.h"
#include "vigs_qt5.h"
#include "winsys_gl.h"
-#include "hw/pci/maru_brightness.h"
#include <math.h>
-extern uint32_t qt5_window_width;
-extern uint32_t qt5_window_height;
-extern int qt5_window_angle;
-
-/* multitouch data */
-extern float *qt5_mt_points;
-extern int qt5_mt_count;
-extern const void *qt5_mt_pixels;
-extern int qt5_mt_width;
-extern int qt5_mt_height;
-
struct vigs_gl_surface;
struct vigs_winsys_gl_surface
@@ -201,136 +189,6 @@ static const char *g_fs_color_source_gl3 =
" FragColor = color;\n"
"}\n";
-static const char *g_fs_dpy_source_gl2 =
- "#version 120\n\n"
- "uniform sampler2D tex;\n"
- "uniform float brightness;\n"
- "varying vec2 v_texCoord;\n"
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(tex, v_texCoord) * brightness;\n"
- "}\n";
-
-static const char *g_fs_dpy_source_gl3 =
- "#version 140\n\n"
- "uniform sampler2D tex;\n"
- "uniform float brightness;\n"
- "in vec2 v_texCoord;\n"
- "out vec4 FragColor;\n"
- "void main()\n"
- "{\n"
- " FragColor = texture(tex, v_texCoord) * brightness;\n"
- "}\n";
-
-static const char *g_fs_scale_source_gl2 =
-"#version 120\n\
-\n\
-uniform sampler2D tex;\n\
-uniform float brightness;\n\
-uniform vec2 texSize;\n\
-varying vec2 v_texCoord;\n\
-vec4 cubic(float x)\n\
-{\n\
- float x2 = x * x;\n\
- float x3 = x2 * x;\n\
- vec4 w;\n\
- w.x = -x3 + 3*x2 - 3*x + 1;\n\
- w.y = 3*x3 - 6*x2 + 4;\n\
- w.z = -3*x3 + 3*x2 + 3*x + 1;\n\
- w.w = x3;\n\
- return w / 6.f;\n\
-}\n\
-void main()\n\
-{\n\
- vec2 texscale = vec2(1.0 / texSize.x, 1.0 / texSize.y);\n\
- vec2 texcoord = vec2(v_texCoord.x * texSize.x, v_texCoord.y * texSize.y);\n\
- float fx = fract(texcoord.x);\n\
- float fy = fract(texcoord.y);\n\
- texcoord.x -= fx;\n\
- texcoord.y -= fy;\n\
-\n\
- vec4 xcubic = cubic(fx);\n\
- vec4 ycubic = cubic(fy);\n\
-\n\
- vec4 c = vec4(texcoord.x - 0.5, texcoord.x + 1.5, texcoord.y -\n\
-0.5, texcoord.y + 1.5);\n\
- vec4 s = vec4(xcubic.x + xcubic.y, xcubic.z + xcubic.w, ycubic.x +\n\
-ycubic.y, ycubic.z + ycubic.w);\n\
- vec4 offset = c + vec4(xcubic.y, xcubic.w, ycubic.y, ycubic.w) /\n\
-s;\n\
-\n\
- vec4 sample0 = texture2D(tex, vec2(offset.x, offset.z) *\n\
-texscale);\n\
- vec4 sample1 = texture2D(tex, vec2(offset.y, offset.z) *\n\
-texscale);\n\
- vec4 sample2 = texture2D(tex, vec2(offset.x, offset.w) *\n\
-texscale);\n\
- vec4 sample3 = texture2D(tex, vec2(offset.y, offset.w) *\n\
-texscale);\n\
-\n\
- float sx = s.x / (s.x + s.y);\n\
- float sy = s.z / (s.z + s.w);\n\
-\n\
- gl_FragColor = mix(\n\
- mix(sample3, sample2, sx),\n\
- mix(sample1, sample0, sx), sy) * brightness;\n\
-}";
-
-static const char *g_fs_scale_source_gl3 =
-"#version 140\n\
-\n\
-uniform sampler2D tex;\n\
-uniform float brightness;\n\
-uniform vec2 texSize;\n\
-in vec2 v_texCoord;\n\
-out vec4 FragColor;\n\
-vec4 cubic(float x)\n\
-{\n\
- float x2 = x * x;\n\
- float x3 = x2 * x;\n\
- vec4 w;\n\
- w.x = -x3 + 3*x2 - 3*x + 1;\n\
- w.y = 3*x3 - 6*x2 + 4;\n\
- w.z = -3*x3 + 3*x2 + 3*x + 1;\n\
- w.w = x3;\n\
- return w / 6.f;\n\
-}\n\
-void main()\n\
-{\n\
- vec2 texscale = vec2(1.0 / texSize.x, 1.0 / texSize.y);\n\
- vec2 texcoord = vec2(v_texCoord.x * texSize.x, v_texCoord.y * texSize.y);\n\
- float fx = fract(texcoord.x);\n\
- float fy = fract(texcoord.y);\n\
- texcoord.x -= fx;\n\
- texcoord.y -= fy;\n\
-\n\
- vec4 xcubic = cubic(fx);\n\
- vec4 ycubic = cubic(fy);\n\
-\n\
- vec4 c = vec4(texcoord.x - 0.5, texcoord.x + 1.5, texcoord.y -\n\
-0.5, texcoord.y + 1.5);\n\
- vec4 s = vec4(xcubic.x + xcubic.y, xcubic.z + xcubic.w, ycubic.x +\n\
-ycubic.y, ycubic.z + ycubic.w);\n\
- vec4 offset = c + vec4(xcubic.y, xcubic.w, ycubic.y, ycubic.w) /\n\
-s;\n\
-\n\
- vec4 sample0 = texture(tex, vec2(offset.x, offset.z) *\n\
-texscale);\n\
- vec4 sample1 = texture(tex, vec2(offset.y, offset.z) *\n\
-texscale);\n\
- vec4 sample2 = texture(tex, vec2(offset.x, offset.w) *\n\
-texscale);\n\
- vec4 sample3 = texture(tex, vec2(offset.y, offset.w) *\n\
-texscale);\n\
-\n\
- float sx = s.x / (s.x + s.y);\n\
- float sy = s.z / (s.z + s.w);\n\
-\n\
- FragColor = mix(\n\
- mix(sample3, sample2, sx),\n\
- mix(sample1, sample0, sx), sy) * brightness;\n\
-}";
-
static const char *g_vs_nv21_source_gl2 =
"#version 120\n\n"
"attribute vec4 vertCoord;\n"
@@ -742,102 +600,6 @@ static void vigs_gl_draw_color_prog(struct vigs_gl_backend *backend,
backend->DisableVertexAttribArray(backend->color_prog_vertCoord_loc);
}
-static void vigs_gl_draw_dpy_tex_prog(struct vigs_gl_backend *backend,
- uint32_t count)
-{
- uint32_t size = count * 16;
- void *ptr;
-
- if (size > backend->dpy_vbo_size) {
- backend->dpy_vbo_size = size;
- backend->BufferData(GL_ARRAY_BUFFER,
- size,
- 0,
- GL_STREAM_DRAW);
- }
-
- if (backend->MapBufferRange) {
- ptr = backend->MapBufferRange(GL_ARRAY_BUFFER, 0, size,
- GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
-
- if (ptr) {
- memcpy(ptr, vigs_vector_data(&backend->dpy_v1), size / 2);
- memcpy(ptr + (size / 2), vigs_vector_data(&backend->dpy_v2), size / 2);
-
- backend->UnmapBuffer(GL_ARRAY_BUFFER);
- } else {
- VIGS_LOG_ERROR("glMapBufferRange failed");
- }
- } else {
- backend->Finish();
- backend->BufferSubData(GL_ARRAY_BUFFER, 0,
- (size / 2), vigs_vector_data(&backend->dpy_v1));
- backend->BufferSubData(GL_ARRAY_BUFFER, (size / 2),
- (size / 2), vigs_vector_data(&backend->dpy_v2));
- }
-
- backend->EnableVertexAttribArray(backend->dpy_tex_prog_vertCoord_loc);
- backend->EnableVertexAttribArray(backend->dpy_tex_prog_texCoord_loc);
-
- backend->VertexAttribPointer(backend->dpy_tex_prog_vertCoord_loc,
- 2, GL_FLOAT, GL_FALSE, 0, NULL);
- backend->VertexAttribPointer(backend->dpy_tex_prog_texCoord_loc,
- 2, GL_FLOAT, GL_FALSE, 0, NULL + (size / 2));
-
- backend->DrawArrays(GL_TRIANGLES, 0, count);
-
- backend->DisableVertexAttribArray(backend->dpy_tex_prog_texCoord_loc);
- backend->DisableVertexAttribArray(backend->dpy_tex_prog_vertCoord_loc);
-}
-
-static void vigs_gl_draw_dpy_scale_prog(struct vigs_gl_backend *backend,
- uint32_t count)
-{
- uint32_t size = count * 16;
- void *ptr;
-
- if (size > backend->dpy_vbo_size) {
- backend->dpy_vbo_size = size;
- backend->BufferData(GL_ARRAY_BUFFER,
- size,
- 0,
- GL_STREAM_DRAW);
- }
-
- if (backend->MapBufferRange) {
- ptr = backend->MapBufferRange(GL_ARRAY_BUFFER, 0, size,
- GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_RANGE_BIT);
-
- if (ptr) {
- memcpy(ptr, vigs_vector_data(&backend->dpy_v1), size / 2);
- memcpy(ptr + (size / 2), vigs_vector_data(&backend->dpy_v2), size / 2);
-
- backend->UnmapBuffer(GL_ARRAY_BUFFER);
- } else {
- VIGS_LOG_ERROR("glMapBufferRange failed");
- }
- } else {
- backend->Finish();
- backend->BufferSubData(GL_ARRAY_BUFFER, 0,
- (size / 2), vigs_vector_data(&backend->dpy_v1));
- backend->BufferSubData(GL_ARRAY_BUFFER, (size / 2),
- (size / 2), vigs_vector_data(&backend->dpy_v2));
- }
-
- backend->EnableVertexAttribArray(backend->dpy_scale_prog_vertCoord_loc);
- backend->EnableVertexAttribArray(backend->dpy_scale_prog_texCoord_loc);
-
- backend->VertexAttribPointer(backend->dpy_scale_prog_vertCoord_loc,
- 2, GL_FLOAT, GL_FALSE, 0, NULL);
- backend->VertexAttribPointer(backend->dpy_scale_prog_texCoord_loc,
- 2, GL_FLOAT, GL_FALSE, 0, NULL + (size / 2));
-
- backend->DrawArrays(GL_TRIANGLES, 0, count);
-
- backend->DisableVertexAttribArray(backend->dpy_scale_prog_texCoord_loc);
- backend->DisableVertexAttribArray(backend->dpy_scale_prog_vertCoord_loc);
-}
-
static void vigs_gl_draw_nv21_prog(struct vigs_gl_backend *backend,
uint32_t count)
{
@@ -894,28 +656,6 @@ static void vigs_gl_create_ortho(GLfloat left, GLfloat right,
ortho[15] = 1.0f;
}
-static void vigs_gl_rotate_ortho(const GLfloat ortho[16],
- GLfloat angle,
- GLfloat res[16])
-{
- GLfloat rot[4][4] = {
- { cos(angle), sin(angle), 0, 0 },
- { -sin(angle), cos(angle), 0, 0 },
- { 0, 0, 1, 0 },
- { 0, 0, 0, 1 }
- };
- int i, j, k;
-
- for (i = 0; i < 4; ++i) {
- for (j = 0; j < 4; ++j) {
- res[i * 4 + j] = 0.0f;
- for (k = 0; k < 4; ++k) {
- res[i * 4 + j] += ortho[i * 4 + k] * rot[k][j];
- }
- }
- }
-}
-
static void vigs_gl_translate_color(vigsp_color color,
vigsp_surface_format format,
GLfloat res[4])
@@ -1026,8 +766,7 @@ static bool vigs_gl_surface_setup_framebuffer(struct vigs_gl_surface *gl_sfc,
}
static bool vigs_gl_update_dpy_texture(struct vigs_gl_backend *gl_backend,
- uint32_t width, uint32_t height,
- GLfloat ortho[16])
+ uint32_t width, uint32_t height)
{
GLuint cur_tex = 0;
@@ -1065,9 +804,6 @@ static bool vigs_gl_update_dpy_texture(struct vigs_gl_backend *gl_backend,
gl_backend->BindTexture(GL_TEXTURE_2D, cur_tex);
- memcpy(gl_backend->dpy_tex_ortho,
- ortho,
- sizeof(gl_backend->dpy_tex_ortho));
gl_backend->dpy_tex_width = width;
gl_backend->dpy_tex_height = height;
@@ -2235,8 +1971,7 @@ static bool vigs_gl_backend_composite(struct vigs_surface *surface,
if (!vigs_gl_update_dpy_texture(gl_backend,
surface->ws_sfc->width,
- surface->ws_sfc->height,
- gl_root_sfc->ortho)) {
+ surface->ws_sfc->height)) {
goto out;
}
@@ -2441,219 +2176,34 @@ static bool vigs_gl_backend_display(struct vigs_backend *backend,
VIGS_LOG_TRACE("enter");
if (vigs_qt5_onscreen_enabled()) {
- GLfloat *vert_coords;
- GLfloat *tex_coords;
- bool scale;
- GLfloat rotated_ortho[16];
- GLfloat *ortho;
- float brightness = (float)(255 - brightness_tbl[brightness_level]) / 255.0f;
- int i, mt_count = qt5_mt_count;
-
- if (display_off) {
- brightness = 0.0f;
- }
-
- if (!gl_backend->is_gl_2 && !gl_backend->dpy_vao) {
- gl_backend->GenVertexArrays(1, &gl_backend->dpy_vao);
+ vigs_qt5_dpy_render_texture(gl_backend->dpy_tex);
+ return true;
+ }
- if (!gl_backend->dpy_vao) {
- VIGS_LOG_CRITICAL("cannot create VAO");
+ if (gl_backend->read_pixels_make_current(gl_backend, true)) {
+ if (!gl_backend->dpy_fb) {
+ gl_backend->GenFramebuffers(1, &gl_backend->dpy_fb);
+ if (!gl_backend->dpy_fb) {
+ VIGS_LOG_CRITICAL("cannot create FB");
exit(1);
}
- gl_backend->BindVertexArray(gl_backend->dpy_vao);
+ gl_backend->BindFramebuffer(GL_FRAMEBUFFER, gl_backend->dpy_fb);
}
- gl_backend->BindBuffer(GL_ARRAY_BUFFER, gl_backend->dpy_vbo);
- gl_backend->Disable(GL_DEPTH_TEST);
- gl_backend->Disable(GL_BLEND);
-
- if (qt5_window_angle == 0) {
- ortho = gl_backend->dpy_tex_ortho;
- } else {
- vigs_gl_rotate_ortho(gl_backend->dpy_tex_ortho,
- (float)(360.0f - qt5_window_angle) * M_PI / 180.0f,
- rotated_ortho);
- ortho = rotated_ortho;
- }
-
- scale = (qt5_window_width != gl_backend->dpy_tex_width) ||
- (qt5_window_height != gl_backend->dpy_tex_height);
-
- gl_backend->Viewport(0, 0,
- qt5_window_width,
- qt5_window_height);
-
- if (scale) {
- float texSize[2];
-
- gl_backend->UseProgram(gl_backend->dpy_scale_prog_id);
- gl_backend->UniformMatrix4fv(gl_backend->dpy_scale_prog_proj_loc, 1, GL_FALSE,
- ortho);
-
- texSize[0] = gl_backend->dpy_tex_width;
- texSize[1] = gl_backend->dpy_tex_height;
-
- gl_backend->Uniform2fv(gl_backend->dpy_scale_prog_texSize_loc, 1, texSize);
- gl_backend->Uniform1f(gl_backend->dpy_scale_prog_brightness_loc, brightness);
- } else {
- gl_backend->UseProgram(gl_backend->dpy_tex_prog_id);
- gl_backend->UniformMatrix4fv(gl_backend->dpy_tex_prog_proj_loc, 1, GL_FALSE,
- ortho);
- gl_backend->Uniform1f(gl_backend->dpy_tex_prog_brightness_loc, brightness);
- }
-
- gl_backend->BindTexture(GL_TEXTURE_2D, gl_backend->dpy_tex);
-
- vigs_vector_resize(&gl_backend->dpy_v1, 0);
- vigs_vector_resize(&gl_backend->dpy_v2, 0);
-
- vert_coords = vigs_vector_append(&gl_backend->dpy_v1,
- (12 * sizeof(GLfloat)));
- tex_coords = vigs_vector_append(&gl_backend->dpy_v2,
- (12 * sizeof(GLfloat)));
-
- vert_coords[6] = vert_coords[0] = 0;
- vert_coords[7] = vert_coords[1] = gl_backend->dpy_tex_height;
- vert_coords[2] = gl_backend->dpy_tex_width;
- vert_coords[3] = gl_backend->dpy_tex_height;
- vert_coords[8] = vert_coords[4] = gl_backend->dpy_tex_width;
- vert_coords[9] = vert_coords[5] = 0;
- vert_coords[10] = 0;
- vert_coords[11] = 0;
-
- tex_coords[6] = tex_coords[0] = 0;
- tex_coords[7] = tex_coords[1] = 0;
- tex_coords[2] = 1;
- tex_coords[3] = 0;
- tex_coords[8] = tex_coords[4] = 1;
- tex_coords[9] = tex_coords[5] = 1;
- tex_coords[10] = 0;
- tex_coords[11] = 1;
-
- if (scale) {
- vigs_gl_draw_dpy_scale_prog(gl_backend, 6);
- } else {
- vigs_gl_draw_dpy_tex_prog(gl_backend, 6);
- }
-
- if (!gl_backend->mt_tex) {
- GLuint mt_tex = 0;
-
- if (!qt5_mt_pixels || qt5_mt_width == 0 || qt5_mt_height == 0) {
- /* multitouch not initialized */
- goto out;
- }
-
- gl_backend->GenTextures(1, &mt_tex);
-
- if (!mt_tex) {
- VIGS_LOG_WARN("MT: GenTextures failed");
- goto out;
- }
-
- gl_backend->BindTexture(GL_TEXTURE_2D, mt_tex);
-
- gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- gl_backend->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- gl_backend->TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,
- qt5_mt_width, qt5_mt_height, 0,
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
- qt5_mt_pixels);
-
- gl_backend->mt_tex = mt_tex;
- gl_backend->mt_tex_width = qt5_mt_width;
- gl_backend->mt_tex_height = qt5_mt_height;
- } else {
- gl_backend->BindTexture(GL_TEXTURE_2D, gl_backend->mt_tex);
- }
-
- vigs_vector_resize(&gl_backend->dpy_v1, 0);
- vigs_vector_resize(&gl_backend->dpy_v2, 0);
-
- for (i = 0; i < mt_count; i++) {
- GLfloat w = (GLfloat)gl_backend->mt_tex_width;
- GLfloat h = (GLfloat)gl_backend->mt_tex_height;
- GLfloat x = qt5_mt_points[2 * i + 0] - w / 2;
- GLfloat y = qt5_window_height - qt5_mt_points[2 * i + 1] - h / 2;
-
- vert_coords = vigs_vector_append(&gl_backend->dpy_v1,
- (12 * sizeof(GLfloat)));
- tex_coords = vigs_vector_append(&gl_backend->dpy_v2,
- (12 * sizeof(GLfloat)));
-
- vert_coords[6] = vert_coords[0] = x;
- vert_coords[7] = vert_coords[1] = y;
- vert_coords[2] = x + w;
- vert_coords[3] = y;
- vert_coords[8] = vert_coords[4] = x + w;
- vert_coords[9] = vert_coords[5] = y + h;
- vert_coords[10] = x;
- vert_coords[11] = y + h;
-
- tex_coords[6] = tex_coords[0] = 0;
- tex_coords[7] = tex_coords[1] = 1;
- tex_coords[2] = 1;
- tex_coords[3] = 1;
- tex_coords[8] = tex_coords[4] = 1;
- tex_coords[9] = tex_coords[5] = 0;
- tex_coords[10] = 0;
- tex_coords[11] = 0;
- }
-
- if (mt_count) {
- vigs_gl_create_ortho(0.0f, qt5_window_width,
- 0.0f, qt5_window_height,
- -1.0f, 1.0f,
- gl_backend->mt_tex_ortho);
-
- gl_backend->Enable(GL_BLEND);
- gl_backend->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- gl_backend->UseProgram(gl_backend->dpy_tex_prog_id);
- gl_backend->UniformMatrix4fv(gl_backend->dpy_tex_prog_proj_loc, 1, GL_FALSE,
- gl_backend->mt_tex_ortho);
- gl_backend->Uniform1f(gl_backend->dpy_tex_prog_brightness_loc, 1.0f);
-
- vigs_gl_draw_dpy_tex_prog(gl_backend, mt_count * 6);
+ gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, gl_backend->dpy_tex, 0);
- gl_backend->Disable(GL_BLEND);
- }
+ gl_backend->ReadPixels(0, 0, gl_backend->dpy_tex_width,
+ gl_backend->dpy_tex_height,
+ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
+ display_data);
-out:
- gl_backend->Finish();
+ gl_backend->read_pixels_make_current(gl_backend, false);
return true;
} else {
- if (gl_backend->read_pixels_make_current(gl_backend, true)) {
- if (!gl_backend->dpy_fb) {
- gl_backend->GenFramebuffers(1, &gl_backend->dpy_fb);
-
- if (!gl_backend->dpy_fb) {
- VIGS_LOG_CRITICAL("cannot create FB");
- exit(1);
- }
-
- gl_backend->BindFramebuffer(GL_FRAMEBUFFER, gl_backend->dpy_fb);
- }
-
- gl_backend->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
- GL_TEXTURE_2D, gl_backend->dpy_tex, 0);
-
- gl_backend->ReadPixels(0, 0, gl_backend->dpy_tex_width,
- gl_backend->dpy_tex_height,
- GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
- display_data);
-
- gl_backend->read_pixels_make_current(gl_backend, false);
-
- return true;
- } else {
- return false;
- }
+ return false;
}
}
@@ -2823,9 +2373,7 @@ bool vigs_gl_backend_init(struct vigs_gl_backend *gl_backend)
gl_backend->yuv420_prog_vtex_loc = gl_backend->GetUniformLocation(gl_backend->yuv420_prog_id, "vtex");
gl_backend->GenBuffers(1, &gl_backend->vbo);
- gl_backend->GenBuffers(1, &gl_backend->dpy_vbo);
-
- if (!gl_backend->vbo || !gl_backend->dpy_vbo) {
+ if (!gl_backend->vbo) {
VIGS_LOG_CRITICAL("cannot create VBOs");
goto fail;
}
@@ -2844,65 +2392,6 @@ bool vigs_gl_backend_init(struct vigs_gl_backend *gl_backend)
gl_backend->UseProgram(gl_backend->tex_prog_id);
gl_backend->cur_prog_id = gl_backend->tex_prog_id;
- gl_backend->dpy_tex_prog_vs_id = vigs_gl_create_shader(gl_backend,
- (gl_backend->is_gl_2 ? g_vs_tex_source_gl2 : g_vs_tex_source_gl3),
- GL_VERTEX_SHADER);
-
- if (!gl_backend->dpy_tex_prog_vs_id) {
- goto fail;
- }
-
- gl_backend->dpy_tex_prog_fs_id = vigs_gl_create_shader(gl_backend,
- (gl_backend->is_gl_2 ? g_fs_dpy_source_gl2 : g_fs_dpy_source_gl3),
- GL_FRAGMENT_SHADER);
-
- if (!gl_backend->dpy_tex_prog_fs_id) {
- goto fail;
- }
-
- gl_backend->dpy_tex_prog_id = vigs_gl_create_program(gl_backend,
- gl_backend->dpy_tex_prog_vs_id,
- gl_backend->dpy_tex_prog_fs_id);
-
- if (!gl_backend->dpy_tex_prog_id) {
- goto fail;
- }
-
- gl_backend->dpy_tex_prog_proj_loc = gl_backend->GetUniformLocation(gl_backend->dpy_tex_prog_id, "proj");
- gl_backend->dpy_tex_prog_vertCoord_loc = gl_backend->GetAttribLocation(gl_backend->dpy_tex_prog_id, "vertCoord");
- gl_backend->dpy_tex_prog_texCoord_loc = gl_backend->GetAttribLocation(gl_backend->dpy_tex_prog_id, "texCoord");
- gl_backend->dpy_tex_prog_brightness_loc = gl_backend->GetUniformLocation(gl_backend->dpy_tex_prog_id, "brightness");
-
- gl_backend->dpy_scale_prog_vs_id = vigs_gl_create_shader(gl_backend,
- (gl_backend->is_gl_2 ? g_vs_tex_source_gl2 : g_vs_tex_source_gl3),
- GL_VERTEX_SHADER);
-
- if (!gl_backend->dpy_scale_prog_vs_id) {
- goto fail;
- }
-
- gl_backend->dpy_scale_prog_fs_id = vigs_gl_create_shader(gl_backend,
- (gl_backend->is_gl_2 ? g_fs_scale_source_gl2 : g_fs_scale_source_gl3),
- GL_FRAGMENT_SHADER);
-
- if (!gl_backend->dpy_scale_prog_fs_id) {
- goto fail;
- }
-
- gl_backend->dpy_scale_prog_id = vigs_gl_create_program(gl_backend,
- gl_backend->dpy_scale_prog_vs_id,
- gl_backend->dpy_scale_prog_fs_id);
-
- if (!gl_backend->dpy_scale_prog_id) {
- goto fail;
- }
-
- gl_backend->dpy_scale_prog_proj_loc = gl_backend->GetUniformLocation(gl_backend->dpy_scale_prog_id, "proj");
- gl_backend->dpy_scale_prog_vertCoord_loc = gl_backend->GetAttribLocation(gl_backend->dpy_scale_prog_id, "vertCoord");
- gl_backend->dpy_scale_prog_texCoord_loc = gl_backend->GetAttribLocation(gl_backend->dpy_scale_prog_id, "texCoord");
- gl_backend->dpy_scale_prog_texSize_loc = gl_backend->GetUniformLocation(gl_backend->dpy_scale_prog_id, "texSize");
- gl_backend->dpy_scale_prog_brightness_loc = gl_backend->GetUniformLocation(gl_backend->dpy_scale_prog_id, "brightness");
-
gl_backend->ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl_backend->Disable(GL_DEPTH_TEST);
gl_backend->Disable(GL_BLEND);
@@ -2918,8 +2407,6 @@ bool vigs_gl_backend_init(struct vigs_gl_backend *gl_backend)
vigs_vector_init(&gl_backend->v1, 0);
vigs_vector_init(&gl_backend->v2, 0);
- vigs_vector_init(&gl_backend->dpy_v1, 0);
- vigs_vector_init(&gl_backend->dpy_v2, 0);
return true;
@@ -2932,27 +2419,12 @@ fail:
void vigs_gl_backend_cleanup(struct vigs_gl_backend *gl_backend)
{
if (gl_backend->make_current(gl_backend, true)) {
- if (gl_backend->mt_tex) {
- gl_backend->DeleteTextures(1, &gl_backend->mt_tex);
- }
if (gl_backend->dpy_tex) {
gl_backend->DeleteTextures(1, &gl_backend->dpy_tex);
}
- gl_backend->DeleteBuffers(1, &gl_backend->dpy_vbo);
- gl_backend->DetachShader(gl_backend->dpy_scale_prog_id,
- gl_backend->dpy_scale_prog_vs_id);
- gl_backend->DetachShader(gl_backend->dpy_scale_prog_id,
- gl_backend->dpy_scale_prog_fs_id);
- gl_backend->DeleteShader(gl_backend->dpy_scale_prog_vs_id);
- gl_backend->DeleteShader(gl_backend->dpy_scale_prog_fs_id);
- gl_backend->DeleteProgram(gl_backend->dpy_scale_prog_id);
- gl_backend->DetachShader(gl_backend->dpy_tex_prog_id,
- gl_backend->dpy_tex_prog_vs_id);
- gl_backend->DetachShader(gl_backend->dpy_tex_prog_id,
- gl_backend->dpy_tex_prog_fs_id);
- gl_backend->DeleteShader(gl_backend->dpy_tex_prog_vs_id);
- gl_backend->DeleteShader(gl_backend->dpy_tex_prog_fs_id);
- gl_backend->DeleteProgram(gl_backend->dpy_tex_prog_id);
+ if (gl_backend->dpy_fb) {
+ gl_backend->DeleteFramebuffers(1, &gl_backend->dpy_fb);
+ }
gl_backend->DeleteBuffers(1, &gl_backend->vbo);
gl_backend->DetachShader(gl_backend->yuv420_prog_id,
gl_backend->yuv420_prog_vs_id);
@@ -2993,8 +2465,6 @@ void vigs_gl_backend_cleanup(struct vigs_gl_backend *gl_backend)
gl_backend->make_current(gl_backend, false);
}
- vigs_vector_cleanup(&gl_backend->dpy_v2);
- vigs_vector_cleanup(&gl_backend->dpy_v1);
vigs_vector_cleanup(&gl_backend->v2);
vigs_vector_cleanup(&gl_backend->v1);
}
diff --git a/hw/vigs/vigs_gl_backend.h b/hw/vigs/vigs_gl_backend.h
index dca456b06c..ca2d3658ab 100644
--- a/hw/vigs/vigs_gl_backend.h
+++ b/hw/vigs/vigs_gl_backend.h
@@ -220,43 +220,11 @@ struct vigs_gl_backend
* Display thread related.
* @{
*/
-
- struct vigs_vector dpy_v1;
- struct vigs_vector dpy_v2;
-
- GLuint dpy_vao;
-
- GLuint dpy_tex_prog_vs_id;
- GLuint dpy_tex_prog_fs_id;
- GLuint dpy_tex_prog_id;
- GLint dpy_tex_prog_proj_loc;
- GLint dpy_tex_prog_vertCoord_loc;
- GLint dpy_tex_prog_texCoord_loc;
- GLint dpy_tex_prog_brightness_loc;
-
- GLuint dpy_scale_prog_vs_id;
- GLuint dpy_scale_prog_fs_id;
- GLuint dpy_scale_prog_id;
- GLint dpy_scale_prog_proj_loc;
- GLint dpy_scale_prog_vertCoord_loc;
- GLint dpy_scale_prog_texCoord_loc;
- GLint dpy_scale_prog_texSize_loc;
- GLint dpy_scale_prog_brightness_loc;
-
- GLuint dpy_vbo;
- uint32_t dpy_vbo_size;
-
GLuint dpy_tex;
GLuint dpy_fb;
- GLfloat dpy_tex_ortho[16];
uint32_t dpy_tex_width;
uint32_t dpy_tex_height;
- GLuint mt_tex;
- GLfloat mt_tex_ortho[16];
- uint32_t mt_tex_width;
- uint32_t mt_tex_height;
-
/*
* @}
*/
diff --git a/hw/vigs/vigs_gl_backend_cgl.c b/hw/vigs/vigs_gl_backend_cgl.c
index 7a41d0a8ab..cc0eabe2e5 100644
--- a/hw/vigs/vigs_gl_backend_cgl.c
+++ b/hw/vigs/vigs_gl_backend_cgl.c
@@ -62,7 +62,7 @@ static const CGLPixelFormatAttribute pixel_format_legacy_attrs[] =
kCGLPFAAlphaSize, 8,
kCGLPFADepthSize, 24,
kCGLPFAStencilSize, 8,
- kCGLPFAPBuffer,
+ kCGLPFAOpenGLProfile, kCGLOGLPVersion_Legacy,
0
};
@@ -255,7 +255,7 @@ struct vigs_backend *vigs_gl_backend_create(void *display,
CGLError error;
CGLPixelFormatObj pixel_format;
int n;
- CGLContextObj qt5_ctx = NULL;
+ CGLContextObj share_ctx = NULL;
gl_backend_cgl = g_malloc0(sizeof(*gl_backend_cgl));
@@ -378,15 +378,15 @@ struct vigs_backend *vigs_gl_backend_create(void *display,
}
if (vigs_qt5_onscreen_enabled()) {
- qt5_ctx = (CGLContextObj)vigs_qt5_gl_context_create(gl_backend_cgl->base.is_gl_2);
- if (!qt5_ctx) {
+ share_ctx = (CGLContextObj)vigs_qt5_gl_context_get();
+ if (!share_ctx) {
goto fail2;
}
}
if (!vigs_gl_backend_cgl_create_context(gl_backend_cgl,
pixel_format,
- qt5_ctx,
+ share_ctx,
&gl_backend_cgl->context)) {
goto fail3;
}
diff --git a/hw/vigs/vigs_gl_backend_glx.c b/hw/vigs/vigs_gl_backend_glx.c
index 4014a832e3..8212b88dbb 100644
--- a/hw/vigs/vigs_gl_backend_glx.c
+++ b/hw/vigs/vigs_gl_backend_glx.c
@@ -238,7 +238,7 @@ static GLXFBConfig vigs_gl_backend_glx_get_config(struct vigs_gl_backend_glx *gl
};
if (gl_backend_glx->glXQueryContext(gl_backend_glx->dpy,
- gl_backend_glx->ctx,
+ vigs_qt5_gl_context_get(),
GLX_FBCONFIG_ID,
&config_attribs[1]) != Success) {
VIGS_LOG_CRITICAL("Unable to get context's GLX config");
@@ -417,7 +417,7 @@ static void vigs_gl_backend_glx_destroy(struct vigs_backend *backend)
gl_backend_glx->glXDestroyPbuffer(gl_backend_glx->dpy,
gl_backend_glx->read_pixels_sfc);
}
- if (!vigs_qt5_onscreen_enabled() && gl_backend_glx->ctx) {
+ if (gl_backend_glx->ctx) {
gl_backend_glx->glXDestroyContext(gl_backend_glx->dpy,
gl_backend_glx->ctx);
}
@@ -443,6 +443,7 @@ struct vigs_backend *vigs_gl_backend_create(void *display,
{
struct vigs_gl_backend_glx *gl_backend_glx;
GLXFBConfig config;
+ GLXContext share_ctx = NULL;
Display *x_display = display;
gl_backend_glx = g_malloc0(sizeof(*gl_backend_glx));
@@ -574,57 +575,35 @@ struct vigs_backend *vigs_gl_backend_create(void *display,
}
if (vigs_qt5_onscreen_enabled()) {
- gl_backend_glx->ctx =
- (GLXContext)vigs_qt5_gl_context_create(gl_backend_glx->base.is_gl_2);
-
- if (!gl_backend_glx->ctx) {
- goto fail2;
- }
-
- config = vigs_gl_backend_glx_get_config(gl_backend_glx);
-
- if (!config) {
- goto fail2;
- }
-
- if (!vigs_gl_backend_glx_create_surface(gl_backend_glx,
- config,
- &gl_backend_glx->read_pixels_sfc)) {
+ share_ctx = (GLXContext)vigs_qt5_gl_context_get();
+ if (!share_ctx) {
goto fail2;
}
+ }
- if (!vigs_gl_backend_glx_create_context(gl_backend_glx,
- config,
- gl_backend_glx->ctx,
- &gl_backend_glx->read_pixels_ctx)) {
- goto fail2;
- }
- } else {
- config = vigs_gl_backend_glx_get_config(gl_backend_glx);
-
- if (!config) {
- goto fail2;
- }
+ config = vigs_gl_backend_glx_get_config(gl_backend_glx);
+ if (!config) {
+ goto fail2;
+ }
- if (!vigs_gl_backend_glx_create_surface(gl_backend_glx,
- config,
- &gl_backend_glx->read_pixels_sfc)) {
- goto fail2;
- }
+ if (!vigs_gl_backend_glx_create_surface(gl_backend_glx,
+ config,
+ &gl_backend_glx->read_pixels_sfc)) {
+ goto fail2;
+ }
- if (!vigs_gl_backend_glx_create_context(gl_backend_glx,
- config,
- NULL,
- &gl_backend_glx->ctx)) {
- goto fail2;
- }
+ if (!vigs_gl_backend_glx_create_context(gl_backend_glx,
+ config,
+ share_ctx,
+ &gl_backend_glx->ctx)) {
+ goto fail2;
+ }
- if (!vigs_gl_backend_glx_create_context(gl_backend_glx,
- config,
- gl_backend_glx->ctx,
- &gl_backend_glx->read_pixels_ctx)) {
- goto fail2;
- }
+ if (!vigs_gl_backend_glx_create_context(gl_backend_glx,
+ config,
+ gl_backend_glx->ctx,
+ &gl_backend_glx->read_pixels_ctx)) {
+ goto fail2;
}
if (!vigs_gl_backend_glx_create_surface(gl_backend_glx,
@@ -655,7 +634,7 @@ fail2:
gl_backend_glx->glXDestroyPbuffer(gl_backend_glx->dpy,
gl_backend_glx->read_pixels_sfc);
}
- if (!vigs_qt5_onscreen_enabled() && gl_backend_glx->ctx) {
+ if (gl_backend_glx->ctx) {
gl_backend_glx->glXDestroyContext(gl_backend_glx->dpy,
gl_backend_glx->ctx);
}
diff --git a/hw/vigs/vigs_gl_backend_wgl.c b/hw/vigs/vigs_gl_backend_wgl.c
index b5b45bcef0..9db01a0a7e 100644
--- a/hw/vigs/vigs_gl_backend_wgl.c
+++ b/hw/vigs/vigs_gl_backend_wgl.c
@@ -482,7 +482,7 @@ struct vigs_backend *vigs_gl_backend_create(void *display,
};
const char *ext_str = NULL;
struct vigs_gl_backend_wgl *gl_backend_wgl = NULL;
- HGLRC qt5_ctx = NULL;
+ HGLRC share_ctx = NULL;
vigs_win_class.cbSize = sizeof(WNDCLASSEXA);
vigs_win_class.style = 0;
@@ -687,9 +687,8 @@ struct vigs_backend *vigs_gl_backend_create(void *display,
tmp_win = NULL;
if (vigs_qt5_onscreen_enabled()) {
- qt5_ctx =
- (HGLRC)vigs_qt5_gl_context_create(gl_backend_wgl->base.is_gl_2);
- if (!qt5_ctx) {
+ share_ctx = (HGLRC)vigs_qt5_gl_context_get();
+ if (!share_ctx) {
goto fail;
}
}
@@ -729,7 +728,7 @@ struct vigs_backend *vigs_gl_backend_create(void *display,
}
if (!vigs_gl_backend_wgl_create_context(gl_backend_wgl,
- qt5_ctx,
+ share_ctx,
&gl_backend_wgl->ctx)) {
goto fail;
}
diff --git a/hw/vigs/vigs_onscreen_server.c b/hw/vigs/vigs_onscreen_server.c
index 7fcc352b33..d6830783cd 100644
--- a/hw/vigs/vigs_onscreen_server.c
+++ b/hw/vigs/vigs_onscreen_server.c
@@ -32,6 +32,24 @@
#include "vigs_log.h"
#include "work_queue.h"
+struct vigs_display_work_item
+{
+ struct work_queue_item base;
+
+ struct vigs_server *server;
+};
+
+static void vigs_onscreen_server_display_work(struct work_queue_item *wq_item)
+{
+ struct vigs_display_work_item *item = (struct vigs_display_work_item*)wq_item;
+ struct vigs_server *server = item->server;
+
+ server->backend->display(server->backend, NULL);
+ vigs_server_finish_update_display(server, false);
+
+ g_free(item);
+}
+
static bool vigs_onscreen_server_begin_update(struct vigs_server *server,
bool is_capturing,
bool force)
@@ -52,10 +70,6 @@ static bool vigs_onscreen_server_begin_update(struct vigs_server *server,
goto out;
}
- onscreen_server->updated = false;
- onscreen_server->composited = false;
- onscreen_server->dirty = false;
-
out:
qemu_mutex_unlock(&onscreen_server->mutex);
@@ -68,73 +82,37 @@ static void vigs_onscreen_server_finish_update(struct vigs_server *server,
{
struct vigs_onscreen_server *onscreen_server =
(struct vigs_onscreen_server*)server;
-
- qemu_mutex_lock(&onscreen_server->mutex);
-
- onscreen_server->updated = true;
- onscreen_server->composited = composited;
- onscreen_server->dirty = dirty;
-
- qemu_mutex_unlock(&onscreen_server->mutex);
-
- qemu_cond_signal(&onscreen_server->cond);
-}
-
-static bool vigs_onscreen_server_display(struct vigs_server *server,
- bool *displayed)
-{
- struct vigs_onscreen_server *onscreen_server =
- (struct vigs_onscreen_server*)server;
bool force = false;
qemu_mutex_lock(&onscreen_server->mutex);
- /*
- * Wait until rendering is finished.
- */
- while (!onscreen_server->updated) {
- qemu_cond_wait(&onscreen_server->cond, &onscreen_server->mutex);
- }
-
if (onscreen_server->invalidate_cnt > 0) {
--onscreen_server->invalidate_cnt;
force = true;
}
- onscreen_server->updated = false;
-
qemu_mutex_unlock(&onscreen_server->mutex);
- *displayed = true;
+ if (composited || force) {
+ struct vigs_display_work_item *item;
- if (onscreen_server->dirty) {
- /*
- * Software composition took place, finish ASAP and
- * process captured data.
- */
- vigs_server_finish_update_display(server, true);
- return vigs_server_process_captured(server, force);
- } else if (onscreen_server->composited) {
- /*
- * Hw composition took place, display the content.
- */
- server->backend->display(server->backend, NULL);
- } else if (force) {
- /*
- * Nothing happened, but if it's a forced display, then
- * we should try to display hw stuff first, if there isn't any
- * then display sw stuff.
- */
- if (!server->backend->display(server->backend, NULL)) {
- vigs_server_finish_update_display(server, false);
- return vigs_server_process_captured(server, force);
- }
+ item = g_malloc(sizeof(*item));
+
+ work_queue_item_init(&item->base, &vigs_onscreen_server_display_work);
+
+ item->server = server;
+
+ work_queue_add_item(onscreen_server->display_queue, &item->base);
} else {
- *displayed = false;
+ vigs_server_finish_update_display(server, false);
}
- vigs_server_finish_update_display(server, false);
+}
+static bool vigs_onscreen_server_display(struct vigs_server *server,
+ bool *displayed)
+{
+ *displayed = false;
return false;
}
@@ -150,7 +128,6 @@ static void vigs_onscreen_server_destroy(struct vigs_server *server)
struct vigs_onscreen_server *onscreen_server =
(struct vigs_onscreen_server*)server;
- qemu_cond_destroy(&onscreen_server->cond);
qemu_mutex_destroy(&onscreen_server->mutex);
vigs_server_cleanup(server);
@@ -178,7 +155,8 @@ struct vigs_server *vigs_onscreen_server_create(uint8_t *vram_ptr,
}
qemu_mutex_init(&server->mutex);
- qemu_cond_init(&server->cond);
+
+ server->display_queue = render_queue;
server->base.begin_update = &vigs_onscreen_server_begin_update;
server->base.finish_update = &vigs_onscreen_server_finish_update;
diff --git a/hw/vigs/vigs_onscreen_server.h b/hw/vigs/vigs_onscreen_server.h
index b0ea1e93d7..19d083e49c 100644
--- a/hw/vigs/vigs_onscreen_server.h
+++ b/hw/vigs/vigs_onscreen_server.h
@@ -37,12 +37,8 @@ struct vigs_onscreen_server
struct vigs_server base;
QemuMutex mutex;
- QemuCond cond;
- bool updated;
- bool composited;
- bool dirty;
-
int invalidate_cnt;
+ struct work_queue *display_queue;
};
struct vigs_server *vigs_onscreen_server_create(uint8_t *vram_ptr,
diff --git a/hw/vigs/vigs_qt5.cpp b/hw/vigs/vigs_qt5.cpp
index 927d558320..286014eff7 100644
--- a/hw/vigs/vigs_qt5.cpp
+++ b/hw/vigs/vigs_qt5.cpp
@@ -27,27 +27,26 @@
*
*/
-#include "vigs_qt5.h"
-#include "config-host.h"
+#include <stdio.h>
#include <QGuiApplication>
#include <QOpenGLContext>
#include <qpa/qplatformnativeinterface.h>
-#include <stdio.h>
+#include "config-host.h"
+#include "vigs_qt5.h"
extern bool qt5IsOnscreen;
extern QApplication *qt5App;
extern QOpenGLContext *qt5GLContext;
-extern QSurfaceFormat qt5GLFormat;
extern void qt5_register_capture_request_listener(void *listener,
void (*handler)(void *));
extern void qt5_unregister_capture_request_listener(void *listener);
extern void qt5_process_captured(bool captured, void *pixels,
int width, int height);
+extern void qt5_update_texture(unsigned int tex_id);
bool vigs_qt5_onscreen_enabled(void)
{
- // TODO: on Darwin?
if (qt5App != NULL && qt5IsOnscreen) {
return true;
}
@@ -67,7 +66,7 @@ void *vigs_qt5_display(void)
QGuiApplication::primaryScreen());
}
-void *vigs_qt5_gl_context_create(bool is_gl2)
+void *vigs_qt5_gl_context_get(void)
{
if (!qt5App) {
fprintf(stderr, "QT5 not enabled!\n");
@@ -75,79 +74,27 @@ void *vigs_qt5_gl_context_create(bool is_gl2)
}
if (qt5GLContext) {
- fprintf(stderr, "QT5 GL context already created!\n");
- return NULL;
- }
-
- qt5GLContext = new QOpenGLContext();
-
- QSurfaceFormat format;
-
- format.setRedBufferSize(8);
- format.setGreenBufferSize(8);
- format.setBlueBufferSize(8);
- format.setAlphaBufferSize(8);
- format.setDepthBufferSize(24);
- format.setStencilBufferSize(8);
-
- if (!is_gl2) {
- format.setMajorVersion(3);
-#ifdef CONFIG_DARWIN
- format.setMinorVersion(2);
- format.setProfile(QSurfaceFormat::CoreProfile);
-#else
- format.setMinorVersion(1);
-#endif
- }
-
- qt5GLContext->setScreen(QGuiApplication::primaryScreen());
- qt5GLContext->setFormat(format);
-
- if (!qt5GLContext->create()) {
- fprintf(stderr, "Cannot create QT5 GL context!\n");
-
- delete qt5GLContext;
- qt5GLContext = NULL;
-
- return NULL;
- }
-
- if (!is_gl2) {
- if ((qt5GLContext->format().majorVersion() < 3) ||
- ((qt5GLContext->format().majorVersion() == 3) &&
- (qt5GLContext->format().minorVersion() < 1))) {
- fprintf(stderr, "Cannot create QT5 3.1 GL context!\n");
-
- delete qt5GLContext;
- qt5GLContext = NULL;
-
- return NULL;
- }
- }
-
- QPlatformNativeInterface *native =
- QGuiApplication::platformNativeInterface();
+ QPlatformNativeInterface *native =
+ QGuiApplication::platformNativeInterface();
- void *ret = NULL;
+ void *ret = NULL;
#if defined(CONFIG_LINUX)
- ret = native->nativeResourceForContext(QByteArray("glxcontext"), qt5GLContext);
+ ret = native->nativeResourceForContext(QByteArray("glxcontext"),
+ qt5GLContext);
#elif defined(CONFIG_WIN32)
- ret = native->nativeResourceForContext(QByteArray("renderingContext"), qt5GLContext);
+ ret = native->nativeResourceForContext(QByteArray("renderingContext"),
+ qt5GLContext);
#elif defined(CONFIG_DARWIN)
- ret = native->nativeResourceForContext(QByteArray("cglContextObj"), qt5GLContext);
+ ret = native->nativeResourceForContext(QByteArray("cglContextObj"),
+ qt5GLContext);
#endif
-
- if (!ret) {
- fprintf(stderr, "Cannot get native QT5 GL context!\n");
-
- delete qt5GLContext;
- qt5GLContext = NULL;
+ if (!ret) {
+ fprintf(stderr, "Cannot get native QT5 GL context!\n");
+ }
+ return ret;
}
-
- qt5GLFormat = format;
-
- return ret;
+ return NULL;
}
void vigs_qt5_register_capture_request_listener(void *listener,
@@ -166,3 +113,8 @@ void vigs_qt5_process_captured(bool captured, void *pixels,
{
qt5_process_captured(captured, pixels, width, height);
}
+
+void vigs_qt5_dpy_render_texture(uint32_t tex_id)
+{
+ qt5_update_texture(tex_id);
+}
diff --git a/hw/vigs/vigs_qt5.h b/hw/vigs/vigs_qt5.h
index b88c84ebf8..a27ae6184b 100644
--- a/hw/vigs/vigs_qt5.h
+++ b/hw/vigs/vigs_qt5.h
@@ -38,14 +38,14 @@ bool vigs_qt5_onscreen_enabled(void);
void *vigs_qt5_display(void);
-void *vigs_qt5_gl_context_create(bool is_gl2);
+void *vigs_qt5_gl_context_get(void);
void vigs_qt5_register_capture_request_listener(void *listener,
void (*handler)(void *));
void vigs_qt5_unregister_capture_request_listener(void *listener);
void vigs_qt5_process_captured(bool captured, void *pixels,
int width, int height);
-
+void vigs_qt5_dpy_render_texture(uint32_t tex_id);
#ifdef __cplusplus
};
#endif
diff --git a/hw/vigs/vigs_qt5_stub.c b/hw/vigs/vigs_qt5_stub.c
index 9b3c80729b..cf490f323c 100644
--- a/hw/vigs/vigs_qt5_stub.c
+++ b/hw/vigs/vigs_qt5_stub.c
@@ -34,17 +34,6 @@
#include "emulator_common.h"
#include "vigs_qt5.h"
-uint32_t qt5_window_width = 0;
-uint32_t qt5_window_height = 0;
-int qt5_window_angle = 0;
-
-/* mutlitouch data */
-float *qt5_mt_points = NULL;
-int qt5_mt_count = 0;
-const void *qt5_mt_pixels = NULL;
-int qt5_mt_width = 0;
-int qt5_mt_height = 0;
-
bool vigs_qt5_onscreen_enabled(void)
{
return false;
@@ -55,7 +44,7 @@ void *vigs_qt5_display(void)
return NULL;
}
-void *vigs_qt5_gl_context_create(bool is_gl2)
+void *vigs_qt5_gl_context_get(void)
{
return NULL;
}
@@ -76,3 +65,9 @@ void vigs_qt5_process_captured(bool captured, void *pixels,
{
return;
}
+
+void vigs_qt5_dpy_render_texture(uint32_t tex_id)
+{
+ return;
+}
+