Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
You don't need to copy the pixels into the streaming texture's pixel …
Browse files Browse the repository at this point in the history
…data. This behavior is defined specifically to optimize the UpdateTexture path.
  • Loading branch information
slouken committed Feb 7, 2011
1 parent 03c72e7 commit b031b86
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Xcode-iPhoneOS/Demos/src/happy.c
Expand Up @@ -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 */
Expand Down
26 changes: 2 additions & 24 deletions src/render/opengles2/SDL_render_gles2.c
Expand Up @@ -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;
}

Expand Down

0 comments on commit b031b86

Please sign in to comment.