Allow setting of GrBatchFontCache atlas sizes
BUG=skia: Review URL: https://codereview.chromium.org/1255943006
This commit is contained in:
parent
45cba08015
commit
da04e0e80a
@ -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',
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
int width = fAtlasConfigs[index].fWidth;
|
||||
int height = fAtlasConfigs[index].fHeight;
|
||||
int numPlotsX = fAtlasConfigs[index].numPlotsX();
|
||||
int numPlotsY = fAtlasConfigs[index].numPlotsY();
|
||||
|
||||
if (kA8_GrMaskFormat == format) {
|
||||
width = GR_FONT_ATLAS_A8_TEXTURE_WIDTH;
|
||||
numPlotsX = GR_FONT_ATLAS_A8_NUM_PLOTS_X;
|
||||
}
|
||||
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));
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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() {
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "GrBitmapTextGeoProc.h"
|
||||
#include "GrFontAtlasSizes.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTexture.h"
|
||||
#include "gl/GrGLFragmentProcessor.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
*/
|
||||
|
||||
#include "GrDistanceFieldGeoProc.h"
|
||||
#include "GrFontAtlasSizes.h"
|
||||
#include "GrInvariantOutput.h"
|
||||
#include "GrTexture.h"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user