diff options
-rw-r--r-- | gyp/gpu.gypi | 1 | ||||
-rw-r--r-- | include/gpu/GrContext.h | 5 | ||||
-rw-r--r-- | src/gpu/GrBatchAtlas.h | 9 | ||||
-rw-r--r-- | src/gpu/GrBatchFontCache.cpp | 43 | ||||
-rw-r--r-- | src/gpu/GrBatchFontCache.h | 5 | ||||
-rw-r--r-- | src/gpu/GrFontAtlasSizes.h | 39 | ||||
-rw-r--r-- | src/gpu/GrTest.cpp | 5 | ||||
-rw-r--r-- | src/gpu/effects/GrBitmapTextGeoProc.cpp | 1 | ||||
-rwxr-xr-x | src/gpu/effects/GrDistanceFieldGeoProc.cpp | 1 |
9 files changed, 57 insertions, 52 deletions
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi index 14e01152f4..838d99c379 100644 --- a/gyp/gpu.gypi +++ b/gyp/gpu.gypi @@ -107,7 +107,6 @@ '<(skia_src_path)/gpu/GrDrawContext.cpp', '<(skia_src_path)/gpu/GrDrawTarget.cpp', '<(skia_src_path)/gpu/GrDrawTarget.h', - '<(skia_src_path)/gpu/GrFontAtlasSizes.h', '<(skia_src_path)/gpu/GrFontScaler.cpp', '<(skia_src_path)/gpu/GrFontScaler.h', '<(skia_src_path)/gpu/GrGeometryBuffer.h', diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index 50d101cf32..cb5eb761ed 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -18,6 +18,7 @@ #include "SkPathEffect.h" #include "SkTypes.h" +struct GrBatchAtlasConfig; class GrBatchFontCache; class GrCaps; struct GrContextOptions; @@ -356,6 +357,10 @@ public: this is for testing only */ void setTextBlobCacheLimit_ForTesting(size_t bytes); + /** Specify the sizes of the GrAtlasTextContext atlases. The configs pointer below should be + to an array of 3 entries */ + void setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* configs); + private: GrGpu* fGpu; const GrCaps* fCaps; diff --git a/src/gpu/GrBatchAtlas.h b/src/gpu/GrBatchAtlas.h index 4948953141..4e23540924 100644 --- a/src/gpu/GrBatchAtlas.h +++ b/src/gpu/GrBatchAtlas.h @@ -19,6 +19,15 @@ class GrRectanizer; typedef SkTInternalLList<BatchPlot> GrBatchPlotList; +struct GrBatchAtlasConfig { + int numPlotsX() const { return fWidth / fPlotWidth; } + int numPlotsY() const { return fHeight / fPlotWidth; } + int fWidth; + int fHeight; + int fPlotWidth; + int fPlotHeight; +}; + class GrBatchAtlas { public: // An AtlasID is an opaque handle which callers can use to determine if the atlas contains diff --git a/src/gpu/GrBatchFontCache.cpp b/src/gpu/GrBatchFontCache.cpp index 88b3a4db17..30dd0b6f8a 100644 --- a/src/gpu/GrBatchFontCache.cpp +++ b/src/gpu/GrBatchFontCache.cpp @@ -7,7 +7,6 @@ #include "GrBatchFontCache.h" #include "GrContext.h" -#include "GrFontAtlasSizes.h" #include "GrGpu.h" #include "GrRectanizer.h" #include "GrResourceProvider.h" @@ -22,15 +21,11 @@ bool GrBatchFontCache::initAtlas(GrMaskFormat format) { int index = MaskFormatToAtlasIndex(format); if (!fAtlases[index]) { GrPixelConfig config = MaskFormatToPixelConfig(format); - int width = GR_FONT_ATLAS_TEXTURE_WIDTH; - int height = GR_FONT_ATLAS_TEXTURE_HEIGHT; - int numPlotsX = GR_FONT_ATLAS_NUM_PLOTS_X; - int numPlotsY = GR_FONT_ATLAS_NUM_PLOTS_Y; - - if (kA8_GrMaskFormat == format) { - width = GR_FONT_ATLAS_A8_TEXTURE_WIDTH; - numPlotsX = GR_FONT_ATLAS_A8_NUM_PLOTS_X; - } + int width = fAtlasConfigs[index].fWidth; + int height = fAtlasConfigs[index].fHeight; + int numPlotsX = fAtlasConfigs[index].numPlotsX(); + int numPlotsY = fAtlasConfigs[index].numPlotsY(); + fAtlases[index] = fContext->resourceProvider()->createAtlas(config, width, height, numPlotsX, numPlotsY, @@ -49,6 +44,22 @@ GrBatchFontCache::GrBatchFontCache(GrContext* context) for (int i = 0; i < kMaskFormatCount; ++i) { fAtlases[i] = NULL; } + + // setup default atlas configs + fAtlasConfigs[kA8_GrMaskFormat].fWidth = 2048; + fAtlasConfigs[kA8_GrMaskFormat].fHeight = 2048; + fAtlasConfigs[kA8_GrMaskFormat].fPlotWidth = 512; + fAtlasConfigs[kA8_GrMaskFormat].fPlotHeight = 256; + + fAtlasConfigs[kA565_GrMaskFormat].fWidth = 1024; + fAtlasConfigs[kA565_GrMaskFormat].fHeight = 2048; + fAtlasConfigs[kA565_GrMaskFormat].fPlotWidth = 256; + fAtlasConfigs[kA565_GrMaskFormat].fPlotHeight = 256; + + fAtlasConfigs[kARGB_GrMaskFormat].fWidth = 1024; + fAtlasConfigs[kARGB_GrMaskFormat].fHeight = 2048; + fAtlasConfigs[kARGB_GrMaskFormat].fPlotWidth = 256; + fAtlasConfigs[kARGB_GrMaskFormat].fPlotHeight = 256; } GrBatchFontCache::~GrBatchFontCache() { @@ -114,6 +125,18 @@ void GrBatchFontCache::dump() const { ++gDumpCount; } +void GrBatchFontCache::setAtlasSizes_ForTesting(const GrBatchAtlasConfig configs[3]) { + // delete any old atlases, this should be safe to do as long as we are not in the middle of a + // flush + for (int i = 0; i < kMaskFormatCount; i++) { + if (fAtlases[i]) { + SkDELETE(fAtlases[i]); + fAtlases[i] = NULL; + } + } + memcpy(fAtlasConfigs, configs, sizeof(fAtlasConfigs)); +} + /////////////////////////////////////////////////////////////////////////////// /* diff --git a/src/gpu/GrBatchFontCache.h b/src/gpu/GrBatchFontCache.h index f315a3eb77..fc2f3b7a29 100644 --- a/src/gpu/GrBatchFontCache.h +++ b/src/gpu/GrBatchFontCache.h @@ -166,8 +166,12 @@ public: return this->getAtlas(format)->atlasGeneration(); } + /////////////////////////////////////////////////////////////////////////// + // Functions intended debug only void dump() const; + void setAtlasSizes_ForTesting(const GrBatchAtlasConfig configs[3]); + private: static GrPixelConfig MaskFormatToPixelConfig(GrMaskFormat format) { static const GrPixelConfig kPixelConfigs[] = { @@ -213,6 +217,7 @@ private: SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache; GrBatchAtlas* fAtlases[kMaskFormatCount]; GrBatchTextStrike* fPreserveStrike; + GrBatchAtlasConfig fAtlasConfigs[kMaskFormatCount]; }; #endif diff --git a/src/gpu/GrFontAtlasSizes.h b/src/gpu/GrFontAtlasSizes.h deleted file mode 100644 index 8722ca1a60..0000000000 --- a/src/gpu/GrFontAtlasSizes.h +++ /dev/null @@ -1,39 +0,0 @@ - -/* - * Copyright 2015 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrFontAtlasSizes_DEFINED -#define GrFontAtlasSizes_DEFINED - -// For debugging atlas which evict all of the time -//#define DEBUG_CONSTANT_EVICT -#ifdef DEBUG_CONSTANT_EVICT -#define GR_FONT_ATLAS_TEXTURE_WIDTH 256//1024 -#define GR_FONT_ATLAS_A8_TEXTURE_WIDTH 256//2048 -#define GR_FONT_ATLAS_TEXTURE_HEIGHT 256//2048 - -#define GR_FONT_ATLAS_PLOT_WIDTH 256 -#define GR_FONT_ATLAS_A8_PLOT_WIDTH 256//512 -#define GR_FONT_ATLAS_PLOT_HEIGHT 256 - -#define GR_FONT_ATLAS_NUM_PLOTS_X (GR_FONT_ATLAS_TEXTURE_WIDTH / GR_FONT_ATLAS_PLOT_WIDTH) -#define GR_FONT_ATLAS_A8_NUM_PLOTS_X (GR_FONT_ATLAS_A8_TEXTURE_WIDTH / GR_FONT_ATLAS_A8_PLOT_WIDTH) -#define GR_FONT_ATLAS_NUM_PLOTS_Y (GR_FONT_ATLAS_TEXTURE_HEIGHT / GR_FONT_ATLAS_PLOT_HEIGHT) -#else -#define GR_FONT_ATLAS_TEXTURE_WIDTH 1024 -#define GR_FONT_ATLAS_A8_TEXTURE_WIDTH 2048 -#define GR_FONT_ATLAS_TEXTURE_HEIGHT 2048 - -#define GR_FONT_ATLAS_PLOT_WIDTH 256 -#define GR_FONT_ATLAS_A8_PLOT_WIDTH 512 -#define GR_FONT_ATLAS_PLOT_HEIGHT 256 - -#define GR_FONT_ATLAS_NUM_PLOTS_X (GR_FONT_ATLAS_TEXTURE_WIDTH / GR_FONT_ATLAS_PLOT_WIDTH) -#define GR_FONT_ATLAS_A8_NUM_PLOTS_X (GR_FONT_ATLAS_A8_TEXTURE_WIDTH / GR_FONT_ATLAS_A8_PLOT_WIDTH) -#define GR_FONT_ATLAS_NUM_PLOTS_Y (GR_FONT_ATLAS_TEXTURE_HEIGHT / GR_FONT_ATLAS_PLOT_HEIGHT) -#endif -#endif diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp index 7b6cb5ed37..a2efb4829b 100644 --- a/src/gpu/GrTest.cpp +++ b/src/gpu/GrTest.cpp @@ -8,6 +8,7 @@ #include "GrTest.h" +#include "GrBatchFontCache.h" #include "GrBufferedDrawTarget.h" #include "GrContextOptions.h" #include "GrGpuResourceCacheAccess.h" @@ -35,6 +36,10 @@ void GrContext::setTextBlobCacheLimit_ForTesting(size_t bytes) { fTextBlobCache->setBudget(bytes); } +void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* configs) { + fBatchFontCache->setAtlasSizes_ForTesting(configs); +} + /////////////////////////////////////////////////////////////////////////////// void GrContext::purgeAllUnlockedResources() { diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index d83cf5595a..dfced55ea2 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -6,7 +6,6 @@ */ #include "GrBitmapTextGeoProc.h" -#include "GrFontAtlasSizes.h" #include "GrInvariantOutput.h" #include "GrTexture.h" #include "gl/GrGLFragmentProcessor.h" diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index d8fbd86cb3..8551272b24 100755 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -6,7 +6,6 @@ */ #include "GrDistanceFieldGeoProc.h" -#include "GrFontAtlasSizes.h" #include "GrInvariantOutput.h" #include "GrTexture.h" |