Layer changes

Bug: 17208461

* Switch Layer to be VirtualLightRefBase instead of
  Caches' side-channel ref-counting
* Include active layers in gfxinfo dump
* Run gfxinfo dump on the correct thread
* Dump gfxinfo on Layer creation failure

Change-Id: I28d195699e2334518e215ab28c7a17355aee9678
diff --git a/libs/hwui/RenderNode.cpp b/libs/hwui/RenderNode.cpp
index 40cd13e..c9ed9a7 100644
--- a/libs/hwui/RenderNode.cpp
+++ b/libs/hwui/RenderNode.cpp
@@ -87,7 +87,11 @@
 RenderNode::~RenderNode() {
     deleteDisplayListData();
     delete mStagingDisplayListData;
-    LayerRenderer::destroyLayerDeferred(mLayer);
+    if (mLayer) {
+        ALOGW("Memory Warning: Layer %p missed its detachment, held on to for far too long!", mLayer);
+        mLayer->postDecStrong();
+        mLayer = 0;
+    }
 }
 
 void RenderNode::setStagingDisplayList(DisplayListData* data) {
@@ -201,6 +205,7 @@
     info.damageAccumulator->peekAtDirty(&dirty);
 
     if (!mLayer) {
+        Caches::getInstance().dumpMemoryUsage();
         if (info.errorHandler) {
             std::string msg = "Unable to create layer for ";
             msg += getName();