OSDN Git Service

Clear any stale errors before allocating layer
authorPaul Drews <paul.drews@intel.com>
Thu, 19 Jul 2012 21:12:22 +0000 (14:12 -0700)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 25 Sep 2013 02:48:22 +0000 (10:48 +0800)
Symptom:  On first boot, the "Make yourself at home" dialog
was not drawn, but was actually present.  This prevented
swiping the home screen until you happened to click on the
invisible "OK" button or take some other action that caused
the screen to get redrawn.

Cause:  GL errors remain within GL until they are cleared by
retrieving them.  The createLayer function was affected by a
stale error leftover from some previous code sequence.  When
it retrieved GL error status to check for success/fail of an
operation it got one of these "stale" errors and erroneously
concluded that the operation had failed.

This change clears any stale errors before embarking the
operation sequence that it wants to check for success/fail.

Issue: AXIA-425
Change-Id: I30b7fe1fbc354d3fea5e1d8cefa1be363fc68f8c
Signed-off-by: Paul Drews <paul.drews@intel.com>
libs/hwui/LayerRenderer.cpp

index 3e55fff..62d1fdd 100644 (file)
@@ -255,12 +255,28 @@ Layer* LayerRenderer::createLayer(uint32_t width, uint32_t height, bool isOpaque
 
     // Initialize the texture if needed
     if (layer->isEmpty()) {
+        int an_error;
+        int num_errors;
+        /*
+         * Make sure there is no stale error leftover from some previous code
+         * sequence before we embark on this series of gl operations.
+         */
+        while ((an_error = glGetError()) != GL_NO_ERROR) {
+            ALOGD("createLayer clearing stale error code 0x%04x", an_error);
+        }
+
         layer->setEmpty(false);
         layer->allocateTexture();
 
-        // This should only happen if we run out of memory
-        if (glGetError() != GL_NO_ERROR) {
-            ALOGE("Could not allocate texture for layer (fbo=%d %dx%d)", fbo, width, height);
+        /* Detect and clear errors from setEmpty(), allocateTexture() */
+        num_errors = 0;
+        while ((an_error = glGetError()) != GL_NO_ERROR) {
+            num_errors++;
+            ALOGD("Could not allocate texture for layer (fbo=%d %dx%d)"
+                  " (error=0x%04x)",
+                    fbo, width, height, an_error);
+        }
+        if (num_errors != 0) {
             glBindFramebuffer(GL_FRAMEBUFFER, previousFbo);
             caches.resourceCache.decrementRefcount(layer);
             return NULL;