summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Romain Guy <romainguy@google.com> 2013-06-28 18:05:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2013-06-28 18:05:00 +0000
commit3d1b158e705f1ba83ac42dfe1aeaf25201638ef6 (patch)
tree4d50d0eb44fcc30c8b06d404cd9c23eba9c6b9ff
parente6304a9c075ed927fc6bdffcc3191dc829f779fa (diff)
parentb254c242d98f4a9d98055726446351e52bece2c6 (diff)
Merge "Fix out of range glCopyTexImage2D Bug #9425270" into jb-mr2-dev
-rw-r--r--libs/hwui/OpenGLRenderer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index ddb190e3fec1..7735819a20a0 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -882,15 +882,18 @@ bool OpenGLRenderer::createLayer(float left, float top, float right, float botto
layer->bindTexture();
if (!bounds.isEmpty()) {
if (layer->isEmpty()) {
- glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
- bounds.left, mSnapshot->height - bounds.bottom,
- layer->getWidth(), layer->getHeight(), 0);
+ // Workaround for some GL drivers. When reading pixels lying outside
+ // of the window we should get undefined values for those pixels.
+ // Unfortunately some drivers will turn the entire target texture black
+ // when reading outside of the window.
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, layer->getWidth(), layer->getHeight(),
+ 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
layer->setEmpty(false);
- } else {
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left,
- mSnapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight());
}
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bounds.left,
+ mSnapshot->height - bounds.bottom, bounds.getWidth(), bounds.getHeight());
+
// Enqueue the buffer coordinates to clear the corresponding region later
mLayers.push(new Rect(bounds));
}