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.
This commit is contained in:
parent
1c8816f6fe
commit
87ca0acb3f
2 changed files with 3 additions and 25 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue