Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

You don't need to copy the pixels into the streaming texture's pixel …

…data. This behavior is defined specifically to optimize the UpdateTexture path.
  • Loading branch information
slouken committed Feb 7, 2011
1 parent 03c72e7 commit b031b86487244e808a9036ccad9074987872743a
Showing with 3 additions and 25 deletions.
  1. +1 −1 Xcode-iPhoneOS/Demos/src/happy.c
  2. +2 −24 src/render/opengles2/SDL_render_gles2.c
@@ -164,7 +164,7 @@ main(int argc, char *argv[])
} else if (delay > MILLESECONDS_PER_FRAME) {
delay = MILLESECONDS_PER_FRAME;
}
//SDL_Delay(delay);
SDL_Delay(delay);
}

/* cleanup */
@@ -389,35 +389,13 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
tdata->pixel_format,
tdata->pixel_type,
src);
SDL_free(blob);

if (glGetError() != GL_NO_ERROR)
{
SDL_SetError("Failed to update texture");
return -1;
}

/* Update the (streaming) texture buffer, in one pass if possible */
if (tdata->pixel_data)
{
dest = (Uint8 *)tdata->pixel_data +
(tdata->pitch * rect->y) +
(SDL_BYTESPERPIXEL(texture->format) * rect->x);
if (rect->w == texture->w)
{
SDL_memcpy(dest, src, srcPitch * rect->h);
}
else
{
for (y = 0; y < rect->h; ++y)
{
SDL_memcpy(dest, src, srcPitch);
src += srcPitch;
dest += tdata->pitch;
}
}
}

/* Clean up and return */
SDL_free(blob);
return 0;
}

0 comments on commit b031b86

Please sign in to comment.