Avoid unnecessarily re-allocating texture buffer when the size hasn't changed.
authorSinclair Yeh <sinclair.yeh@intel.com>
Thu, 6 Jun 2013 23:41:30 +0000 (16:41 -0700)
committerKristian Høgsberg <krh@bitplanet.net>
Fri, 7 Jun 2013 04:19:13 +0000 (00:19 -0400)
commit2ada74828953296787ef5477064e8ad025f59a77
tree0b1cc148cb237dcd1b4ab23f060f5c5756ba2e5a
parentd7bc6351f84b0d735718965282d5ad4de9c3f75e
Avoid unnecessarily re-allocating texture buffer when the size hasn't changed.

v4:
Incorporated krh and anderco's comments.  Now adding newly allocated
buffer's dimensions to texture_damage

v3:
* Removed unnecessary parentheses
* Added check for switching from EGL image to SHM buffer
* Moved shader assignment out of IF condition

v2:
Fixed the wrong comparison

v1:
Depending on specific DRI driver implementation, glTexImage2D() with data
set to NULL may or may not re-allocate the texture buffer each time it is
called.  Unintended consequences happen if later glTexSubImage2D() is called
to only update a sub-region of the texture buffer.

I've explored moving glTexImage2D() from gl_renderer_attach() and simply
mark the texture dirty, but the current implemention seems cleaner because
I won't have to worry about calling ensure_textures() and re-assigning
gs->shader unnecessarily.
src/gl-renderer.c