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>
Tue, 22 Dec 2015 04:13:49 +0000 (12:13 +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 83f9c6a..3e5fc79 100644 (file)
@@ -234,12 +234,28 @@ Layer* LayerRenderer::createRenderLayer(RenderState& renderState, uint32_t width
 
     // 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) {
             renderState.bindFramebuffer(previousFbo);
             layer->decStrong(0);
             return NULL;