From: Mateusz Majewski Date: Wed, 19 Jun 2024 08:03:54 +0000 (+0200) Subject: progress X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2bfa41933fe7363cf3a03dcc22afd66ab546d659;p=sdk%2Femulator%2Fqemu.git progress Change-Id: I1799be6c34df1d318bda0a4a9b7aa3b243b2dcd5 --- diff --git a/tizen/src/ui/Makefile.objs b/tizen/src/ui/Makefile.objs index 479b3f7a91..8c8feecc8c 100644 --- a/tizen/src/ui/Makefile.objs +++ b/tizen/src/ui/Makefile.objs @@ -35,8 +35,6 @@ $(obj)/moc_displayglwidget.cpp: $(obj)/displayglwidget.h moc $< -o $@ $(obj)/moc_displayswwidget.cpp: $(obj)/displayswwidget.h moc $< -o $@ -$(obj)/moc_displayqemuglwidget.cpp: $(obj)/displayqemuglwidget.h - moc $< -o $@ $(obj)/moc_mainwindow.cpp: $(obj)/mainwindow.h moc $< -o $@ $(obj)/moc_skinkeyitem.cpp: $(obj)/skinkeyitem.h diff --git a/tizen/src/ui/displayglwidget.cpp b/tizen/src/ui/displayglwidget.cpp index 3cd6523462..e6af18541f 100644 --- a/tizen/src/ui/displayglwidget.cpp +++ b/tizen/src/ui/displayglwidget.cpp @@ -522,7 +522,6 @@ void DisplayGLWidget::paintGL() textureListMutex.unlock(); if (current) { - fprintf(stderr, "will show %d\n", current->tex); drawQuad(current->tex, false); } diff --git a/tizen/src/ui/qt5.c b/tizen/src/ui/qt5.c index 9002784377..931c5a6ce2 100644 --- a/tizen/src/ui/qt5.c +++ b/tizen/src/ui/qt5.c @@ -60,6 +60,10 @@ static struct qt5_state { bool updated; ConsoleGLState *gls; QEMUGLContext ctx; + bool is_scanout; + uint32_t scanout_fbs[2]; + bool backing_y_0_top; + uint32_t backing_width, backing_height; #endif } *qt5_console; @@ -121,11 +125,13 @@ static void qt5_gl_update(DisplayChangeListener *dcl, int x, int y, int w, int h) { struct qt5_state *con = container_of(dcl, struct qt5_state, dcl); - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); + + if (con->is_scanout) + return; + if (con->ctx) qt5_gl_make_context_current_internal(con->ctx); surface_gl_update_texture(con->gls, con->surface, x, y, w, h); - fprintf(stderr, "rendered %d\n", con->surface->texture); con->updated = true; } @@ -133,7 +139,7 @@ static void qt5_gl_switch(DisplayChangeListener *dcl, DisplaySurface *new_surface) { struct qt5_state *con = container_of(dcl, struct qt5_state, dcl); - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); + if (con->ctx) qt5_gl_make_context_current_internal(con->ctx); @@ -155,24 +161,22 @@ static void qt5_gl_switch(DisplayChangeListener *dcl, con->surface = new_surface; con->gen += 1; + // TODO: con->is_scanout? surface_gl_create_texture(con->gls, con->surface); - fprintf(stderr, "created %d\n", con->surface->texture); } static void qt5_gl_refresh(DisplayChangeListener *dcl) { struct qt5_state *con = container_of(dcl, struct qt5_state, dcl); - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); + if (con->ctx) qt5_gl_make_context_current_internal(con->ctx); graphic_hw_update(dcl->con); - if (con->surface && con->updated) { - fprintf(stderr, "sending %d\n", con->surface->texture); + if (con->surface && !con->is_scanout && con->updated) { con->surface->texture = qt5_gl_refresh_internal(con->surface->texture, surface_width(con->surface), surface_height(con->surface), con->gen); if (con->surface->texture == 0) { surface_gl_create_texture(con->gls, con->surface); - fprintf(stderr, "created %d\n", con->surface->texture); } con->updated = false; } @@ -196,20 +200,17 @@ static QEMUGLContext qt5_gl_create_context(DisplayChangeListener *dcl, static void qt5_gl_destroy_context(DisplayChangeListener *dcl, QEMUGLContext ctx) { - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); qt5_gl_destroy_context_internal(ctx); } static int qt5_gl_make_context_current(DisplayChangeListener *dcl, QEMUGLContext ctx) { - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); qt5_gl_make_context_current_internal(ctx); } static QEMUGLContext qt5_gl_get_current_context(DisplayChangeListener *dcl) { - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); return qt5_gl_get_current_context_internal(); } @@ -220,7 +221,29 @@ static void qt5_gl_scanout(DisplayChangeListener *dcl, uint32_t w, uint32_t h) { struct qt5_state *con = container_of(dcl, struct qt5_state, dcl); - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); + + if (backing_id == 0) { + con->is_scanout = false; + return; + } + con->is_scanout = true; + + if (con->ctx) + qt5_gl_make_context_current_internal(con->ctx); + + con->backing_y_0_top = backing_y_0_top; + con->backing_width = backing_width; + con->backing_height = backing_height; + + if (con->scanout_fbs[0] == 0) { + // TODO: these leak? + glGenFramebuffers(2, con->scanout_fbs); + } + + glBindFramebuffer(GL_READ_FRAMEBUFFER, con->scanout_fbs[0]); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, con->scanout_fbs[1]); + glFramebufferTexture2DEXT(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, backing_id, 0); } @@ -228,8 +251,23 @@ static void qt5_gl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { struct qt5_state *con = container_of(dcl, struct qt5_state, dcl); - fprintf(stderr, "in %s %s:%d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__); + if (con->ctx) + qt5_gl_make_context_current_internal(con->ctx); + + glFramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, con->surface->texture, 0); + + uint32_t y1 = con->backing_y_0_top ? con->backing_height : 0; + uint32_t y2 = con->backing_y_0_top ? 0 : con->backing_height; + glBlitFramebuffer(0, y1, con->backing_width, y2, + 0, 0, surface_width(con->surface), surface_height(con->surface), + GL_COLOR_BUFFER_BIT, GL_NEAREST); + + con->surface->texture = qt5_gl_refresh_internal(con->surface->texture, surface_width(con->surface), surface_height(con->surface), con->gen); + if (con->surface->texture == 0) { + surface_gl_create_texture(con->gls, con->surface); + } } static const DisplayChangeListenerOps dcl_ops = { @@ -341,15 +379,17 @@ void maru_qt5_display_init(DisplayState *ds, int full_screen) qt5_console = g_new0(struct qt5_state, qt5_num_outputs); for (i = 0; i < qt5_num_outputs; i++) { QemuConsole *con = qemu_console_lookup_by_index(i); - fprintf(stderr, "opengl is %d\n", display_opengl); qt5_console[i].dcl.ops = display_opengl ? &dcl_gl_ops : &dcl_ops; qt5_console[i].dcl.con = con; register_displaychangelistener(&qt5_console[i].dcl); qt5_console[i].idx = i; + qt5_console[i].gen = 0; qt5_console[i].updated = false; qt5_console[i].gls = NULL; qt5_console[i].ctx = qt5_gl_create_context_internal(3, 3); + qt5_console[i].is_scanout = false; + qt5_console[i].scanout_fbs[0] = 0; } if (full_screen) { diff --git a/tizen/src/ui/qt5_supplement.cpp b/tizen/src/ui/qt5_supplement.cpp index 375f7af086..fb450fd1c5 100644 --- a/tizen/src/ui/qt5_supplement.cpp +++ b/tizen/src/ui/qt5_supplement.cpp @@ -626,7 +626,7 @@ uint32_t qt5_gl_refresh_internal(uint32_t tex, uint32_t width, uint32_t height, qemu_mutex_lock(&item->mutex); bool ok = dpy_item_gen[item_id] == 0 || item->available; if (ok) { - if (dpy_item_gen[item_id] == gen) { + if (dpy_item_gen[item_id] == gen && /* HACK HACK HACK */ item->tex >= 25) { ret = item->tex; } else { // TODO: we will leak a texture soon! diff --git a/ui/sdl2-gl.c b/ui/sdl2-gl.c index 2e812ba0ca..039645df3e 100644 --- a/ui/sdl2-gl.c +++ b/ui/sdl2-gl.c @@ -191,59 +191,59 @@ void sdl2_gl_scanout(DisplayChangeListener *dcl, uint32_t w, uint32_t h) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); - // - // assert(scon->opengl); - // scon->x = x; - // scon->y = y; - // scon->w = w; - // scon->h = h; - // scon->tex_id = backing_id; - // scon->y0_top = backing_y_0_top; - // - // SDL_GL_MakeCurrent(scon->real_window, scon->winctx); - // - // if (scon->tex_id == 0 || scon->w == 0 || scon->h == 0) { - // sdl2_set_scanout_mode(scon, false); - // return; - // } - // - // sdl2_set_scanout_mode(scon, true); - // if (!scon->fbo_id) { - // glGenFramebuffers(1, &scon->fbo_id); - // } - // - // glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id); - // glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, - // GL_TEXTURE_2D, scon->tex_id, 0); + + assert(scon->opengl); + scon->x = x; + scon->y = y; + scon->w = w; + scon->h = h; + scon->tex_id = backing_id; + scon->y0_top = backing_y_0_top; + + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); + + if (scon->tex_id == 0 || scon->w == 0 || scon->h == 0) { + sdl2_set_scanout_mode(scon, false); + return; + } + + sdl2_set_scanout_mode(scon, true); + if (!scon->fbo_id) { + glGenFramebuffers(1, &scon->fbo_id); + } + + glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_TEXTURE_2D, scon->tex_id, 0); } void sdl2_gl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); - // int ww, wh, y1, y2; - // - // assert(scon->opengl); - // if (!scon->scanout_mode) { - // return; - // } - // if (!scon->fbo_id) { - // return; - // } - // - // SDL_GL_MakeCurrent(scon->real_window, scon->winctx); - // - // glBindFramebuffer(GL_READ_FRAMEBUFFER, scon->fbo_id); - // glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); - // - // SDL_GetWindowSize(scon->real_window, &ww, &wh); - // glViewport(0, 0, ww, wh); - // y1 = scon->y0_top ? 0 : scon->h; - // y2 = scon->y0_top ? scon->h : 0; - // glBlitFramebuffer(0, y1, scon->w, y2, - // 0, 0, ww, wh, - // GL_COLOR_BUFFER_BIT, GL_NEAREST); - // glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id); - // - // SDL_GL_SwapWindow(scon->real_window); + int ww, wh, y1, y2; + + assert(scon->opengl); + if (!scon->scanout_mode) { + return; + } + if (!scon->fbo_id) { + return; + } + + SDL_GL_MakeCurrent(scon->real_window, scon->winctx); + + glBindFramebuffer(GL_READ_FRAMEBUFFER, scon->fbo_id); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); + + SDL_GetWindowSize(scon->real_window, &ww, &wh); + glViewport(0, 0, ww, wh); + y1 = scon->y0_top ? 0 : scon->h; + y2 = scon->y0_top ? scon->h : 0; + glBlitFramebuffer(0, y1, scon->w, y2, + 0, 0, ww, wh, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + glBindFramebuffer(GL_FRAMEBUFFER_EXT, scon->fbo_id); + + SDL_GL_SwapWindow(scon->real_window); }