diff src/video/SDL_renderer_gles.c @ 4525:3abf0b9cafad

pelya 2010-07-12 03:53:48 PDT In function GLES_RenderCopy() in SDL_renderer_gles.c:819 there is one memcpy() that can be avoided if we're updating whole texture. Because of that the SDL 1.3 in compatibility mode is working even slower than software rendering in SDL 1.2.
author Sam Lantinga <slouken@libsdl.org>
date Wed, 14 Jul 2010 07:31:35 -0700
parents f7b03b6838cb
children aa8888658021
line wrap: on
line diff
--- a/src/video/SDL_renderer_gles.c	Wed Jul 14 07:25:07 2010 -0700
+++ b/src/video/SDL_renderer_gles.c	Wed Jul 14 07:31:35 2010 -0700
@@ -822,20 +822,25 @@
                maybe it'd be a good idea to keep a temp buffer around
                for this purpose rather than allocating it each time
              */
-            temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
-            temp_ptr = temp_buffer;
-            for (i = 0; i < rect->h; i++) {
-                SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
-                temp_ptr += rect->w * bpp;
-                pixels += pitch;
+            if( rect->x == 0 && rect->w * bpp == pitch ) {
+                temp_buffer = pixels; /* Updating whole texture, no need to reformat */
+            } else {
+                temp_buffer = SDL_malloc(rect->w * rect->h * bpp);
+                temp_ptr = temp_buffer;
+                for (i = 0; i < rect->h; i++) {
+                    SDL_memcpy(temp_ptr, pixels, rect->w * bpp);
+                    temp_ptr += rect->w * bpp;
+                    pixels += pitch;
+                }
             }
 
             data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y,
                                   rect->w, rect->h, texturedata->format,
                                   texturedata->formattype, temp_buffer);
 
-            SDL_free(temp_buffer);
-
+            if( temp_buffer != pixels ) {
+                SDL_free(temp_buffer);
+            }
         }
         SDL_ClearDirtyRects(&texturedata->dirty);
     }