summaryrefslogtreecommitdiff
path: root/meme/gui.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-13 00:49:24 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-13 00:49:24 (GMT)
commit72fba9389e57930a7c14e13d38a6623d3d68a339 (patch)
tree2c018b0557a974e2b6e45d2c70235a2117d95537 /meme/gui.c
parentc2527f76ad3d79cc087640b62b9e27f14b3e6869 (diff)
downloadmisc-72fba9389e57930a7c14e13d38a6623d3d68a339.zip
misc-72fba9389e57930a7c14e13d38a6623d3d68a339.tar.gz
misc-72fba9389e57930a7c14e13d38a6623d3d68a339.tar.bz2
meme/gui.c: use SDL_HWSURFACE; time redraws
Redraws with SDL_HWSURFACE are about 10-20% faster than with SDL_SWSURFACE.
Diffstat (limited to 'meme/gui.c')
-rw-r--r--meme/gui.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/meme/gui.c b/meme/gui.c
index 9924c46..73dbe88 100644
--- a/meme/gui.c
+++ b/meme/gui.c
@@ -27,6 +27,8 @@
#define XRES 1280
#define YRES 1024
+#define SDL_SURFACE SDL_HWSURFACE
+
#define CURSOR_R 5
#define EDGE_RGBA 0x000000ff
@@ -213,7 +215,7 @@ static void change(SDL_Surface *s, int x, int y, int w, int h)
* a surface that's compatible with the display ?
*/
c = alloc_type(struct change);
- tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 0, 0, 0, 0, 0);
+ tmp = SDL_CreateRGBSurface(SDL_SURFACE, w, h, 0, 0, 0, 0, 0);
if (!tmp) {
fprintf(stderr, "SDL_CreateRGBSurface failed\n");
exit(1);
@@ -651,7 +653,7 @@ void gui(void)
}
atexit(SDL_Quit);
- surf = SDL_SetVideoMode(XRES, YRES, 0, SDL_SWSURFACE);
+ surf = SDL_SetVideoMode(XRES, YRES, 0, SDL_SURFACE);
if (!surf) {
fprintf(stderr, "SDL_SetVideoMode: %s\n", SDL_GetError());
exit(1);
@@ -663,9 +665,13 @@ void gui(void)
zoom = 7;
while (1) {
+struct time t;
discard_changes();
SDL_LockSurface(surf);
+time_start(&t);
draw(surf);
+time_stop(&t);
+fprintf(stderr, "%.3f s @ zoom %d\n", time_ms(&t)/1000.0, zoom);
SDL_UnlockSurface(surf);
SDL_UpdateRect(surf, 0, 0, 0, 0);