Cleanup properties

bug:19967854

Separate properties from Caches, into static, RenderThread-only class.

Also rewrites the means for java to set properties to correctly handle
threading, and adds an override for profile bars so that SysUi doesn't clutter
the screen with them.

Change-Id: I6e21a96065f52b9ecc49d1a126244804ba106fa9
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 7fc31b8..09674f7 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -245,7 +245,7 @@
 #if DEBUG_MEMORY_USAGE
         mCaches.dumpMemoryUsage();
 #else
-        if (mCaches.getDebugLevel() & kDebugMemory) {
+        if (Properties::debugLevel & kDebugMemory) {
             mCaches.dumpMemoryUsage();
         }
 #endif
@@ -339,7 +339,7 @@
 }
 
 void OpenGLRenderer::renderOverdraw() {
-    if (mCaches.debugOverdraw && getTargetFbo() == 0) {
+    if (Properties::debugOverdraw && getTargetFbo() == 0) {
         const Rect* clip = &mTilingClip;
 
         mRenderState.scissor().setEnabled(true);
@@ -381,7 +381,7 @@
             debugOverdraw(false, false);
         }
 
-        if (CC_UNLIKELY(inFrame || mCaches.drawDeferDisabled)) {
+        if (CC_UNLIKELY(inFrame || Properties::drawDeferDisabled)) {
             layer->render(*this);
         } else {
             layer->defer(*this);
@@ -392,7 +392,7 @@
             startTilingCurrentClip();
         }
 
-        layer->debugDrawUpdate = mCaches.debugLayersUpdates;
+        layer->debugDrawUpdate = Properties::debugLayersUpdates;
         layer->hasDrawnSinceUpdate = false;
 
         return true;
@@ -407,7 +407,7 @@
     // in the layer updates list which will be cleared by flushLayers().
     int count = mLayerUpdates.size();
     if (count > 0) {
-        if (CC_UNLIKELY(mCaches.drawDeferDisabled)) {
+        if (CC_UNLIKELY(Properties::drawDeferDisabled)) {
             startMark("Layer Updates");
         } else {
             startMark("Defer Layer Updates");
@@ -419,7 +419,7 @@
             updateLayer(layer, false);
         }
 
-        if (CC_UNLIKELY(mCaches.drawDeferDisabled)) {
+        if (CC_UNLIKELY(Properties::drawDeferDisabled)) {
             mLayerUpdates.clear();
             mRenderState.bindFramebuffer(getTargetFbo());
         }
@@ -883,13 +883,13 @@
  * operations are correctly counted twice for overdraw. NOTE: assumes composeLayerRegion only used
  * by saveLayer's restore
  */
-#define DRAW_DOUBLE_STENCIL_IF(COND, DRAW_COMMAND) {                             \
-        DRAW_COMMAND;                                                            \
-        if (CC_UNLIKELY(mCaches.debugOverdraw && getTargetFbo() == 0 && COND)) { \
-            glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);                 \
-            DRAW_COMMAND;                                                        \
-            glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);                     \
-        }                                                                        \
+#define DRAW_DOUBLE_STENCIL_IF(COND, DRAW_COMMAND) { \
+        DRAW_COMMAND; \
+        if (CC_UNLIKELY(Properties::debugOverdraw && getTargetFbo() == 0 && COND)) { \
+            glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); \
+            DRAW_COMMAND; \
+            glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); \
+        } \
     }
 
 #define DRAW_DOUBLE_STENCIL(DRAW_COMMAND) DRAW_DOUBLE_STENCIL_IF(true, DRAW_COMMAND)
@@ -1324,7 +1324,7 @@
 }
 
 void OpenGLRenderer::setStencilFromClip() {
-    if (!mCaches.debugOverdraw) {
+    if (!Properties::debugOverdraw) {
         if (!currentSnapshot()->clipIsSimple()) {
             int incrementThreshold;
             EVENT_LOGD("setStencilFromClip - enabling");
@@ -1383,8 +1383,8 @@
             // Draw the region used to generate the stencil if the appropriate debug
             // mode is enabled
             // TODO: Implement for rectangle list clip areas
-            if (mCaches.debugStencilClip == Caches::kStencilShowRegion &&
-                    !clipArea.isRectangleList()) {
+            if (Properties::debugStencilClip == StencilClipDebug::ShowRegion
+                    && !clipArea.isRectangleList()) {
                 paint.setColor(0x7f0000ff);
                 paint.setXfermodeMode(SkXfermode::kSrcOver_Mode);
                 drawRegionRects(currentSnapshot()->getClipRegion(), paint);
@@ -1469,7 +1469,7 @@
     if (renderNode && renderNode->isRenderable()) {
         // compute 3d ordering
         renderNode->computeOrdering();
-        if (CC_UNLIKELY(mCaches.drawDeferDisabled)) {
+        if (CC_UNLIKELY(Properties::drawDeferDisabled)) {
             startFrame();
             ReplayStateStruct replayStruct(*this, dirty, replayFlags);
             renderNode->replay(replayStruct, 0);
@@ -1478,7 +1478,7 @@
 
         // Don't avoid overdraw when visualizing, since that makes it harder to
         // debug where it's coming from, and when the problem occurs.
-        bool avoidOverdraw = !mCaches.debugOverdraw;
+        bool avoidOverdraw = !Properties::debugOverdraw;
         DeferredDisplayList deferredList(mState.currentClipRect(), avoidOverdraw);
         DeferStateStruct deferStruct(deferredList, *this, replayFlags);
         renderNode->defer(deferStruct, 0);
@@ -2452,8 +2452,8 @@
 
     // The caller has made sure casterAlpha > 0.
     float ambientShadowAlpha = mAmbientShadowAlpha;
-    if (CC_UNLIKELY(mCaches.propertyAmbientShadowStrength >= 0)) {
-        ambientShadowAlpha = mCaches.propertyAmbientShadowStrength;
+    if (CC_UNLIKELY(Properties::overrideAmbientShadowStrength >= 0)) {
+        ambientShadowAlpha = Properties::overrideAmbientShadowStrength;
     }
     if (ambientShadowVertexBuffer && ambientShadowAlpha > 0) {
         paint.setARGB(casterAlpha * ambientShadowAlpha, 0, 0, 0);
@@ -2461,8 +2461,8 @@
     }
 
     float spotShadowAlpha = mSpotShadowAlpha;
-    if (CC_UNLIKELY(mCaches.propertySpotShadowStrength >= 0)) {
-        spotShadowAlpha = mCaches.propertySpotShadowStrength;
+    if (CC_UNLIKELY(Properties::overrideSpotShadowStrength >= 0)) {
+        spotShadowAlpha = Properties::overrideSpotShadowStrength;
     }
     if (spotShadowVertexBuffer && spotShadowAlpha > 0) {
         paint.setARGB(casterAlpha * spotShadowAlpha, 0, 0, 0);