Rename GrBatchFontCache->GrAtlasGlyphCache
Change-Id: Ie21e18b631daa24e70df630b9f910213f62bdbdf
Reviewed-on: https://skia-review.googlesource.com/6164
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
diff --git a/gn/gpu.gni b/gn/gpu.gni
index 155eac67..d1bd83e 100644
--- a/gn/gpu.gni
+++ b/gn/gpu.gni
@@ -345,13 +345,13 @@
"$_src/gpu/instanced/GLInstancedRendering.h",
# text
+ "$_src/gpu/text/GrAtlasGlyphCache.cpp",
+ "$_src/gpu/text/GrAtlasGlyphCache.h",
"$_src/gpu/text/GrAtlasTextBlob.cpp",
"$_src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp",
"$_src/gpu/text/GrAtlasTextBlob.h",
"$_src/gpu/text/GrAtlasTextContext.cpp",
"$_src/gpu/text/GrAtlasTextContext.h",
- "$_src/gpu/text/GrBatchFontCache.cpp",
- "$_src/gpu/text/GrBatchFontCache.h",
"$_src/gpu/text/GrDistanceFieldAdjustTable.cpp",
"$_src/gpu/text/GrDistanceFieldAdjustTable.h",
"$_src/gpu/text/GrStencilAndCoverTextContext.cpp",
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 147cf5c..779529a 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -20,8 +20,8 @@
#include "../private/GrAuditTrail.h"
#include "../private/GrSingleOwner.h"
+class GrAtlasGlyphCache;
struct GrBatchAtlasConfig;
-class GrBatchFontCache;
struct GrContextOptions;
class GrContextPriv;
class GrContextThreadSafeProxy;
@@ -330,7 +330,7 @@
// Functions intended for internal use only.
GrGpu* getGpu() { return fGpu; }
const GrGpu* getGpu() const { return fGpu; }
- GrBatchFontCache* getBatchFontCache() { return fBatchFontCache; }
+ GrAtlasGlyphCache* getAtlasGlyphCache() { return fAtlasGlyphCache; }
GrTextBlobCache* getTextBlobCache() { return fTextBlobCache.get(); }
bool abandoned() const;
GrResourceProvider* resourceProvider() { return fResourceProvider; }
@@ -389,7 +389,7 @@
sk_sp<GrContextThreadSafeProxy> fThreadSafeProxy;
- GrBatchFontCache* fBatchFontCache;
+ GrAtlasGlyphCache* fAtlasGlyphCache;
std::unique_ptr<GrTextBlobCache> fTextBlobCache;
bool fDidTestPMConversions;
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 67ef83a..f1a080f 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -68,7 +68,7 @@
fCaps = nullptr;
fResourceCache = nullptr;
fResourceProvider = nullptr;
- fBatchFontCache = nullptr;
+ fAtlasGlyphCache = nullptr;
}
bool GrContext::init(GrBackend backend, GrBackendContext backendContext,
@@ -104,8 +104,7 @@
fDrawingManager.reset(new GrDrawingManager(this, rtOpListOptions, prcOptions,
options.fImmediateMode, &fSingleOwner));
- // GrBatchFontCache will eventually replace GrFontCache
- fBatchFontCache = new GrBatchFontCache(this);
+ fAtlasGlyphCache = new GrAtlasGlyphCache(this);
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB, this));
}
@@ -128,7 +127,7 @@
delete fResourceProvider;
delete fResourceCache;
- delete fBatchFontCache;
+ delete fAtlasGlyphCache;
fGpu->unref();
fCaps->unref();
@@ -156,7 +155,7 @@
fGpu->disconnect(GrGpu::DisconnectType::kAbandon);
- fBatchFontCache->freeAll();
+ fAtlasGlyphCache->freeAll();
fTextBlobCache->freeAll();
}
@@ -174,7 +173,7 @@
fGpu->disconnect(GrGpu::DisconnectType::kCleanup);
- fBatchFontCache->freeAll();
+ fAtlasGlyphCache->freeAll();
fTextBlobCache->freeAll();
}
@@ -188,7 +187,7 @@
this->flush();
- fBatchFontCache->freeAll();
+ fAtlasGlyphCache->freeAll();
fDrawingManager->freeGpuResources();
diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp
index d576789..38fc5e0 100644
--- a/src/gpu/ops/GrAtlasTextOp.cpp
+++ b/src/gpu/ops/GrAtlasTextOp.cpp
@@ -15,7 +15,7 @@
#include "effects/GrBitmapTextGeoProc.h"
#include "effects/GrDistanceFieldGeoProc.h"
-#include "text/GrBatchFontCache.h"
+#include "text/GrAtlasGlyphCache.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h
index 6bb0474..9040ef3 100644
--- a/src/gpu/ops/GrAtlasTextOp.h
+++ b/src/gpu/ops/GrAtlasTextOp.h
@@ -32,7 +32,7 @@
};
static sk_sp<GrAtlasTextOp> MakeBitmap(GrMaskFormat maskFormat, int glyphCount,
- GrBatchFontCache* fontCache) {
+ GrAtlasGlyphCache* fontCache) {
sk_sp<GrAtlasTextOp> op(new GrAtlasTextOp);
op->fFontCache = fontCache;
@@ -56,7 +56,7 @@
}
static sk_sp<GrAtlasTextOp> MakeDistanceField(
- int glyphCount, GrBatchFontCache* fontCache,
+ int glyphCount, GrAtlasGlyphCache* fontCache,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
bool useGammaCorrectDistanceTable, SkColor filteredColor, bool isLCD, bool useBGR) {
sk_sp<GrAtlasTextOp> op(new GrAtlasTextOp);
@@ -175,7 +175,7 @@
} fMaskType;
bool fUseBGR; // fold this into the enum?
- GrBatchFontCache* fFontCache;
+ GrAtlasGlyphCache* fFontCache;
// Distance field properties
sk_sp<const GrDistanceFieldAdjustTable> fDistanceAdjustTable;
diff --git a/src/gpu/text/GrBatchFontCache.cpp b/src/gpu/text/GrAtlasGlyphCache.cpp
similarity index 91%
rename from src/gpu/text/GrBatchFontCache.cpp
rename to src/gpu/text/GrAtlasGlyphCache.cpp
index 04acdd2..6884c91 100644
--- a/src/gpu/text/GrBatchFontCache.cpp
+++ b/src/gpu/text/GrAtlasGlyphCache.cpp
@@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
-#include "GrBatchFontCache.h"
+#include "GrAtlasGlyphCache.h"
#include "GrContext.h"
#include "GrGpu.h"
#include "GrRectanizer.h"
@@ -15,7 +15,7 @@
#include "SkDistanceFieldGen.h"
-bool GrBatchFontCache::initAtlas(GrMaskFormat format) {
+bool GrAtlasGlyphCache::initAtlas(GrMaskFormat format) {
int index = MaskFormatToAtlasIndex(format);
if (!fAtlases[index]) {
GrPixelConfig config = MaskFormatToPixelConfig(format, *fContext->caps());
@@ -24,10 +24,9 @@
int numPlotsX = fAtlasConfigs[index].numPlotsX();
int numPlotsY = fAtlasConfigs[index].numPlotsY();
- fAtlases[index] = fContext->resourceProvider()->makeAtlas(config, width, height,
- numPlotsX, numPlotsY,
- &GrBatchFontCache::HandleEviction,
- (void*)this);
+ fAtlases[index] = fContext->resourceProvider()->makeAtlas(
+ config, width, height, numPlotsX, numPlotsY, &GrAtlasGlyphCache::HandleEviction,
+ (void*)this);
if (!fAtlases[index]) {
return false;
}
@@ -35,7 +34,7 @@
return true;
}
-GrBatchFontCache::GrBatchFontCache(GrContext* context)
+GrAtlasGlyphCache::GrAtlasGlyphCache(GrContext* context)
: fContext(context)
, fPreserveStrike(nullptr) {
@@ -62,7 +61,7 @@
fAtlasConfigs[kARGB_GrMaskFormat].fPlotHeight = 256;
}
-GrBatchFontCache::~GrBatchFontCache() {
+GrAtlasGlyphCache::~GrAtlasGlyphCache() {
StrikeHash::Iter iter(&fCache);
while (!iter.done()) {
(*iter).fIsAbandoned = true;
@@ -71,7 +70,7 @@
}
}
-void GrBatchFontCache::freeAll() {
+void GrAtlasGlyphCache::freeAll() {
StrikeHash::Iter iter(&fCache);
while (!iter.done()) {
(*iter).fIsAbandoned = true;
@@ -84,18 +83,18 @@
}
}
-void GrBatchFontCache::HandleEviction(GrBatchAtlas::AtlasID id, void* ptr) {
- GrBatchFontCache* fontCache = reinterpret_cast<GrBatchFontCache*>(ptr);
+void GrAtlasGlyphCache::HandleEviction(GrBatchAtlas::AtlasID id, void* ptr) {
+ GrAtlasGlyphCache* fontCache = reinterpret_cast<GrAtlasGlyphCache*>(ptr);
StrikeHash::Iter iter(&fontCache->fCache);
for (; !iter.done(); ++iter) {
- GrBatchTextStrike* strike = &*iter;
+ GrAtlasTextStrike* strike = &*iter;
strike->removeID(id);
// clear out any empty strikes. We will preserve the strike whose call to addToAtlas
// triggered the eviction
if (strike != fontCache->fPreserveStrike && 0 == strike->fAtlasedGlyphs) {
- fontCache->fCache.remove(GrBatchTextStrike::GetKey(*strike));
+ fontCache->fCache.remove(GrAtlasTextStrike::GetKey(*strike));
strike->fIsAbandoned = true;
strike->unref();
}
@@ -161,7 +160,7 @@
return true;
}
-void GrBatchFontCache::dump() const {
+void GrAtlasGlyphCache::dump() const {
static int gDumpCount = 0;
for (int i = 0; i < kMaskFormatCount; ++i) {
if (fAtlases[i]) {
@@ -184,7 +183,7 @@
}
#endif
-void GrBatchFontCache::setAtlasSizes_ForTesting(const GrBatchAtlasConfig configs[3]) {
+void GrAtlasGlyphCache::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++) {
@@ -357,14 +356,14 @@
atlas and a position within that texture.
*/
-GrBatchTextStrike::GrBatchTextStrike(GrBatchFontCache* owner, const SkDescriptor& key)
+GrAtlasTextStrike::GrAtlasTextStrike(GrAtlasGlyphCache* owner, const SkDescriptor& key)
: fFontScalerKey(key)
, fPool(9/*start allocations at 512 bytes*/)
- , fBatchFontCache(owner) // no need to ref, it won't go away before we do
+ , fAtlasGlyphCache(owner) // no need to ref, it won't go away before we do
, fAtlasedGlyphs(0)
, fIsAbandoned(false) {}
-GrBatchTextStrike::~GrBatchTextStrike() {
+GrAtlasTextStrike::~GrAtlasTextStrike() {
SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache);
while (!iter.done()) {
(*iter).reset();
@@ -372,7 +371,7 @@
}
}
-GrGlyph* GrBatchTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed,
+GrGlyph* GrAtlasTextStrike::generateGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed,
SkGlyphCache* cache) {
SkIRect bounds;
if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(packed)) {
@@ -392,7 +391,7 @@
return glyph;
}
-void GrBatchTextStrike::removeID(GrBatchAtlas::AtlasID id) {
+void GrAtlasTextStrike::removeID(GrBatchAtlas::AtlasID id) {
SkTDynamicHash<GrGlyph, GrGlyph::PackedID>::Iter iter(&fCache);
while (!iter.done()) {
if (id == (*iter).fID) {
@@ -404,7 +403,7 @@
}
}
-bool GrBatchTextStrike::addGlyphToAtlas(GrDrawOp::Target* target,
+bool GrAtlasTextStrike::addGlyphToAtlas(GrDrawOp::Target* target,
GrGlyph* glyph,
SkGlyphCache* cache,
GrMaskFormat expectedMaskFormat) {
@@ -431,7 +430,7 @@
}
}
- bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expectedMaskFormat,
+ bool success = fAtlasGlyphCache->addToAtlas(this, &glyph->fID, target, expectedMaskFormat,
glyph->width(), glyph->height(),
storage.get(), &glyph->fAtlasLocation);
if (success) {
diff --git a/src/gpu/text/GrBatchFontCache.h b/src/gpu/text/GrAtlasGlyphCache.h
similarity index 77%
rename from src/gpu/text/GrBatchFontCache.h
rename to src/gpu/text/GrAtlasGlyphCache.h
index a06652b..5311266 100644
--- a/src/gpu/text/GrBatchFontCache.h
+++ b/src/gpu/text/GrAtlasGlyphCache.h
@@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
-#ifndef GrBatchFontCache_DEFINED
-#define GrBatchFontCache_DEFINED
+#ifndef GrAtlasGlyphCache_DEFINED
+#define GrAtlasGlyphCache_DEFINED
#include "GrBatchAtlas.h"
#include "GrCaps.h"
@@ -15,21 +15,21 @@
#include "SkTDynamicHash.h"
#include "SkVarAlloc.h"
-class GrBatchFontCache;
+class GrAtlasGlyphCache;
class GrGpu;
/**
- * The GrBatchTextStrike manages a pool of CPU backing memory for GrGlyphs. This backing memory
+ * The GrAtlasTextStrike manages a pool of CPU backing memory for GrGlyphs. This backing memory
* is indexed by a PackedID and SkGlyphCache. The SkGlyphCache is what actually creates the mask.
- * The GrBatchTextStrike may outlive the generating SkGlyphCache. However, it retains a copy
- * of it's SkDescriptor as a key to access (or regenerate) the SkGlyphCache. GrBatchTextStrikes are
- * created by and owned by a GrBatchFontCache.
+ * The GrAtlasTextStrike may outlive the generating SkGlyphCache. However, it retains a copy
+ * of it's SkDescriptor as a key to access (or regenerate) the SkGlyphCache. GrAtlasTextStrike are
+ * created by and owned by a GrAtlasGlyphCache.
*/
-class GrBatchTextStrike : public SkNVRefCnt<GrBatchTextStrike> {
+class GrAtlasTextStrike : public SkNVRefCnt<GrAtlasTextStrike> {
public:
/** Owner is the cache that owns this strike. */
- GrBatchTextStrike(GrBatchFontCache* owner, const SkDescriptor& fontScalerKey);
- ~GrBatchTextStrike();
+ GrAtlasTextStrike(GrAtlasGlyphCache* owner, const SkDescriptor& fontScalerKey);
+ ~GrAtlasTextStrike();
inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed,
SkGlyphCache* cache) {
@@ -40,7 +40,7 @@
return glyph;
}
- // This variant of the above function is called by TextBatch. At this point, it is possible
+ // This variant of the above function is called by GrAtlasTextOp. At this point, it is possible
// that the maskformat of the glyph differs from what we expect. In these cases we will just
// draw a clear square.
// skbug:4143 crbug:510931
@@ -76,7 +76,7 @@
// If a TextStrike is abandoned by the cache, then the caller must get a new strike
bool isAbandoned() const { return fIsAbandoned; }
- static const SkDescriptor& GetKey(const GrBatchTextStrike& ts) {
+ static const SkDescriptor& GetKey(const GrAtlasTextStrike& ts) {
return *ts.fFontScalerKey.getDesc();
}
@@ -87,7 +87,7 @@
SkAutoDescriptor fFontScalerKey;
SkVarAlloc fPool;
- GrBatchFontCache* fBatchFontCache;
+ GrAtlasGlyphCache* fAtlasGlyphCache;
int fAtlasedGlyphs;
bool fIsAbandoned;
@@ -99,27 +99,25 @@
GrGlyph* generateGlyph(const SkGlyph&, GrGlyph::PackedID, SkGlyphCache*);
- friend class GrBatchFontCache;
+ friend class GrAtlasGlyphCache;
};
/*
- * GrBatchFontCache manages strikes which are indexed by a SkGlyphCache. These strikes can then be
- * used to individual Glyph Masks. The GrBatchFontCache also manages GrBatchAtlases, though this is
- * more or less transparent to the client(aside from atlasGeneration, described below).
- * Note - we used to initialize the backing atlas for the GrBatchFontCache at initialization time.
- * However, this caused a regression, even when the GrBatchFontCache was unused. We now initialize
- * the backing atlases lazily. Its not immediately clear why this improves the situation.
+ * GrAtlasGlyphCache manages strikes which are indexed by a SkGlyphCache. These strikes can then be
+ * used to generate individual Glyph Masks. The GrAtlasGlyphCache also manages GrBatchAtlases,
+ * though this is more or less transparent to the client(aside from atlasGeneration, described
+ * below).
*/
-class GrBatchFontCache {
+class GrAtlasGlyphCache {
public:
- GrBatchFontCache(GrContext*);
- ~GrBatchFontCache();
+ GrAtlasGlyphCache(GrContext*);
+ ~GrAtlasGlyphCache();
// The user of the cache may hold a long-lived ref to the returned strike. However, actions by
// another client of the cache may cause the strike to be purged while it is still reffed.
- // Therefore, the caller must check GrBatchTextStrike::isAbandoned() if there are other
+ // Therefore, the caller must check GrAtlasTextStrike::isAbandoned() if there are other
// interactions with the cache since the strike was received.
- inline GrBatchTextStrike* getStrike(const SkGlyphCache* cache) {
- GrBatchTextStrike* strike = fCache.find(cache->getDescriptor());
+ inline GrAtlasTextStrike* getStrike(const SkGlyphCache* cache) {
+ GrAtlasTextStrike* strike = fCache.find(cache->getDescriptor());
if (nullptr == strike) {
strike = this->generateStrike(cache);
}
@@ -129,7 +127,7 @@
void freeAll();
// if texture returns nullptr, the client must not try to use other functions on the
- // GrBatchFontCache which use the atlas. This function *must* be called first, before other
+ // GrAtlasGlyphCache which use the atlas. This function *must* be called first, before other
// functions which use the atlas.
GrTexture* getTexture(GrMaskFormat format) {
if (this->initAtlas(format)) {
@@ -144,7 +142,7 @@
}
// To ensure the GrBatchAtlas does not evict the Glyph Mask from its texture backing store,
- // the client must pass in the current batch token along with the GrGlyph.
+ // the client must pass in the current op token along with the GrGlyph.
// A BulkUseTokenUpdater is used to manage bulk last use token updating in the Atlas.
// For convenience, this function will also set the use token for the current glyph if required
// NOTE: the bulk uploader is only valid if the subrun has a valid atlasGeneration
@@ -162,7 +160,7 @@
}
// add to texture atlas that matches this format
- bool addToAtlas(GrBatchTextStrike* strike, GrBatchAtlas::AtlasID* id,
+ bool addToAtlas(GrAtlasTextStrike* strike, GrBatchAtlas::AtlasID* id,
GrDrawOp::Target* target,
GrMaskFormat format, int width, int height, const void* image,
SkIPoint16* loc) {
@@ -171,8 +169,8 @@
}
// Some clients may wish to verify the integrity of the texture backing store of the
- // GrBatchAtlas. The atlasGeneration returned below is a monitonically increasing number which
- // changes everytime something is removed from the texture backing store.
+ // GrBatchAtlas. The atlasGeneration returned below is a monotonically increasing number which
+ // changes every time something is removed from the texture backing store.
uint64_t atlasGeneration(GrMaskFormat format) const {
return this->getAtlas(format)->atlasGeneration();
}
@@ -218,8 +216,8 @@
bool initAtlas(GrMaskFormat);
- GrBatchTextStrike* generateStrike(const SkGlyphCache* cache) {
- GrBatchTextStrike* strike = new GrBatchTextStrike(this, cache->getDescriptor());
+ GrAtlasTextStrike* generateStrike(const SkGlyphCache* cache) {
+ GrAtlasTextStrike* strike = new GrAtlasTextStrike(this, cache->getDescriptor());
fCache.add(strike);
return strike;
}
@@ -232,11 +230,11 @@
static void HandleEviction(GrBatchAtlas::AtlasID, void*);
- using StrikeHash = SkTDynamicHash<GrBatchTextStrike, SkDescriptor>;
+ using StrikeHash = SkTDynamicHash<GrAtlasTextStrike, SkDescriptor>;
GrContext* fContext;
StrikeHash fCache;
std::unique_ptr<GrBatchAtlas> fAtlases[kMaskFormatCount];
- GrBatchTextStrike* fPreserveStrike;
+ GrAtlasTextStrike* fPreserveStrike;
GrBatchAtlasConfig fAtlasConfigs[kMaskFormatCount];
};
diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrAtlasTextBlob.cpp
index 1420ad0..bf42d5d 100644
--- a/src/gpu/text/GrAtlasTextBlob.cpp
+++ b/src/gpu/text/GrAtlasTextBlob.cpp
@@ -71,7 +71,7 @@
void GrAtlasTextBlob::appendGlyph(int runIndex,
const SkRect& positions,
GrColor color,
- GrBatchTextStrike* strike,
+ GrAtlasTextStrike* strike,
GrGlyph* glyph,
SkGlyphCache* cache, const SkGlyph& skGlyph,
SkScalar x, SkScalar y, SkScalar scale, bool treatAsBMP) {
@@ -258,7 +258,7 @@
const Run::SubRunInfo& info, int glyphCount, int run, int subRun,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint,
const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable,
- bool useGammaCorrectDistanceTable, GrBatchFontCache* cache) {
+ bool useGammaCorrectDistanceTable, GrAtlasGlyphCache* cache) {
GrMaskFormat format = info.maskFormat();
GrColor subRunColor;
if (kARGB_GrMaskFormat == format) {
@@ -303,7 +303,7 @@
SkScalar y,
const SkPaint& skPaint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- GrBatchFontCache* cache) {
+ GrAtlasGlyphCache* cache) {
for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) {
const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
int glyphCount = info.glyphCount();
@@ -425,7 +425,7 @@
continue;
}
this->flushRun(rtc, grPaint, clip, run, viewMatrix, x, y, skPaint, props,
- distanceAdjustTable, context->getBatchFontCache());
+ distanceAdjustTable, context->getAtlasGlyphCache());
}
// Now flush big glyphs
@@ -444,7 +444,7 @@
SkScalar x, SkScalar y) {
for (int run = 0; run < fRunCount; run++) {
this->flushRun(rtc, grPaint, clip, run, viewMatrix, x, y, skPaint, props,
- distanceAdjustTable, context->getBatchFontCache());
+ distanceAdjustTable, context->getAtlasGlyphCache());
}
// Now flush big glyphs
@@ -456,7 +456,7 @@
GrColor color, const SkPaint& skPaint,
const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- GrBatchFontCache* cache) {
+ GrAtlasGlyphCache* cache) {
const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun];
return this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint, props,
distanceAdjustTable, false, cache);
@@ -530,8 +530,8 @@
if (lSubRun.strike()) {
SkASSERT_RELEASE(rSubRun.strike());
- SkASSERT_RELEASE(GrBatchTextStrike::GetKey(*lSubRun.strike()) ==
- GrBatchTextStrike::GetKey(*rSubRun.strike()));
+ SkASSERT_RELEASE(GrAtlasTextStrike::GetKey(*lSubRun.strike()) ==
+ GrAtlasTextStrike::GetKey(*rSubRun.strike()));
} else {
SkASSERT_RELEASE(!rSubRun.strike());
diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrAtlasTextBlob.h
index 9d19a70..149aa66 100644
--- a/src/gpu/text/GrAtlasTextBlob.h
+++ b/src/gpu/text/GrAtlasTextBlob.h
@@ -8,8 +8,8 @@
#ifndef GrAtlasTextBlob_DEFINED
#define GrAtlasTextBlob_DEFINED
+#include "GrAtlasGlyphCache.h"
#include "GrBatchAtlas.h"
-#include "GrBatchFontCache.h"
#include "GrColor.h"
#include "GrMemoryPool.h"
#include "SkDescriptor.h"
@@ -161,7 +161,7 @@
void appendGlyph(int runIndex,
const SkRect& positions,
GrColor color,
- GrBatchTextStrike* strike,
+ GrAtlasTextStrike* strike,
GrGlyph* glyph,
SkGlyphCache*, const SkGlyph& skGlyph,
SkScalar x, SkScalar y, SkScalar scale, bool treatAsBMP);
@@ -264,7 +264,7 @@
* SkAutoGlyphCache is passed to multiple calls of regenInBatch then it can save the cost of
* multiple detach/attach operations of SkGlyphCache.
*/
- void regenInBatch(GrDrawOp::Target* target, GrBatchFontCache* fontCache,
+ void regenInBatch(GrDrawOp::Target* target, GrAtlasGlyphCache* fontCache,
GrBlobRegenHelper *helper, int run, int subRun, SkAutoGlyphCache*,
size_t vertexStride, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
GrColor color, void** vertices, size_t* byteCount, int* glyphCount);
@@ -283,7 +283,7 @@
SkScalar x, SkScalar y, GrColor color, const SkPaint& skPaint,
const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- GrBatchFontCache* cache);
+ GrAtlasGlyphCache* cache);
private:
GrAtlasTextBlob()
@@ -298,7 +298,7 @@
int run, const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
const SkPaint& skPaint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- GrBatchFontCache* cache);
+ GrAtlasGlyphCache* cache);
void flushBigGlyphs(GrContext* context, GrRenderTargetContext* rtc,
const GrClip& clip, const SkPaint& skPaint,
@@ -396,8 +396,8 @@
// TODO when this object is more internal, drop the privacy
void resetBulkUseToken() { fBulkUseToken.reset(); }
GrBatchAtlas::BulkUseTokenUpdater* bulkUseToken() { return &fBulkUseToken; }
- void setStrike(GrBatchTextStrike* strike) { fStrike.reset(SkRef(strike)); }
- GrBatchTextStrike* strike() const { return fStrike.get(); }
+ void setStrike(GrAtlasTextStrike* strike) { fStrike.reset(SkRef(strike)); }
+ GrAtlasTextStrike* strike() const { return fStrike.get(); }
void setAtlasGeneration(uint64_t atlasGeneration) { fAtlasGeneration = atlasGeneration;}
uint64_t atlasGeneration() const { return fAtlasGeneration; }
@@ -452,7 +452,7 @@
private:
GrBatchAtlas::BulkUseTokenUpdater fBulkUseToken;
- sk_sp<GrBatchTextStrike> fStrike;
+ sk_sp<GrAtlasTextStrike> fStrike;
SkMatrix fCurrentViewMatrix;
SkRect fVertexBounds;
uint64_t fAtlasGeneration;
@@ -496,7 +496,7 @@
};
template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs>
- void regenInOp(GrDrawOp::Target* target, GrBatchFontCache* fontCache, GrBlobRegenHelper* helper,
+ void regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fontCache, GrBlobRegenHelper* helper,
Run* run, Run::SubRunInfo* info, SkAutoGlyphCache*, int glyphCount,
size_t vertexStride, GrColor color, SkScalar transX, SkScalar transY) const;
@@ -504,7 +504,7 @@
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
const SkPaint& skPaint, const SkSurfaceProps& props,
const GrDistanceFieldAdjustTable* distanceAdjustTable,
- bool useGammaCorrectDistanceTable, GrBatchFontCache* cache);
+ bool useGammaCorrectDistanceTable, GrAtlasGlyphCache* cache);
struct BigGlyph {
BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, bool treatAsBMP)
diff --git a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
index 88321b9..7f22d92 100644
--- a/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
+++ b/src/gpu/text/GrAtlasTextBlob_regenInBatch.cpp
@@ -138,13 +138,13 @@
}
template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs>
-void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target, GrBatchFontCache* fontCache,
+void GrAtlasTextBlob::regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fontCache,
GrBlobRegenHelper* helper, Run* run, Run::SubRunInfo* info,
SkAutoGlyphCache* lazyCache, int glyphCount, size_t vertexStride,
GrColor color, SkScalar transX, SkScalar transY) const {
SkASSERT(lazyCache);
static_assert(!regenGlyphs || regenTexCoords, "must regenTexCoords along regenGlyphs");
- GrBatchTextStrike* strike = nullptr;
+ GrAtlasTextStrike* strike = nullptr;
if (regenTexCoords) {
info->resetBulkUseToken();
@@ -242,7 +242,7 @@
*glyphCount, vertexStride, color, transX, transY
void GrAtlasTextBlob::regenInBatch(GrDrawOp::Target* target,
- GrBatchFontCache* fontCache,
+ GrAtlasGlyphCache* fontCache,
GrBlobRegenHelper *helper,
int runIndex, int subRunIndex, SkAutoGlyphCache* lazyCache,
size_t vertexStride, const SkMatrix& viewMatrix,
@@ -257,7 +257,7 @@
SkScalar transX, transY;
info.computeTranslation(viewMatrix, x, y, &transX, &transY);
- // Because the GrBatchFontCache may evict the strike a blob depends on using for
+ // Because the GrAtlasGlyphCache may evict the strike a blob depends on using for
// generating its texture coords, we have to track whether or not the strike has
// been abandoned. If it hasn't been abandoned, then we can use the GrGlyph*s as is
// otherwise we have to get the new strike, and use that to get the correct glyphs.
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index 2e2cf40..032a983 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -135,7 +135,7 @@
// but we'd have to clear the subrun information
cache->remove(cacheBlob.get());
cacheBlob.reset(SkRef(cache->createCachedBlob(blob, key, blurRec, skPaint)));
- RegenerateTextBlob(cacheBlob.get(), context->getBatchFontCache(),
+ RegenerateTextBlob(cacheBlob.get(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), skPaint, grPaint.getColor(),
scalerContextFlags, viewMatrix, props,
blob, x, y, drawFilter);
@@ -148,7 +148,7 @@
GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob);
sk_sp<GrAtlasTextBlob> sanityBlob(cache->createBlob(glyphCount, runCount));
sanityBlob->setupKey(key, blurRec, skPaint);
- RegenerateTextBlob(sanityBlob.get(), context->getBatchFontCache(),
+ RegenerateTextBlob(sanityBlob.get(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), skPaint,
grPaint.getColor(), scalerContextFlags, viewMatrix, props,
blob, x, y, drawFilter);
@@ -161,7 +161,7 @@
} else {
cacheBlob.reset(cache->createBlob(blob));
}
- RegenerateTextBlob(cacheBlob.get(), context->getBatchFontCache(),
+ RegenerateTextBlob(cacheBlob.get(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), skPaint, grPaint.getColor(),
scalerContextFlags, viewMatrix, props,
blob, x, y, drawFilter);
@@ -172,7 +172,7 @@
}
void GrAtlasTextContext::RegenerateTextBlob(GrAtlasTextBlob* cacheBlob,
- GrBatchFontCache* fontCache,
+ GrAtlasGlyphCache* fontCache,
const GrShaderCaps& shaderCaps,
const SkPaint& skPaint, GrColor color,
uint32_t scalerContextFlags,
@@ -263,7 +263,7 @@
inline GrAtlasTextBlob*
GrAtlasTextContext::CreateDrawTextBlob(GrTextBlobCache* blobCache,
- GrBatchFontCache* fontCache,
+ GrAtlasGlyphCache* fontCache,
const GrShaderCaps& shaderCaps,
const GrPaint& paint,
const SkPaint& skPaint,
@@ -288,7 +288,7 @@
}
inline GrAtlasTextBlob*
-GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrBatchFontCache* fontCache,
+GrAtlasTextContext::CreateDrawPosTextBlob(GrTextBlobCache* blobCache, GrAtlasGlyphCache* fontCache,
const GrShaderCaps& shaderCaps, const GrPaint& paint,
const SkPaint& skPaint, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix, const SkSurfaceProps& props,
@@ -324,7 +324,7 @@
return;
} else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shaderCaps())) {
sk_sp<GrAtlasTextBlob> blob(
- CreateDrawTextBlob(context->getTextBlobCache(), context->getBatchFontCache(),
+ CreateDrawTextBlob(context->getTextBlobCache(), context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(),
paint, skPaint,
ComputeScalerContextFlags(rtc),
@@ -354,7 +354,7 @@
} else if (this->canDraw(skPaint, viewMatrix, props, *context->caps()->shaderCaps())) {
sk_sp<GrAtlasTextBlob> blob(
CreateDrawPosTextBlob(context->getTextBlobCache(),
- context->getBatchFontCache(),
+ context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(),
paint, skPaint,
ComputeScalerContextFlags(rtc),
@@ -421,7 +421,7 @@
// intend to test the batch with this unit test, that is okay.
sk_sp<GrAtlasTextBlob> blob(
GrAtlasTextContext::CreateDrawTextBlob(context->getTextBlobCache(),
- context->getBatchFontCache(),
+ context->getAtlasGlyphCache(),
*context->caps()->shaderCaps(), grPaint, skPaint,
GrAtlasTextContext::kTextBlobBatchScalerContextFlags,
viewMatrix,
@@ -430,7 +430,7 @@
return blob
->test_makeOp(textLen, 0, 0, viewMatrix, x, y, color, skPaint, gSurfaceProps,
- gTextContext->dfAdjustTable(), context->getBatchFontCache())
+ gTextContext->dfAdjustTable(), context->getAtlasGlyphCache())
.release();
}
diff --git a/src/gpu/text/GrAtlasTextContext.h b/src/gpu/text/GrAtlasTextContext.h
index d0e5a6c..471d9d2 100644
--- a/src/gpu/text/GrAtlasTextContext.h
+++ b/src/gpu/text/GrAtlasTextContext.h
@@ -54,7 +54,7 @@
// Determines if we need to use fake gamma (and contrast boost):
inline static uint32_t ComputeScalerContextFlags(GrRenderTargetContext*);
static void RegenerateTextBlob(GrAtlasTextBlob* bmp,
- GrBatchFontCache*,
+ GrAtlasGlyphCache*,
const GrShaderCaps&,
const SkPaint& skPaint, GrColor,
uint32_t scalerContextFlags,
@@ -65,7 +65,7 @@
inline static bool HasLCD(const SkTextBlob*);
static inline GrAtlasTextBlob* CreateDrawTextBlob(GrTextBlobCache*,
- GrBatchFontCache*, const GrShaderCaps&,
+ GrAtlasGlyphCache*, const GrShaderCaps&,
const GrPaint&,
const SkPaint&,
uint32_t scalerContextFlags,
@@ -73,7 +73,7 @@
const SkSurfaceProps&,
const char text[], size_t byteLength,
SkScalar x, SkScalar y);
- static inline GrAtlasTextBlob* CreateDrawPosTextBlob(GrTextBlobCache*, GrBatchFontCache*,
+ static inline GrAtlasTextBlob* CreateDrawPosTextBlob(GrTextBlobCache*, GrAtlasGlyphCache*,
const GrShaderCaps&,
const GrPaint&,
const SkPaint&,
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index 7f7dc68..5793ade 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -7,8 +7,8 @@
#include "GrTextUtils.h"
+#include "GrAtlasGlyphCache.h"
#include "GrAtlasTextBlob.h"
-#include "GrBatchFontCache.h"
#include "GrBlurUtils.h"
#include "GrCaps.h"
#include "GrContext.h"
@@ -38,7 +38,7 @@
};
void GrTextUtils::DrawBmpText(GrAtlasTextBlob* blob, int runIndex,
- GrBatchFontCache* fontCache,
+ GrAtlasGlyphCache* fontCache,
const SkSurfaceProps& props, const SkPaint& skPaint,
GrColor color, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
@@ -54,7 +54,7 @@
// Ensure the blob is set for bitmaptext
blob->setHasBitmap();
- GrBatchTextStrike* currStrike = nullptr;
+ GrAtlasTextStrike* currStrike = nullptr;
SkGlyphCache* cache = blob->setupCache(runIndex, props, scalerContextFlags, skPaint,
&viewMatrix);
@@ -75,7 +75,7 @@
}
void GrTextUtils::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex,
- GrBatchFontCache* fontCache,
+ GrAtlasGlyphCache* fontCache,
const SkSurfaceProps& props, const SkPaint& skPaint,
GrColor color, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
@@ -93,7 +93,7 @@
// Ensure the blob is set for bitmaptext
blob->setHasBitmap();
- GrBatchTextStrike* currStrike = nullptr;
+ GrAtlasTextStrike* currStrike = nullptr;
SkGlyphCache* cache = blob->setupCache(runIndex, props, scalerContextFlags, skPaint,
&viewMatrix);
@@ -115,8 +115,8 @@
}
void GrTextUtils::BmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex,
- GrBatchFontCache* fontCache,
- GrBatchTextStrike** strike, const SkGlyph& skGlyph,
+ GrAtlasGlyphCache* fontCache,
+ GrAtlasTextStrike** strike, const SkGlyph& skGlyph,
int vx, int vy, GrColor color, SkGlyphCache* cache) {
if (!*strike) {
*strike = fontCache->getStrike(cache);
@@ -241,7 +241,7 @@
}
void GrTextUtils::DrawDFText(GrAtlasTextBlob* blob, int runIndex,
- GrBatchFontCache* fontCache, const SkSurfaceProps& props,
+ GrAtlasGlyphCache* fontCache, const SkSurfaceProps& props,
const SkPaint& skPaint, GrColor color, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -316,7 +316,7 @@
}
void GrTextUtils::DrawDFPosText(GrAtlasTextBlob* blob, int runIndex,
- GrBatchFontCache* fontCache, const SkSurfaceProps& props,
+ GrAtlasGlyphCache* fontCache, const SkSurfaceProps& props,
const SkPaint& origPaint,
GrColor color, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
@@ -341,7 +341,7 @@
blob->setHasDistanceField();
blob->setSubRunHasDistanceFields(runIndex, origPaint.isLCDRenderText());
- GrBatchTextStrike* currStrike = nullptr;
+ GrAtlasTextStrike* currStrike = nullptr;
// We apply the fake-gamma by altering the distance in the shader, so we ignore the
// passed-in scaler context flags. (It's only used when we fall-back to bitmap text).
@@ -426,8 +426,8 @@
}
}
-bool GrTextUtils::DfAppendGlyph(GrAtlasTextBlob* blob, int runIndex, GrBatchFontCache* cache,
- GrBatchTextStrike** strike, const SkGlyph& skGlyph,
+bool GrTextUtils::DfAppendGlyph(GrAtlasTextBlob* blob, int runIndex, GrAtlasGlyphCache* cache,
+ GrAtlasTextStrike** strike, const SkGlyph& skGlyph,
SkScalar sx, SkScalar sy, GrColor color,
SkGlyphCache* glyphCache,
SkScalar textRatio, const SkMatrix& viewMatrix) {
diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h
index 9529c54..93a0c1f 100644
--- a/src/gpu/text/GrTextUtils.h
+++ b/src/gpu/text/GrTextUtils.h
@@ -12,9 +12,9 @@
#include "SkPaint.h"
#include "SkScalar.h"
+class GrAtlasGlyphCache;
class GrAtlasTextBlob;
-class GrBatchFontCache;
-class GrBatchTextStrike;
+class GrAtlasTextStrike;
class GrClip;
class GrContext;
class GrRenderTargetContext;
@@ -35,14 +35,14 @@
public:
// Functions for appending BMP text to GrAtlasTextBlob
static void DrawBmpText(GrAtlasTextBlob*, int runIndex,
- GrBatchFontCache*, const SkSurfaceProps&,
+ GrAtlasGlyphCache*, const SkSurfaceProps&,
const SkPaint&,
GrColor, uint32_t scalerContextFlags, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y);
static void DrawBmpPosText(GrAtlasTextBlob*, int runIndex,
- GrBatchFontCache*, const SkSurfaceProps&, const SkPaint&,
+ GrAtlasGlyphCache*, const SkSurfaceProps&, const SkPaint&,
GrColor, uint32_t scalerContextFlags, const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
const SkScalar pos[], int scalarsPerPosition,
@@ -53,14 +53,14 @@
const SkSurfaceProps& props, const GrShaderCaps& caps);
static void DrawDFText(GrAtlasTextBlob* blob, int runIndex,
- GrBatchFontCache*, const SkSurfaceProps&,
+ GrAtlasGlyphCache*, const SkSurfaceProps&,
const SkPaint& skPaint, GrColor color, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
SkScalar x, SkScalar y);
static void DrawDFPosText(GrAtlasTextBlob* blob, int runIndex,
- GrBatchFontCache*, const SkSurfaceProps&, const SkPaint&,
+ GrAtlasGlyphCache*, const SkSurfaceProps&, const SkPaint&,
GrColor color, uint32_t scalerContextFlags,
const SkMatrix& viewMatrix,
const char text[], size_t byteLength,
@@ -92,12 +92,12 @@
SkScalar* textRatio,
const SkMatrix& viewMatrix);
- static void BmpAppendGlyph(GrAtlasTextBlob*, int runIndex, GrBatchFontCache*,
- GrBatchTextStrike**, const SkGlyph&, int left, int top,
+ static void BmpAppendGlyph(GrAtlasTextBlob*, int runIndex, GrAtlasGlyphCache*,
+ GrAtlasTextStrike**, const SkGlyph&, int left, int top,
GrColor color, SkGlyphCache*);
- static bool DfAppendGlyph(GrAtlasTextBlob*, int runIndex, GrBatchFontCache*,
- GrBatchTextStrike**, const SkGlyph&,
+ static bool DfAppendGlyph(GrAtlasTextBlob*, int runIndex, GrAtlasGlyphCache*,
+ GrAtlasTextStrike**, const SkGlyph&,
SkScalar sx, SkScalar sy, GrColor color,
SkGlyphCache* cache,
SkScalar textRatio, const SkMatrix& viewMatrix);
diff --git a/tools/gpu/GrTest.cpp b/tools/gpu/GrTest.cpp
index a7feffc..ae1fae6 100644
--- a/tools/gpu/GrTest.cpp
+++ b/tools/gpu/GrTest.cpp
@@ -21,7 +21,7 @@
#include "SkMathPriv.h"
#include "SkString.h"
-#include "text/GrBatchFontCache.h"
+#include "text/GrAtlasGlyphCache.h"
#include "text/GrTextBlobCache.h"
namespace GrTest {
@@ -85,7 +85,7 @@
}
void GrContext::setTextContextAtlasSizes_ForTesting(const GrBatchAtlasConfig* configs) {
- fBatchFontCache->setAtlasSizes_ForTesting(configs);
+ fAtlasGlyphCache->setAtlasSizes_ForTesting(configs);
}
///////////////////////////////////////////////////////////////////////////////
@@ -139,7 +139,7 @@
}
GrTexture* GrContext::getFontAtlasTexture(GrMaskFormat format) {
- GrBatchFontCache* cache = this->getBatchFontCache();
+ GrAtlasGlyphCache* cache = this->getAtlasGlyphCache();
return cache->getTexture(format);
}