Rename GrGlyphCache -> GrStrikeCache

Change-Id: Ie6fdcc6ce1f2265783ebb4dcd1b1ce087a296ddf
Reviewed-on: https://skia-review.googlesource.com/c/184500
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2019-01-16 13:46:02 -05:00 committed by Skia Commit-Bot
parent 765bdaa6ca
commit 081e6f3754
20 changed files with 60 additions and 62 deletions

View File

@ -387,10 +387,10 @@ skia_gpu_sources = [
"$_src/gpu/text/GrAtlasManager.h",
"$_src/gpu/text/GrDistanceFieldAdjustTable.cpp",
"$_src/gpu/text/GrDistanceFieldAdjustTable.h",
"$_src/gpu/text/GrGlyphCache.cpp",
"$_src/gpu/text/GrGlyphCache.h",
"$_src/gpu/text/GrSDFMaskFilter.cpp",
"$_src/gpu/text/GrSDFMaskFilter.h",
"$_src/gpu/text/GrStrikeCache.cpp",
"$_src/gpu/text/GrStrikeCache.h",
"$_src/gpu/text/GrTextBlob.cpp",
"$_src/gpu/text/GrTextBlob.h",
"$_src/gpu/text/GrTextBlobCache.cpp",

View File

@ -29,7 +29,7 @@ class GrContextThreadSafeProxyPriv;
class GrDrawingManager;
class GrFragmentProcessor;
struct GrGLInterface;
class GrGlyphCache;
class GrStrikeCache;
class GrGpu;
struct GrMockOptions;
class GrOpMemoryPool;
@ -312,7 +312,7 @@ private:
// All the GrOp-derived classes use this pool.
sk_sp<GrOpMemoryPool> fOpMemoryPool;
GrGlyphCache* fGlyphCache;
GrStrikeCache* fGlyphCache;
std::unique_ptr<GrTextBlobCache> fTextBlobCache;
bool fDisableGpuYUVConversion;

View File

@ -10,7 +10,7 @@
#include "GrContextPriv.h"
#include "SkAtlasTextContext.h"
#include "SkAtlasTextRenderer.h"
#include "text/GrGlyphCache.h"
#include "text/GrStrikeCache.h"
SkAtlasTextRenderer* SkGetAtlasTextRendererFromInternalContext(
class SkInternalAtlasTextContext& internal) {
@ -49,7 +49,7 @@ SkInternalAtlasTextContext::~SkInternalAtlasTextContext() {
}
}
GrGlyphCache* SkInternalAtlasTextContext::glyphCache() {
GrStrikeCache* SkInternalAtlasTextContext::glyphCache() {
return fGrContext->contextPriv().getGlyphCache();
}

View File

@ -14,7 +14,7 @@
#include "SkRefCnt.h"
class GrContext;
class GrGlyphCache;
class GrStrikeCache;
class GrTextBlobCache;
class SkAtlasTextRenderer;
@ -33,7 +33,7 @@ public:
SkAtlasTextRenderer* renderer() const { return fRenderer.get(); }
GrContext* grContext() const { return fGrContext.get(); }
GrGlyphCache* glyphCache();
GrStrikeCache* glyphCache();
GrTextBlobCache* textBlobCache();
const GrTokenTracker* tokenTracker() final { return &fTokenTracker; }

View File

@ -683,7 +683,7 @@ void GrTextBlob::Run::appendSourceSpaceGlyph(const sk_sp<GrTextStrike>& strike,
}
}
void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache,
void GrTextBlob::generateFromGlyphRunList(GrStrikeCache* glyphCache,
const GrShaderCaps& shaderCaps,
const GrTextContext::Options& options,
const SkPaint& paint,
@ -703,7 +703,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache,
auto subRun = fRun->initARGBFallback();
SkExclusiveStrikePtr fallbackCache = SkStrikeCache::FindOrCreateStrikeExclusive(
fallbackFont, fallbackPaint, fProps, fScalerContextFlags, glyphCacheMatrix);
sk_sp<GrTextStrike> strike = fGlyphCache->getStrike(fallbackCache.get());
sk_sp<GrTextStrike> strike = fGrStrikeCache->getStrike(fallbackCache.get());
fRun->setupFont(fallbackPaint, fallbackFont, fallbackCache->getDescriptor());
SkASSERT(strike != nullptr);
@ -726,7 +726,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache,
GrTextBlob::Run* fRun;
const SkSurfaceProps& fProps;
const SkScalerContextFlags fScalerContextFlags;
GrGlyphCache* const fGlyphCache;
GrStrikeCache* const fGrStrikeCache;
};
SkPoint origin = glyphRunList.origin();
@ -961,7 +961,7 @@ void SkTextBlobCacheDiffCanvas::TrackLayerDevice::processGlyphRunForMask(
// Glyphs which are too large for the atlas still request images when computing the bounds
// for the glyph, which is why its necessary to send both. See related code in
// get_packed_glyph_bounds in GrGlyphCache.cpp and crbug.com/510931.
// get_packed_glyph_bounds in GrStrikeCache.cpp and crbug.com/510931.
auto processPaths = [glyphCacheState]
(SkSpan<const SkGlyphRunListPainter::GlyphAndPos> paths) {
for (const auto& path : paths) {

View File

@ -139,7 +139,7 @@ bool GrContext::initCommon(const GrContextOptions& options) {
options.fSortRenderTargets,
options.fReduceOpListSplitting));
fGlyphCache = new GrGlyphCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes);
fGlyphCache = new GrStrikeCache(fCaps.get(), options.fGlyphCacheTextureMaximumBytes);
fTextBlobCache.reset(new GrTextBlobCache(TextBlobCacheOverBudgetCB,
this, this->uniqueID()));

View File

@ -197,7 +197,7 @@ public:
GrGpu* getGpu() { return fContext->fGpu.get(); }
const GrGpu* getGpu() const { return fContext->fGpu.get(); }
GrGlyphCache* getGlyphCache() { return fContext->fGlyphCache; }
GrStrikeCache* getGlyphCache() { return fContext->fGlyphCache; }
GrTextBlobCache* getTextBlobCache() { return fContext->fTextBlobCache.get(); }
// This accessor should only ever be called by the GrOpFlushState.

View File

@ -14,7 +14,7 @@
#include "effects/GrSkSLFP.h"
#include "gl/GrGLGpu.h"
#include "mock/GrMockGpu.h"
#include "text/GrGlyphCache.h"
#include "text/GrStrikeCache.h"
#ifdef SK_METAL
#include "mtl/GrMtlTrampoline.h"
#endif
@ -78,7 +78,7 @@ protected:
allowMultitexturing = GrDrawOpAtlas::AllowMultitexturing::kYes;
}
GrGlyphCache* glyphCache = this->contextPriv().getGlyphCache();
GrStrikeCache* glyphCache = this->contextPriv().getGlyphCache();
GrProxyProvider* proxyProvider = this->contextPriv().proxyProvider();
fAtlasManager = new GrAtlasManager(proxyProvider, glyphCache,

View File

@ -165,7 +165,7 @@ GrAppliedClip GrOpFlushState::detachAppliedClip() {
return fOpArgs->fAppliedClip ? std::move(*fOpArgs->fAppliedClip) : GrAppliedClip();
}
GrGlyphCache* GrOpFlushState::glyphCache() const {
GrStrikeCache* GrOpFlushState::glyphCache() const {
return fGpu->getContext()->contextPriv().getGlyphCache();
}

View File

@ -99,7 +99,7 @@ public:
const GrCaps& caps() const final;
GrResourceProvider* resourceProvider() const final { return fResourceProvider; }
GrGlyphCache* glyphCache() const final;
GrStrikeCache* glyphCache() const final;
// At this point we know we're flushing so full access to the GrAtlasManager is required (and
// permissible).

View File

@ -20,7 +20,7 @@
#include "effects/GrBitmapTextGeoProc.h"
#include "effects/GrDistanceFieldGeoProc.h"
#include "text/GrAtlasManager.h"
#include "text/GrGlyphCache.h"
#include "text/GrStrikeCache.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
@ -286,7 +286,7 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) {
}
GrAtlasManager* atlasManager = target->atlasManager();
GrGlyphCache* glyphCache = target->glyphCache();
GrStrikeCache* glyphCache = target->glyphCache();
GrMaskFormat maskFormat = this->maskFormat();

View File

@ -11,7 +11,6 @@
#include "ops/GrMeshDrawOp.h"
#include "text/GrTextBlob.h"
#include "text/GrDistanceFieldAdjustTable.h"
#include "text/GrGlyphCache.h"
class SkAtlasTextTarget;
class GrContext;

View File

@ -16,7 +16,7 @@
class GrAtlasManager;
class GrCaps;
class GrGlyphCache;
class GrStrikeCache;
class GrOpFlushState;
/**
@ -190,7 +190,7 @@ public:
virtual GrResourceProvider* resourceProvider() const = 0;
uint32_t contextUniqueID() const { return this->resourceProvider()->contextUniqueID(); }
virtual GrGlyphCache* glyphCache() const = 0;
virtual GrStrikeCache* glyphCache() const = 0;
virtual GrAtlasManager* atlasManager() const = 0;
virtual const GrCaps& caps() const = 0;

View File

@ -8,9 +8,9 @@
#include "GrAtlasManager.h"
#include "GrGlyph.h"
#include "GrGlyphCache.h"
#include "GrStrikeCache.h"
GrAtlasManager::GrAtlasManager(GrProxyProvider* proxyProvider, GrGlyphCache* glyphCache,
GrAtlasManager::GrAtlasManager(GrProxyProvider* proxyProvider, GrStrikeCache* glyphCache,
size_t maxTextureBytes,
GrDrawOpAtlas::AllowMultitexturing allowMultitexturing)
: fAllowMultitexturing{allowMultitexturing}
@ -64,7 +64,7 @@ bool GrAtlasManager::hasGlyph(GrGlyph* glyph) {
// add to texture atlas that matches this format
GrDrawOpAtlas::ErrorCode GrAtlasManager::addToAtlas(
GrResourceProvider* resourceProvider,
GrGlyphCache* glyphCache,
GrStrikeCache* glyphCache,
GrTextStrike* strike, GrDrawOpAtlas::AtlasID* id,
GrDeferredUploadTarget* target, GrMaskFormat format,
int width, int height, const void* image, SkIPoint16* loc) {
@ -186,7 +186,7 @@ bool GrAtlasManager::initAtlas(GrMaskFormat format) {
fAtlases[index] = GrDrawOpAtlas::Make(
fProxyProvider, format, config, atlasDimensions.width(), atlasDimensions.height(),
plotDimensions.width(), plotDimensions.height(), fAllowMultitexturing,
&GrGlyphCache::HandleEviction, fGlyphCache);
&GrStrikeCache::HandleEviction, fGlyphCache);
if (!fAtlases[index]) {
return false;
}

View File

@ -13,9 +13,8 @@
#include "GrOnFlushResourceProvider.h"
#include "GrProxyProvider.h"
class GrAtlasGlypCache;
class GrTextStrike;
struct GrGlyph;
class GrTextStrike;
//////////////////////////////////////////////////////////////////////////////////////////////////
/** The GrAtlasManager manages the lifetime of and access to GrDrawOpAtlases.
@ -26,13 +25,13 @@ struct GrGlyph;
*/
class GrAtlasManager : public GrOnFlushCallbackObject {
public:
GrAtlasManager(GrProxyProvider*, GrGlyphCache*,
GrAtlasManager(GrProxyProvider*, GrStrikeCache*,
size_t maxTextureBytes, GrDrawOpAtlas::AllowMultitexturing);
~GrAtlasManager() override;
// Change an expected 565 mask format to 8888 if 565 is not supported (will happen when using
// Metal on macOS). The actual conversion of the data is handled in get_packed_glyph_image() in
// GrGlyphCache.cpp
// GrStrikeCache.cpp
GrMaskFormat resolveMaskFormat(GrMaskFormat format) const {
if (kA565_GrMaskFormat == format &&
!fProxyProvider->caps()->isConfigTexturable(kRGB_565_GrPixelConfig)) {
@ -42,7 +41,7 @@ public:
}
// if getProxies returns nullptr, the client must not try to use other functions on the
// GrGlyphCache which use the atlas. This function *must* be called first, before other
// GrStrikeCache which use the atlas. This function *must* be called first, before other
// functions which use the atlas. Note that we can have proxies available but none active
// (i.e., none instantiated).
const sk_sp<GrTextureProxy>* getProxies(GrMaskFormat format, unsigned int* numActiveProxies) {
@ -75,7 +74,7 @@ public:
// add to texture atlas that matches this format
GrDrawOpAtlas::ErrorCode addToAtlas(
GrResourceProvider*, GrGlyphCache*, GrTextStrike*,
GrResourceProvider*, GrStrikeCache*, GrTextStrike*,
GrDrawOpAtlas::AtlasID*, GrDeferredUploadTarget*, GrMaskFormat,
int width, int height, const void* image, SkIPoint16* loc);
@ -146,7 +145,7 @@ private:
std::unique_ptr<GrDrawOpAtlas> fAtlases[kMaskFormatCount];
GrProxyProvider* fProxyProvider;
sk_sp<const GrCaps> fCaps;
GrGlyphCache* fGlyphCache;
GrStrikeCache* fGlyphCache;
GrDrawOpAtlasConfig fAtlasConfig;
typedef GrOnFlushCallbackObject INHERITED;

View File

@ -5,7 +5,7 @@
* found in the LICENSE file.
*/
#include "GrGlyphCache.h"
#include "GrStrikeCache.h"
#include "GrAtlasManager.h"
#include "GrCaps.h"
#include "GrColor.h"
@ -14,12 +14,12 @@
#include "SkAutoMalloc.h"
#include "SkDistanceFieldGen.h"
GrGlyphCache::GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes)
GrStrikeCache::GrStrikeCache(const GrCaps* caps, size_t maxTextureBytes)
: fPreserveStrike(nullptr)
, f565Masks(SkMasks::CreateMasks({0xF800, 0x07E0, 0x001F, 0},
GrMaskFormatBytesPerPixel(kA565_GrMaskFormat) * 8)) { }
GrGlyphCache::~GrGlyphCache() {
GrStrikeCache::~GrStrikeCache() {
StrikeHash::Iter iter(&fCache);
while (!iter.done()) {
(*iter).fIsAbandoned = true;
@ -28,7 +28,7 @@ GrGlyphCache::~GrGlyphCache() {
}
}
void GrGlyphCache::freeAll() {
void GrStrikeCache::freeAll() {
StrikeHash::Iter iter(&fCache);
while (!iter.done()) {
(*iter).fIsAbandoned = true;
@ -38,8 +38,8 @@ void GrGlyphCache::freeAll() {
fCache.rewind();
}
void GrGlyphCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) {
GrGlyphCache* glyphCache = reinterpret_cast<GrGlyphCache*>(ptr);
void GrStrikeCache::HandleEviction(GrDrawOpAtlas::AtlasID id, void* ptr) {
GrStrikeCache* glyphCache = reinterpret_cast<GrStrikeCache*>(ptr);
StrikeHash::Iter iter(&glyphCache->fCache);
for (; !iter.done(); ++iter) {
@ -193,7 +193,7 @@ void GrTextStrike::removeID(GrDrawOpAtlas::AtlasID id) {
GrDrawOpAtlas::ErrorCode GrTextStrike::addGlyphToAtlas(
GrResourceProvider* resourceProvider,
GrDeferredUploadTarget* target,
GrGlyphCache* glyphCache,
GrStrikeCache* glyphCache,
GrAtlasManager* fullAtlasManager,
GrGlyph* glyph,
SkStrike* cache,

View File

@ -5,8 +5,8 @@
* found in the LICENSE file.
*/
#ifndef GrAtlasGlyphCache_DEFINED
#define GrAtlasGlyphCache_DEFINED
#ifndef GrStrikeCache_DEFINED
#define GrStrikeCache_DEFINED
#include "GrDrawOpAtlas.h"
#include "GrGlyph.h"
@ -15,16 +15,16 @@
#include "SkStrike.h"
#include "SkTDynamicHash.h"
class GrGlyphCache;
class GrAtlasManager;
class GrGpu;
class GrStrikeCache;
/**
* The GrTextStrike 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 GrTextStrike may outlive the generating SkGlyphCache. However, it retains a copy
* of it's SkDescriptor as a key to access (or regenerate) the SkGlyphCache. GrTextStrikes are
* created by and owned by a GrGlyphCache.
* is indexed by a PackedID and SkStrike. The SkStrike is what actually creates the mask.
* The GrTextStrike may outlive the generating SkStrike. However, it retains a copy
* of it's SkDescriptor as a key to access (or regenerate) the SkStrike. GrTextStrikes are
* created by and owned by a GrStrikeCache.
*/
class GrTextStrike : public SkNVRefCnt<GrTextStrike> {
public:
@ -61,7 +61,7 @@ public:
// TODO we can handle some of these cases if we really want to, but the long term solution is to
// get the actual glyph image itself when we get the glyph metrics.
GrDrawOpAtlas::ErrorCode addGlyphToAtlas(GrResourceProvider*, GrDeferredUploadTarget*,
GrGlyphCache*, GrAtlasManager*, GrGlyph*,
GrStrikeCache*, GrAtlasManager*, GrGlyph*,
SkStrike*, GrMaskFormat expectedMaskFormat,
bool isScaledGlyph);
@ -94,17 +94,17 @@ private:
GrGlyph* generateGlyph(const SkGlyph&);
friend class GrGlyphCache;
friend class GrStrikeCache;
};
/**
* GrGlyphCache manages strikes which are indexed by a SkGlyphCache. These strikes can then be
* GrStrikeCache manages strikes which are indexed by a SkStrike. These strikes can then be
* used to generate individual Glyph Masks.
*/
class GrGlyphCache {
class GrStrikeCache {
public:
GrGlyphCache(const GrCaps* caps, size_t maxTextureBytes);
~GrGlyphCache();
GrStrikeCache(const GrCaps* caps, size_t maxTextureBytes);
~GrStrikeCache();
void setStrikeToPreserve(GrTextStrike* strike) { fPreserveStrike = strike; }
@ -141,4 +141,4 @@ private:
std::unique_ptr<const SkMasks> f565Masks;
};
#endif
#endif // GrStrikeCache_DEFINED

View File

@ -10,7 +10,7 @@
#include "GrColor.h"
#include "GrDrawOpAtlas.h"
#include "GrGlyphCache.h"
#include "GrStrikeCache.h"
#include "GrTextTarget.h"
#include "text/GrTextContext.h"
#include "SkDescriptor.h"
@ -55,7 +55,7 @@ public:
class VertexRegenerator;
void generateFromGlyphRunList(GrGlyphCache* glyphCache,
void generateFromGlyphRunList(GrStrikeCache* glyphCache,
const GrShaderCaps& shaderCaps,
const GrTextContext::Options& options,
const SkPaint& paint,
@ -571,7 +571,7 @@ public:
*/
VertexRegenerator(GrResourceProvider*, GrTextBlob*, int runIdx, int subRunIdx,
const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color,
GrDeferredUploadTarget*, GrGlyphCache*, GrAtlasManager*,
GrDeferredUploadTarget*, GrStrikeCache*, GrAtlasManager*,
SkExclusiveStrikePtr*);
struct Result {
@ -602,7 +602,7 @@ private:
const SkMatrix& fViewMatrix;
GrTextBlob* fBlob;
GrDeferredUploadTarget* fUploadTarget;
GrGlyphCache* fGlyphCache;
GrStrikeCache* fGlyphCache;
GrAtlasManager* fFullAtlasManager;
SkExclusiveStrikePtr* fLazyCache;
Run* fRun;

View File

@ -121,7 +121,7 @@ GrTextBlob::VertexRegenerator::VertexRegenerator(GrResourceProvider* resourcePro
const SkMatrix& viewMatrix, SkScalar x, SkScalar y,
GrColor color,
GrDeferredUploadTarget* uploadTarget,
GrGlyphCache* glyphCache,
GrStrikeCache* glyphCache,
GrAtlasManager* fullAtlasManager,
SkExclusiveStrikePtr* lazyCache)
: fResourceProvider(resourceProvider)
@ -137,7 +137,7 @@ GrTextBlob::VertexRegenerator::VertexRegenerator(GrResourceProvider* resourcePro
// Compute translation if any
fSubRun->computeTranslation(fViewMatrix, x, y, &fTransX, &fTransY);
// Because the GrGlyphCache may evict the strike a blob depends on using for
// Because the GrStrikeCache 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.

View File

@ -29,7 +29,7 @@
#include "ccpr/GrCoverageCountingPathRenderer.h"
#include "ccpr/GrCCPathCache.h"
#include "ops/GrMeshDrawOp.h"
#include "text/GrGlyphCache.h"
#include "text/GrStrikeCache.h"
#include "text/GrTextBlobCache.h"
#include <algorithm>