better workaround for bug: 6020860

this prevents the GPU from running when composition
is fully handled by overlays. this should improve
animations a bit.

Change-Id: If4ae584b7a3976e6bdd36e318686ac3940b6b075
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index fe39584..0b68aa3 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1013,18 +1013,29 @@
         drawWormhole();
     }
 
-    // FIXME: workaroud for b/6020860
-    glEnable(GL_SCISSOR_TEST);
-    glScissor(0,0,0,0);
-    glClear(GL_COLOR_BUFFER_BIT);
-    // end-workaround
-
     /*
      * and then, render the layers targeted at the framebuffer
      */
+
     hwc_layer_t* const cur(hwc.getLayers());
     const Vector< sp<LayerBase> >& layers(mVisibleLayersSortedByZ);
     size_t count = layers.size();
+
+
+    // FIXME: workaround for b/6020860
+    if (hw.getFlags() & DisplayHardware::BUFFER_PRESERVED) {
+        for (size_t i=0 ; i<count ; i++) {
+            if (cur && (cur[i].compositionType == HWC_FRAMEBUFFER)) {
+                glEnable(GL_SCISSOR_TEST);
+                glScissor(0,0,0,0);
+                glClear(GL_COLOR_BUFFER_BIT);
+                break;
+            }
+        }
+    }
+    // FIXME: bug6020860 for b/6020860
+
+
     for (size_t i=0 ; i<count ; i++) {
         if (cur && (cur[i].compositionType != HWC_FRAMEBUFFER)) {
             continue;