From 027151ca6c373de9ef25de36b333d1285de71095 Mon Sep 17 00:00:00 2001 From: Pascal Massimino Date: Wed, 8 Feb 2017 16:34:57 +0100 Subject: [PATCH] don't erase the surface before blitting. It's done at HTML level with canvas.clearRect() BUG=webp:261 Change-Id: I83c73791f5922cd1f426f19faf856fa1cf8f0311 --- extras/webp_to_sdl.c | 4 ++-- webp_js/index.html | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/extras/webp_to_sdl.c b/extras/webp_to_sdl.c index b47c1e6e..461d4c72 100755 --- a/extras/webp_to_sdl.c +++ b/extras/webp_to_sdl.c @@ -60,6 +60,7 @@ int WebpToSDL(const char* data, unsigned int data_size) { 0x0000ff00u, // G mask 0x00ff0000u, // B mask 0xff000000u); // A mask + if (surface == NULL) { fprintf(stderr, "Unable to create %dx%d RGBA surface!\n", input->width, input->height); @@ -86,8 +87,7 @@ int WebpToSDL(const char* data, unsigned int data_size) { } if (SDL_MUSTLOCK(surface)) SDL_UnlockSurface(surface); - if (SDL_FillRect(screen, &screen->clip_rect, 0xffffffff) || - SDL_BlitSurface(surface, NULL, screen, NULL) || + if (SDL_BlitSurface(surface, NULL, screen, NULL) || SDL_Flip(screen)) { goto Error; } diff --git a/webp_js/index.html b/webp_js/index.html index 096ef151..3ac9325f 100644 --- a/webp_js/index.html +++ b/webp_js/index.html @@ -21,8 +21,11 @@ function init() { function decode(webp_data, canvas_id) { // get the canvas to decode into - Module.canvas = document.getElementById(canvas_id); - if (Module.canvas == null) return; + var canvas = document.getElementById(canvas_id); + if (canvas == null) return; + // clear previous picture (if any) + Module.canvas = canvas; + canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height); // decode and measure timing start = new Date(); var ret = WebpToCanvas(webp_data, webp_data.length);