Apply dev. settings at runtime
Bug #7434649

Change-Id: I16f00eaa8a5eefd9f9849e196cf2cb1659215390
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index e7085b0..5c2b388 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -126,7 +126,10 @@
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
 }
 
-void Caches::initProperties() {
+bool Caches::initProperties() {
+    bool prevDebugLayersUpdates = debugLayersUpdates;
+    bool prevDebugOverdraw = debugOverdraw;
+
     char property[PROPERTY_VALUE_MAX];
     if (property_get(PROPERTY_DEBUG_LAYERS_UPDATES, property, NULL) > 0) {
         INIT_LOGD("  Layers updates debug enabled: %s", property);
@@ -141,6 +144,9 @@
     } else {
         debugOverdraw = false;
     }
+
+    return (prevDebugLayersUpdates != debugLayersUpdates) ||
+            (prevDebugOverdraw != debugOverdraw);
 }
 
 void Caches::terminate() {
diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h
index ad1ff6f..628d8a0 100644
--- a/libs/hwui/Caches.h
+++ b/libs/hwui/Caches.h
@@ -115,6 +115,11 @@
     void init();
 
     /**
+     * Initialize global system properties.
+     */
+    bool initProperties();
+
+    /**
      * Flush the cache.
      *
      * @param mode Indicates how much of the cache should be flushed
@@ -281,7 +286,6 @@
     void initFont();
     void initExtensions();
     void initConstraints();
-    void initProperties();
 
     static void eventMarkNull(GLsizei length, const GLchar* marker) { }
     static void startMarkNull(GLsizei length, const GLchar* marker) { }
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp
index 1cdc063..ee1d391 100644
--- a/libs/hwui/Layer.cpp
+++ b/libs/hwui/Layer.cpp
@@ -41,6 +41,7 @@
     renderer = NULL;
     displayList = NULL;
     fbo = 0;
+    debugDrawUpdate = false;
     Caches::getInstance().resourceCache.incrementRefcount(this);
 }
 
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index e1f6a70..181eb6c 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -265,6 +265,7 @@
     OpenGLRenderer* renderer;
     DisplayList* displayList;
     Rect dirtyRect;
+    bool debugDrawUpdate;
 
 private:
     /**
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index bc30738..c7a2014 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -489,6 +489,7 @@
         layer->deferredUpdateScheduled = false;
         layer->renderer = NULL;
         layer->displayList = NULL;
+        layer->debugDrawUpdate = mCaches.debugLayersUpdates;
 
         return true;
     }
@@ -2806,10 +2807,7 @@
         return DrawGlInfo::kStatusDone;
     }
 
-    bool debugLayerUpdate = false;
-    if (updateLayer(layer, true)) {
-        debugLayerUpdate = mCaches.debugLayersUpdates;
-    }
+    updateLayer(layer, true);
 
     mCaches.setScissorEnabled(mScissorOptimizationDisabled || !clip.contains(transformed));
     mCaches.activeTexture(0);
@@ -2857,7 +2855,8 @@
 
         mColorFilter = oldFilter;
 
-        if (debugLayerUpdate) {
+        if (layer->debugDrawUpdate) {
+            layer->debugDrawUpdate = false;
             drawColorRect(x, y, x + layer->layer.getWidth(), y + layer->layer.getHeight(),
                     0x7f00ff00, SkXfermode::kSrcOver_Mode);
         }