Add GrLayerCache::writeLayersToDisk
I'm tired of readding this capability whenever I need to debug.
Review URL: https://codereview.chromium.org/654653006
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index 570b2d6..de4a90a 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -8,6 +8,7 @@
#include "GrAtlas.h"
#include "GrGpu.h"
#include "GrLayerCache.h"
+#include "GrSurfacePriv.h"
DECLARE_SKMESSAGEBUS_MESSAGE(GrPictureDeletedMessage);
@@ -434,3 +435,33 @@
}
}
+#ifdef SK_DEVELOPER
+void GrLayerCache::writeLayersToDisk(const SkString& dirName) {
+
+ GrTexture* atlasTexture = fAtlas->getTexture();
+ if (NULL != atlasTexture) {
+ SkString fileName(dirName);
+ fileName.append("\\atlas.png");
+
+ atlasTexture->surfacePriv().savePixels(fileName.c_str());
+ }
+
+ SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key>::Iter iter(&fLayerHash);
+ for (; !iter.done(); ++iter) {
+ GrCachedLayer* layer = &(*iter);
+
+ if (layer->isAtlased() || !layer->texture()) {
+ continue;
+ }
+
+ SkString fileName(dirName);
+ fileName.append("\\");
+ fileName.appendU32(layer->fKey.pictureID());
+ fileName.append("-");
+ fileName.appendU32(layer->fKey.start());
+ fileName.append(".png");
+
+ layer->texture()->surfacePriv().savePixels(fileName.c_str());
+ }
+}
+#endif
diff --git a/src/gpu/GrLayerCache.h b/src/gpu/GrLayerCache.h
index 3bccb43..d8c5ad9 100644
--- a/src/gpu/GrLayerCache.h
+++ b/src/gpu/GrLayerCache.h
@@ -222,6 +222,10 @@
SkDEBUGCODE(void validate() const;)
+#ifdef SK_DEVELOPER
+ void writeLayersToDisk(const SkString& dirName);
+#endif
+
private:
static const int kAtlasTextureWidth = 1024;
static const int kAtlasTextureHeight = 1024;