comparison src/render/opengles2/SDL_render_gles2.c @ 5217:b0797947dd1c

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.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 06 Feb 2011 20:56:21 -0800
parents 25ad4a50d34f
children c66b2a778b7e
comparison
equal deleted inserted replaced
5216:25ad4a50d34f 5217:b0797947dd1c
387 rect->w, 387 rect->w,
388 rect->h, 388 rect->h,
389 tdata->pixel_format, 389 tdata->pixel_format,
390 tdata->pixel_type, 390 tdata->pixel_type,
391 src); 391 src);
392 SDL_free(blob);
393
392 if (glGetError() != GL_NO_ERROR) 394 if (glGetError() != GL_NO_ERROR)
393 { 395 {
394 SDL_SetError("Failed to update texture"); 396 SDL_SetError("Failed to update texture");
395 return -1; 397 return -1;
396 } 398 }
397
398 /* Update the (streaming) texture buffer, in one pass if possible */
399 if (tdata->pixel_data)
400 {
401 dest = (Uint8 *)tdata->pixel_data +
402 (tdata->pitch * rect->y) +
403 (SDL_BYTESPERPIXEL(texture->format) * rect->x);
404 if (rect->w == texture->w)
405 {
406 SDL_memcpy(dest, src, srcPitch * rect->h);
407 }
408 else
409 {
410 for (y = 0; y < rect->h; ++y)
411 {
412 SDL_memcpy(dest, src, srcPitch);
413 src += srcPitch;
414 dest += tdata->pitch;
415 }
416 }
417 }
418
419 /* Clean up and return */
420 SDL_free(blob);
421 return 0; 399 return 0;
422 } 400 }
423 401
424 /************************************************************************************************* 402 /*************************************************************************************************
425 * Shader management functions * 403 * Shader management functions *