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/ResourceCache.cpp b/libs/hwui/ResourceCache.cpp
index 8b553d1..329d92f 100644
--- a/libs/hwui/ResourceCache.cpp
+++ b/libs/hwui/ResourceCache.cpp
@@ -75,10 +75,6 @@
     incrementRefcount((void*) patchResource, kNinePatch);
 }
 
-void ResourceCache::incrementRefcount(Layer* layerResource) {
-    incrementRefcount((void*) layerResource, kLayer);
-}
-
 void ResourceCache::incrementRefcountLocked(void* resource, ResourceType resourceType) {
     ssize_t index = mCache->indexOfKey(resource);
     ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL;
@@ -103,10 +99,6 @@
     incrementRefcountLocked((void*) patchResource, kNinePatch);
 }
 
-void ResourceCache::incrementRefcountLocked(Layer* layerResource) {
-    incrementRefcountLocked((void*) layerResource, kLayer);
-}
-
 void ResourceCache::decrementRefcount(void* resource) {
     Mutex::Autolock _l(mLock);
     decrementRefcountLocked(resource);
@@ -126,10 +118,6 @@
     decrementRefcount((void*) patchResource);
 }
 
-void ResourceCache::decrementRefcount(Layer* layerResource) {
-    decrementRefcount((void*) layerResource);
-}
-
 void ResourceCache::decrementRefcountLocked(void* resource) {
     ssize_t index = mCache->indexOfKey(resource);
     ResourceReference* ref = index >= 0 ? mCache->valueAt(index) : NULL;
@@ -157,10 +145,6 @@
     decrementRefcountLocked((void*) patchResource);
 }
 
-void ResourceCache::decrementRefcountLocked(Layer* layerResource) {
-    decrementRefcountLocked((void*) layerResource);
-}
-
 void ResourceCache::destructor(SkPath* resource) {
     Mutex::Autolock _l(mLock);
     destructorLocked(resource);
@@ -274,7 +258,7 @@
     if (ref->recycled && ref->resourceType == kBitmap) {
         ((SkBitmap*) resource)->setPixels(NULL, NULL);
     }
-    if (ref->destroyed || ref->resourceType == kLayer) {
+    if (ref->destroyed) {
         switch (ref->resourceType) {
             case kBitmap: {
                 SkBitmap* bitmap = (SkBitmap*) resource;
@@ -305,11 +289,6 @@
                 }
             }
             break;
-            case kLayer: {
-                Layer* layer = (Layer*) resource;
-                Caches::getInstance().deleteLayerDeferred(layer);
-            }
-            break;
         }
     }
     mCache->removeItem(resource);