static void egl_scanout_flush(DisplayChangeListener *dcl, uint32_t x, uint32_t y, uint32_t w, uint32_t h) { egl_dpy *edpy = container_of(dcl, egl_dpy, dcl); if (!edpy->guest_fb.texture || !edpy->ds) { return; } assert(surface_width(edpy->ds) == edpy->guest_fb.width); assert(surface_height(edpy->ds) == edpy->guest_fb.height); assert(surface_format(edpy->ds) == PIXMAN_x8r8g8b8); if (edpy->cursor_fb.texture) { /* have cursor -> render using textures */ egl_texture_blit(edpy->gls, &edpy->blit_fb, &edpy->guest_fb, !edpy->y_0_top); egl_texture_blend(edpy->gls, &edpy->blit_fb, &edpy->cursor_fb, !edpy->y_0_top, edpy->pos_x, edpy->pos_y); } else { /* no cursor -> use simple framebuffer blit */ egl_fb_blit(&edpy->blit_fb, &edpy->guest_fb, edpy->y_0_top); } egl_fb_read(surface_data(edpy->ds), &edpy->blit_fb); dpy_gfx_update(edpy->dcl.con, x, y, w, h); }
void sdl2_2d_switch(DisplayChangeListener *dcl, DisplaySurface *new_surface) { struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl); DisplaySurface *old_surface = scon->surface; int format = 0; assert(!scon->opengl); scon->surface = new_surface; if (scon->texture) { SDL_DestroyTexture(scon->texture); scon->texture = NULL; } if (!new_surface) { sdl2_window_destroy(scon); return; } if (!scon->real_window) { sdl2_window_create(scon); } else if (old_surface && ((surface_width(old_surface) != surface_width(new_surface)) || (surface_height(old_surface) != surface_height(new_surface)))) { sdl2_window_resize(scon); } SDL_RenderSetLogicalSize(scon->real_renderer, surface_width(new_surface), surface_height(new_surface)); switch (surface_format(scon->surface)) { case PIXMAN_x1r5g5b5: format = SDL_PIXELFORMAT_ARGB1555; break; case PIXMAN_r5g6b5: format = SDL_PIXELFORMAT_RGB565; break; case PIXMAN_x8r8g8b8: format = SDL_PIXELFORMAT_ARGB8888; break; case PIXMAN_r8g8b8x8: format = SDL_PIXELFORMAT_RGBA8888; break; case PIXMAN_b8g8r8x8: format = SDL_PIXELFORMAT_BGRX8888; break; default: g_assert_not_reached(); } scon->texture = SDL_CreateTexture(scon->real_renderer, format, SDL_TEXTUREACCESS_STREAMING, surface_width(new_surface), surface_height(new_surface)); sdl2_2d_redraw(scon); }