Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
4524:a256e1dadf3f | 4525:3abf0b9cafad |
---|---|
820 we must do this reformatting ourselves(!) | 820 we must do this reformatting ourselves(!) |
821 | 821 |
822 maybe it'd be a good idea to keep a temp buffer around | 822 maybe it'd be a good idea to keep a temp buffer around |
823 for this purpose rather than allocating it each time | 823 for this purpose rather than allocating it each time |
824 */ | 824 */ |
825 temp_buffer = SDL_malloc(rect->w * rect->h * bpp); | 825 if( rect->x == 0 && rect->w * bpp == pitch ) { |
826 temp_ptr = temp_buffer; | 826 temp_buffer = pixels; /* Updating whole texture, no need to reformat */ |
827 for (i = 0; i < rect->h; i++) { | 827 } else { |
828 SDL_memcpy(temp_ptr, pixels, rect->w * bpp); | 828 temp_buffer = SDL_malloc(rect->w * rect->h * bpp); |
829 temp_ptr += rect->w * bpp; | 829 temp_ptr = temp_buffer; |
830 pixels += pitch; | 830 for (i = 0; i < rect->h; i++) { |
831 SDL_memcpy(temp_ptr, pixels, rect->w * bpp); | |
832 temp_ptr += rect->w * bpp; | |
833 pixels += pitch; | |
834 } | |
831 } | 835 } |
832 | 836 |
833 data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, | 837 data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, |
834 rect->w, rect->h, texturedata->format, | 838 rect->w, rect->h, texturedata->format, |
835 texturedata->formattype, temp_buffer); | 839 texturedata->formattype, temp_buffer); |
836 | 840 |
837 SDL_free(temp_buffer); | 841 if( temp_buffer != pixels ) { |
838 | 842 SDL_free(temp_buffer); |
843 } | |
839 } | 844 } |
840 SDL_ClearDirtyRects(&texturedata->dirty); | 845 SDL_ClearDirtyRects(&texturedata->dirty); |
841 } | 846 } |
842 | 847 |
843 data->glBindTexture(texturedata->type, texturedata->texture); | 848 data->glBindTexture(texturedata->type, texturedata->texture); |