[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 4/9] sdl: restore optimized redraw
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 4/9] sdl: restore optimized redraw |
Date: |
Fri, 16 Feb 2018 12:54:05 +0100 |
From: Anatoly Trosinenko <address@hidden>
The documentation on SDL_RenderPresent function states that
"the backbuffer should be considered invalidated after each present",
so copy the entire texture on each redraw.
On the other hand, SDL_UpdateTexture function is described as
"fairly slow function", so restrict it to just the changed pixels.
Also added SDL_RenderClear call, as suggested in the documentation
page on SDL_RenderPresent.
Signed-off-by: Anatoly Trosinenko <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
ui/sdl2-2d.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/ui/sdl2-2d.c b/ui/sdl2-2d.c
index 8ab68d67b9..1f34817bae 100644
--- a/ui/sdl2-2d.c
+++ b/ui/sdl2-2d.c
@@ -36,6 +36,8 @@ void sdl2_2d_update(DisplayChangeListener *dcl,
struct sdl2_console *scon = container_of(dcl, struct sdl2_console, dcl);
DisplaySurface *surf = qemu_console_surface(dcl->con);
SDL_Rect rect;
+ size_t surface_data_offset = surface_bytes_per_pixel(surf) * x +
+ surface_stride(surf) * y;
assert(!scon->opengl);
@@ -46,27 +48,16 @@ void sdl2_2d_update(DisplayChangeListener *dcl,
return;
}
- /*
- * SDL2 seems to do some double-buffering, and trying to only
- * update the changed areas results in only one of the two buffers
- * being updated. Which flickers alot. So lets not try to be
- * clever do a full update every time ...
- */
-#if 0
rect.x = x;
rect.y = y;
rect.w = w;
rect.h = h;
-#else
- rect.x = 0;
- rect.y = 0;
- rect.w = surface_width(surf);
- rect.h = surface_height(surf);
-#endif
- SDL_UpdateTexture(scon->texture, NULL, surface_data(surf),
+ SDL_UpdateTexture(scon->texture, &rect,
+ surface_data(surf) + surface_data_offset,
surface_stride(surf));
- SDL_RenderCopy(scon->real_renderer, scon->texture, &rect, &rect);
+ SDL_RenderClear(scon->real_renderer);
+ SDL_RenderCopy(scon->real_renderer, scon->texture, NULL, NULL);
SDL_RenderPresent(scon->real_renderer);
}
--
2.9.3
- [Qemu-devel] [PULL 0/9] Ui 20180216 patches, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 6/9] ui: avoid risk of 32-bit int overflow in VNC buffer check, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 4/9] sdl: restore optimized redraw,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 7/9] ui: avoid 'local_err' variable shadowing in VNC SASL auth, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 1/9] vnc: remove bogus object_unref on client socket, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 5/9] sdl2: fix mouse grab, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 3/9] vnc: fix segfault in closed connection handling, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 9/9] ui: extend VNC trottling tracing to SASL codepaths, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 8/9] ui: check VNC audio frequency limit at time of reading from client, Gerd Hoffmann, 2018/02/16
- [Qemu-devel] [PULL 2/9] vnc: add qapi/error.h include to stubs, Gerd Hoffmann, 2018/02/16
- Re: [Qemu-devel] [PULL 0/9] Ui 20180216 patches, Peter Maydell, 2018/02/16