Add GrLayerCache::writeLayersToDisk

I'm tired of readding this capability whenever I need to debug.

Review URL: https://codereview.chromium.org/654653006
This commit is contained in:
robertphillips 2014-10-14 07:07:59 -07:00 committed by Commit bot
parent ab84fae29f
commit 84ac082fd4
2 changed files with 35 additions and 0 deletions

View File

@ -8,6 +8,7 @@
#include "GrAtlas.h"
#include "GrGpu.h"
#include "GrLayerCache.h"
#include "GrSurfacePriv.h"
DECLARE_SKMESSAGEBUS_MESSAGE(GrPictureDeletedMessage);
@ -434,3 +435,33 @@ void GrLayerCache::processDeletedPictures() {
}
}
#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

View File

@ -222,6 +222,10 @@ public:
SkDEBUGCODE(void validate() const;)
#ifdef SK_DEVELOPER
void writeLayersToDisk(const SkString& dirName);
#endif
private:
static const int kAtlasTextureWidth = 1024;
static const int kAtlasTextureHeight = 1024;