diff options
author | 2013-10-02 18:19:17 +0000 | |
---|---|---|
committer | 2013-10-02 18:19:17 +0000 | |
commit | 03e3e89641c93df603dfb705d518848dfe81427e (patch) | |
tree | 58f092086627ef6a39c933b716808869e9295c38 /src | |
parent | aaf3e64b2c867dff1b750cebdeff9e57784b8f22 (diff) |
Add support to dump font cache texture for debug purposes
R=robertphillips@google.com, bsalomon@google.com
Author: jvanverth@google.com
Review URL: https://codereview.chromium.org/25736002
git-svn-id: http://skia.googlecode.com/svn/trunk@11579 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrAtlas.cpp | 7 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrTextContext.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrTextStrike.cpp | 18 | ||||
-rw-r--r-- | src/gpu/GrTextStrike.h | 4 |
5 files changed, 45 insertions, 0 deletions
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp index 70fe3e017f..9784e83de9 100644 --- a/src/gpu/GrAtlas.cpp +++ b/src/gpu/GrAtlas.cpp @@ -179,7 +179,13 @@ GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, if (NULL == fTexture) { // TODO: Update this to use the cache rather than directly creating a texture. GrTextureDesc desc; +#ifdef SK_DEVELOPER + // RenderTarget so we can read the pixels to dump them + desc.fFlags = kDynamicUpdate_GrTextureFlagBit|kRenderTarget_GrTextureFlagBit + |kNoStencil_GrTextureFlagBit; +#else desc.fFlags = kDynamicUpdate_GrTextureFlagBit; +#endif desc.fWidth = GR_ATLAS_TEXTURE_WIDTH; desc.fHeight = GR_ATLAS_TEXTURE_HEIGHT; desc.fConfig = fPixelConfig; @@ -205,6 +211,7 @@ GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, } bool GrAtlasMgr::removeUnusedPlots(GrAtlas* atlas) { + // GrPlot** is used so that the head element can be easily // modified when the first element is deleted GrPlot** plotRef = &atlas->fPlots; diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 9dfe761024..6b1efbeac2 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -642,6 +642,12 @@ void GrContext::drawPaint(const GrPaint& origPaint) { this->drawRect(*paint, r); } +#ifdef SK_DEVELOPER +void GrContext::dumpFontCache() const { + fFontCache->dump(); +} +#endif + //////////////////////////////////////////////////////////////////////////////// namespace { diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp index 1f25c906fb..5a6183965c 100644 --- a/src/gpu/GrTextContext.cpp +++ b/src/gpu/GrTextContext.cpp @@ -16,11 +16,15 @@ #include "GrTextStrike.h" #include "GrTextStrike_impl.h" #include "SkPath.h" +#include "SkRTConf.h" #include "SkStrokeRec.h" #include "effects/GrCustomCoordsTextureEffect.h" static const int kGlyphCoordsAttributeIndex = 1; +SK_CONF_DECLARE(bool, c_DumpFontCache, "gpu.dumpFontCache", false, + "Dump the contents of the font cache before every purge."); + void GrTextContext::flushGlyphs() { if (NULL == fDrawTarget) { return; @@ -161,6 +165,12 @@ void GrTextContext::drawPackedGlyph(GrGlyph::PackedID packed, goto HAS_ATLAS; } + if (c_DumpFontCache) { +#ifdef SK_DEVELOPER + fContext->getFontCache()->dump(); +#endif + } + // before we purge the cache, we must flush any accumulated draws this->flushGlyphs(); fContext->flush(); diff --git a/src/gpu/GrTextStrike.cpp b/src/gpu/GrTextStrike.cpp index e399c91f6c..7cab335d72 100644 --- a/src/gpu/GrTextStrike.cpp +++ b/src/gpu/GrTextStrike.cpp @@ -10,6 +10,7 @@ #include "GrRectanizer.h" #include "GrTextStrike.h" #include "GrTextStrike_impl.h" +#include "SkString.h" SK_DEFINE_INST_COUNT(GrFontScaler) SK_DEFINE_INST_COUNT(GrKey) @@ -170,6 +171,23 @@ void GrFontCache::validate() const { } #endif +#ifdef SK_DEVELOPER +void GrFontCache::dump() const { + static int gDumpCount = 0; + for (int i = 0; i < kMaskFormatCount; ++i) { + if (NULL != fAtlasMgr[i]) { + GrTexture* texture = fAtlasMgr[i]->getTexture(); + if (NULL != texture) { + SkString filename; + filename.printf("fontcache_%d%d.png", gDumpCount, i); + texture->savePixels(filename.c_str()); + } + } + } + ++gDumpCount; +} +#endif + /////////////////////////////////////////////////////////////////////////////// #ifdef SK_DEBUG diff --git a/src/gpu/GrTextStrike.h b/src/gpu/GrTextStrike.h index e311f3f51d..35d50082b0 100644 --- a/src/gpu/GrTextStrike.h +++ b/src/gpu/GrTextStrike.h @@ -98,6 +98,10 @@ public: void validate() const {} #endif +#ifdef SK_DEVELOPER + void dump() const; +#endif + private: friend class GrFontPurgeListener; |