From 862405921bdbf599bac3bd829e9d6a81a4ee4d37 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 24 May 2018 16:12:31 -0400 Subject: [PATCH] Rename GrAtlasTextBlob -> GrTextBlob Change-Id: I61311b48f206890dfd1a20796d7d678cd05ef5a3 Reviewed-on: https://skia-review.googlesource.com/130140 Reviewed-by: Brian Salomon Commit-Queue: Herb Derby --- gn/gpu.gni | 10 ++-- src/atlastext/SkAtlasTextTarget.cpp | 4 +- src/gpu/ops/GrAtlasTextOp.cpp | 6 +-- src/gpu/ops/GrAtlasTextOp.h | 4 +- .../{GrAtlasTextBlob.cpp => GrTextBlob.cpp} | 46 ++++++++-------- .../text/{GrAtlasTextBlob.h => GrTextBlob.h} | 34 ++++++------ src/gpu/text/GrTextBlobCache.cpp | 4 +- src/gpu/text/GrTextBlobCache.h | 52 +++++++++---------- ...or.cpp => GrTextBlobVertexRegenerator.cpp} | 6 +-- src/gpu/text/GrTextContext.cpp | 44 ++++++++-------- src/gpu/text/GrTextContext.h | 36 ++++++------- src/gpu/text/GrTextUtils.h | 2 +- 12 files changed, 124 insertions(+), 124 deletions(-) rename src/gpu/text/{GrAtlasTextBlob.cpp => GrTextBlob.cpp} (92%) rename src/gpu/text/{GrAtlasTextBlob.h => GrTextBlob.h} (96%) rename src/gpu/text/{GrAtlasTextBlobVertexRegenerator.cpp => GrTextBlobVertexRegenerator.cpp} (99%) diff --git a/gn/gpu.gni b/gn/gpu.gni index d050df9ca9..14059fde75 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -407,19 +407,19 @@ skia_gpu_sources = [ # text "$_src/gpu/text/GrAtlasManager.cpp", "$_src/gpu/text/GrAtlasManager.h", - "$_src/gpu/text/GrAtlasTextBlob.cpp", - "$_src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp", - "$_src/gpu/text/GrAtlasTextBlob.h", - "$_src/gpu/text/GrTextContext.cpp", - "$_src/gpu/text/GrTextContext.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/GrTextBlob.cpp", + "$_src/gpu/text/GrTextBlob.h", "$_src/gpu/text/GrTextBlobCache.cpp", "$_src/gpu/text/GrTextBlobCache.h", + "$_src/gpu/text/GrTextContext.cpp", + "$_src/gpu/text/GrTextContext.h", + "$_src/gpu/text/GrTextBlobVertexRegenerator.cpp", "$_src/gpu/text/GrTextUtils.cpp", "$_src/gpu/text/GrTextUtils.h", diff --git a/src/atlastext/SkAtlasTextTarget.cpp b/src/atlastext/SkAtlasTextTarget.cpp index 5d46669d9c..09efc3e021 100644 --- a/src/atlastext/SkAtlasTextTarget.cpp +++ b/src/atlastext/SkAtlasTextTarget.cpp @@ -193,13 +193,13 @@ void GrAtlasTextOp::executeForTextTarget(SkAtlasTextTarget* target) { } for (int i = 0; i < fGeoCount; ++i) { - GrAtlasTextBlob::VertexRegenerator regenerator( + GrTextBlob::VertexRegenerator regenerator( resourceProvider, fGeoData[i].fBlob, fGeoData[i].fRun, fGeoData[i].fSubRun, fGeoData[i].fViewMatrix, fGeoData[i].fX, fGeoData[i].fY, fGeoData[i].fColor, &context, glyphCache, atlasManager, &autoGlyphCache); bool done = false; while (!done) { - GrAtlasTextBlob::VertexRegenerator::Result result; + GrTextBlob::VertexRegenerator::Result result; if (!regenerator.regenerate(&result)) { break; } diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index 2ec6f60686..82f4b54c10 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -254,7 +254,7 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) { flushInfo.fGlyphsToFlush = 0; size_t vertexStride = flushInfo.fGeometryProcessor->getVertexStride(); - SkASSERT(vertexStride == GrAtlasTextBlob::GetVertexStride(maskFormat, vmPerspective)); + SkASSERT(vertexStride == GrTextBlob::GetVertexStride(maskFormat, vmPerspective)); int glyphCount = this->numGlyphs(); const GrBuffer* vertexBuffer; @@ -275,13 +275,13 @@ void GrAtlasTextOp::onPrepareDraws(Target* target) { for (int i = 0; i < fGeoCount; i++) { const Geometry& args = fGeoData[i]; Blob* blob = args.fBlob; - GrAtlasTextBlob::VertexRegenerator regenerator( + GrTextBlob::VertexRegenerator regenerator( resourceProvider, blob, args.fRun, args.fSubRun, args.fViewMatrix, args.fX, args.fY, args.fColor, target->deferredUploadTarget(), glyphCache, atlasManager, &autoGlyphCache); bool done = false; while (!done) { - GrAtlasTextBlob::VertexRegenerator::Result result; + GrTextBlob::VertexRegenerator::Result result; if (!regenerator.regenerate(&result)) { break; } diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h index 836d305668..04f7bae39d 100644 --- a/src/gpu/ops/GrAtlasTextOp.h +++ b/src/gpu/ops/GrAtlasTextOp.h @@ -25,10 +25,10 @@ public: } } - static const int kVerticesPerGlyph = GrAtlasTextBlob::kVerticesPerGlyph; + static const int kVerticesPerGlyph = GrTextBlob::kVerticesPerGlyph; static const int kIndicesPerGlyph = 6; - typedef GrAtlasTextBlob Blob; + typedef GrTextBlob Blob; struct Geometry { SkMatrix fViewMatrix; SkIRect fClipRect; diff --git a/src/gpu/text/GrAtlasTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp similarity index 92% rename from src/gpu/text/GrAtlasTextBlob.cpp rename to src/gpu/text/GrTextBlob.cpp index f1c0f392a9..c3d06e81fd 100644 --- a/src/gpu/text/GrAtlasTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -5,7 +5,7 @@ * found in the LICENSE file. */ -#include "GrAtlasTextBlob.h" +#include "GrTextBlob.h" #include "GrBlurUtils.h" #include "GrClip.h" #include "GrContext.h" @@ -19,14 +19,14 @@ #include "SkTextToPathIter.h" #include "ops/GrAtlasTextOp.h" -sk_sp GrAtlasTextBlob::Make(int glyphCount, int runCount) { - // We allocate size for the GrAtlasTextBlob itself, plus size for the vertices array, +sk_sp GrTextBlob::Make(int glyphCount, int runCount) { + // We allocate size for the GrTextBlob itself, plus size for the vertices array, // and size for the glyphIds array. size_t verticesCount = glyphCount * kVerticesPerGlyph * kMaxVASize; - size_t size = sizeof(GrAtlasTextBlob) + + size_t size = sizeof(GrTextBlob) + verticesCount + glyphCount * sizeof(GrGlyph**) + - sizeof(GrAtlasTextBlob::Run) * runCount; + sizeof(GrTextBlob::Run) * runCount; void* allocation = ::operator new (size); @@ -34,28 +34,28 @@ sk_sp GrAtlasTextBlob::Make(int glyphCount, int runCount) { sk_bzero(allocation, size); } - sk_sp cacheBlob(new (allocation) GrAtlasTextBlob); + sk_sp cacheBlob(new (allocation) GrTextBlob); cacheBlob->fSize = size; // setup offsets for vertices / glyphs - cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast(cacheBlob.get()); + cacheBlob->fVertices = sizeof(GrTextBlob) + reinterpret_cast(cacheBlob.get()); cacheBlob->fGlyphs = reinterpret_cast(cacheBlob->fVertices + verticesCount); - cacheBlob->fRuns = reinterpret_cast(cacheBlob->fGlyphs + glyphCount); + cacheBlob->fRuns = reinterpret_cast(cacheBlob->fGlyphs + glyphCount); // Initialize runs for (int i = 0; i < runCount; i++) { - new (&cacheBlob->fRuns[i]) GrAtlasTextBlob::Run; + new (&cacheBlob->fRuns[i]) GrTextBlob::Run; } cacheBlob->fRunCount = runCount; return cacheBlob; } -SkExclusiveStrikePtr GrAtlasTextBlob::setupCache(int runIndex, +SkExclusiveStrikePtr GrTextBlob::setupCache(int runIndex, const SkSurfaceProps& props, SkScalerContextFlags scalerContextFlags, const SkPaint& skPaint, const SkMatrix* viewMatrix) { - GrAtlasTextBlob::Run* run = &fRuns[runIndex]; + GrTextBlob::Run* run = &fRuns[runIndex]; // if we have an override descriptor for the run, then we should use that SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDescriptor.get() : @@ -69,7 +69,7 @@ SkExclusiveStrikePtr GrAtlasTextBlob::setupCache(int runIndex, return SkStrikeCache::FindOrCreateStrikeExclusive(*desc->getDesc(), effects, *run->fTypeface); } -void GrAtlasTextBlob::appendGlyph(int runIndex, +void GrTextBlob::appendGlyph(int runIndex, const SkRect& positions, GrColor color, sk_sp strike, @@ -149,13 +149,13 @@ void GrAtlasTextBlob::appendGlyph(int runIndex, subRun->setNeedsTransform(!preTransformed); } -void GrAtlasTextBlob::appendPathGlyph(int runIndex, const SkPath& path, SkScalar x, SkScalar y, +void GrTextBlob::appendPathGlyph(int runIndex, const SkPath& path, SkScalar x, SkScalar y, SkScalar scale, bool preTransformed) { Run& run = fRuns[runIndex]; - run.fPathGlyphs.push_back(GrAtlasTextBlob::Run::PathGlyph(path, x, y, scale, preTransformed)); + run.fPathGlyphs.push_back(GrTextBlob::Run::PathGlyph(path, x, y, scale, preTransformed)); } -bool GrAtlasTextBlob::mustRegenerate(const GrTextUtils::Paint& paint, +bool GrTextBlob::mustRegenerate(const GrTextUtils::Paint& paint, const SkMaskFilterBase::BlurRec& blurRec, const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { // If we have LCD text then our canonical color will be set to transparent, in this case we have @@ -239,7 +239,7 @@ bool GrAtlasTextBlob::mustRegenerate(const GrTextUtils::Paint& paint, return false; } -inline std::unique_ptr GrAtlasTextBlob::makeOp( +inline std::unique_ptr GrTextBlob::makeOp( const Run::SubRunInfo& info, int glyphCount, uint16_t run, uint16_t subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const SkIRect& clipRect, const GrTextUtils::Paint& paint, const SkSurfaceProps& props, @@ -292,13 +292,13 @@ static void calculate_translation(bool applyVM, } } -void GrAtlasTextBlob::flush(GrTextUtils::Target* target, const SkSurfaceProps& props, +void GrTextBlob::flush(GrTextUtils::Target* target, const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, const GrTextUtils::Paint& paint, const GrClip& clip, const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x, SkScalar y) { - // GrAtlasTextBlob::makeOp only takes uint16_t values for run and subRun indices. + // GrTextBlob::makeOp only takes uint16_t values for run and subRun indices. // Encountering something larger than this is highly unlikely, so we'll just not draw it. int lastRun = SkTMin(fRunCount, (1 << 16)) - 1; GrTextUtils::RunPaint runPaint(&paint, nullptr); @@ -316,7 +316,7 @@ void GrAtlasTextBlob::flush(GrTextUtils::Target* target, const SkSurfaceProps& p continue; } for (int i = 0; i < run.fPathGlyphs.count(); i++) { - GrAtlasTextBlob::Run::PathGlyph& pathGlyph = run.fPathGlyphs[i]; + GrTextBlob::Run::PathGlyph& pathGlyph = run.fPathGlyphs[i]; calculate_translation(pathGlyph.fPreTransformed, viewMatrix, x, y, fInitialViewMatrix, fInitialX, fInitialY, &transX, &transY); const SkMatrix& ctm = pathGlyph.fPreTransformed ? SkMatrix::I() : viewMatrix; @@ -383,17 +383,17 @@ void GrAtlasTextBlob::flush(GrTextUtils::Target* target, const SkSurfaceProps& p } } -std::unique_ptr GrAtlasTextBlob::test_makeOp( +std::unique_ptr GrTextBlob::test_makeOp( int glyphCount, uint16_t run, uint16_t subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const GrTextUtils::Paint& paint, const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, GrTextUtils::Target* target) { - const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; + const GrTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; SkIRect emptyRect = SkIRect::MakeEmpty(); return this->makeOp(info, glyphCount, run, subRun, viewMatrix, x, y, emptyRect, paint, props, distanceAdjustTable, target); } -void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlob& r) { +void GrTextBlob::AssertEqual(const GrTextBlob& l, const GrTextBlob& r) { SkASSERT_RELEASE(l.fSize == r.fSize); SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma); @@ -476,7 +476,7 @@ void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo } } -void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMatrix, +void GrTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMatrix, SkScalar x, SkScalar y, SkScalar* transX, SkScalar* transY) { calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, diff --git a/src/gpu/text/GrAtlasTextBlob.h b/src/gpu/text/GrTextBlob.h similarity index 96% rename from src/gpu/text/GrAtlasTextBlob.h rename to src/gpu/text/GrTextBlob.h index 302a66d9d4..49615a92ed 100644 --- a/src/gpu/text/GrAtlasTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -5,8 +5,8 @@ * found in the LICENSE file. */ -#ifndef GrAtlasTextBlob_DEFINED -#define GrAtlasTextBlob_DEFINED +#ifndef GrTextBlob_DEFINED +#define GrTextBlob_DEFINED #include "GrColor.h" #include "GrDrawOpAtlas.h" @@ -36,26 +36,26 @@ class SkTextBlobRunIterator; #define CACHE_SANITY_CHECK 0 /* - * A GrAtlasTextBlob contains a fully processed SkTextBlob, suitable for nearly immediate drawing + * A GrTextBlob contains a fully processed SkTextBlob, suitable for nearly immediate drawing * on the GPU. These are initially created with valid positions and colors, but invalid - * texture coordinates. The GrAtlasTextBlob itself has a few Blob-wide properties, and also + * texture coordinates. The GrTextBlob itself has a few Blob-wide properties, and also * consists of a number of runs. Runs inside a blob are flushed individually so they can be * reordered. * - * The only thing(aside from a memcopy) required to flush a GrAtlasTextBlob is to ensure that + * The only thing(aside from a memcopy) required to flush a GrTextBlob is to ensure that * the GrAtlas will not evict anything the Blob needs. * * Note: This struct should really be named GrCachedAtasTextBlob, but that is too verbose. * * *WARNING* If you add new fields to this struct, then you may need to to update AssertEqual */ -class GrAtlasTextBlob : public SkNVRefCnt { +class GrTextBlob : public SkNVRefCnt { public: - SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrAtlasTextBlob); + SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrTextBlob); class VertexRegenerator; - static sk_sp Make(int glyphCount, int runCount); + static sk_sp Make(int glyphCount, int runCount); /** * We currently force regeneration of a blob if old or new matrix differ in having perspective. @@ -83,7 +83,7 @@ public: } }; - void setupKey(const GrAtlasTextBlob::Key& key, + void setupKey(const GrTextBlob::Key& key, const SkMaskFilterBase::BlurRec& blurRec, const SkPaint& paint) { fKey = key; @@ -97,7 +97,7 @@ public: } } - static const Key& GetKey(const GrAtlasTextBlob& blob) { + static const Key& GetKey(const GrTextBlob& blob) { return blob.fKey; } @@ -251,7 +251,7 @@ public: static const size_t kMaxVASize = kGrayTextDFPerspectiveVASize; static const int kVerticesPerGlyph = 4; - static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); + static void AssertEqual(const GrTextBlob&, const GrTextBlob&); // The color here is the GrPaint color, and it is used to determine whether we // have to regenerate LCD text blobs. @@ -270,7 +270,7 @@ public: size_t size() const { return fSize; } - ~GrAtlasTextBlob() { + ~GrTextBlob() { for (int i = 0; i < fRunCount; i++) { fRuns[i].~Run(); } @@ -285,7 +285,7 @@ public: GrTextUtils::Target*); private: - GrAtlasTextBlob() + GrTextBlob() : fMaxMinScale(-SK_ScalarMax) , fMinMaxScale(SK_ScalarMax) , fTextType(0) {} @@ -562,14 +562,14 @@ private: * free up atlas space. Thus, this generator is stateful and should be invoked in a loop until the * entire sub run has been completed. */ -class GrAtlasTextBlob::VertexRegenerator { +class GrTextBlob::VertexRegenerator { public: /** * Consecutive VertexRegenerators often use the same SkGlyphCache. If the same instance of * SkAutoGlyphCache is reused then it can save the cost of multiple detach/attach operations of * SkGlyphCache. */ - VertexRegenerator(GrResourceProvider*, GrAtlasTextBlob*, int runIdx, int subRunIdx, + VertexRegenerator(GrResourceProvider*, GrTextBlob*, int runIdx, int subRunIdx, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color, GrDeferredUploadTarget*, GrGlyphCache*, GrAtlasManager*, SkExclusiveStrikePtr*); @@ -601,7 +601,7 @@ private: GrResourceProvider* fResourceProvider; const SkMatrix& fViewMatrix; - GrAtlasTextBlob* fBlob; + GrTextBlob* fBlob; GrDeferredUploadTarget* fUploadTarget; GrGlyphCache* fGlyphCache; GrAtlasManager* fFullAtlasManager; @@ -617,4 +617,4 @@ private: bool fBrokenRun = false; }; -#endif +#endif // GrTextBlob_DEFINED diff --git a/src/gpu/text/GrTextBlobCache.cpp b/src/gpu/text/GrTextBlobCache.cpp index 5b951462f0..71d9052ade 100644 --- a/src/gpu/text/GrTextBlobCache.cpp +++ b/src/gpu/text/GrTextBlobCache.cpp @@ -55,7 +55,7 @@ void GrTextBlobCache::purgeStaleBlobs() { } } -void GrTextBlobCache::checkPurge(GrAtlasTextBlob* blob) { +void GrTextBlobCache::checkPurge(GrTextBlob* blob) { // First, purge all stale blob IDs. this->purgeStaleBlobs(); @@ -63,7 +63,7 @@ void GrTextBlobCache::checkPurge(GrAtlasTextBlob* blob) { if (fCurrentSize > fSizeBudget) { BitmapBlobList::Iter iter; iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart); - GrAtlasTextBlob* lruBlob = nullptr; + GrTextBlob* lruBlob = nullptr; while (fCurrentSize > fSizeBudget && (lruBlob = iter.get()) && lruBlob != blob) { // Backup the iterator before removing and unrefing the blob iter.prev(); diff --git a/src/gpu/text/GrTextBlobCache.h b/src/gpu/text/GrTextBlobCache.h index c6b5c70614..b41d401aee 100644 --- a/src/gpu/text/GrTextBlobCache.h +++ b/src/gpu/text/GrTextBlobCache.h @@ -34,35 +34,35 @@ public: ~GrTextBlobCache(); // creates an uncached blob - sk_sp makeBlob(int glyphCount, int runCount) { - return GrAtlasTextBlob::Make(glyphCount, runCount); + sk_sp makeBlob(int glyphCount, int runCount) { + return GrTextBlob::Make(glyphCount, runCount); } - sk_sp makeBlob(const SkTextBlob* blob) { + sk_sp makeBlob(const SkTextBlob* blob) { int glyphCount = 0; int runCount = 0; BlobGlyphCount(&glyphCount, &runCount, blob); - return GrAtlasTextBlob::Make(glyphCount, runCount); + return GrTextBlob::Make(glyphCount, runCount); } - sk_sp makeCachedBlob(const SkTextBlob* blob, - const GrAtlasTextBlob::Key& key, + sk_sp makeCachedBlob(const SkTextBlob* blob, + const GrTextBlob::Key& key, const SkMaskFilterBase::BlurRec& blurRec, const SkPaint& paint) { - sk_sp cacheBlob(this->makeBlob(blob)); + sk_sp cacheBlob(this->makeBlob(blob)); cacheBlob->setupKey(key, blurRec, paint); this->add(cacheBlob); blob->notifyAddedToCache(fUniqueID); return cacheBlob; } - sk_sp find(const GrAtlasTextBlob::Key& key) const { + sk_sp find(const GrTextBlob::Key& key) const { const auto* idEntry = fBlobIDCache.find(key.fUniqueID); return idEntry ? idEntry->find(key) : nullptr; } - void remove(GrAtlasTextBlob* blob) { - auto id = GrAtlasTextBlob::GetKey(*blob).fUniqueID; + void remove(GrTextBlob* blob) { + auto id = GrTextBlob::GetKey(*blob).fUniqueID; auto* idEntry = fBlobIDCache.find(id); SkASSERT(idEntry); @@ -74,7 +74,7 @@ public: } } - void makeMRU(GrAtlasTextBlob* blob) { + void makeMRU(GrTextBlob* blob) { if (fBlobList.head() == blob) { return; } @@ -107,7 +107,7 @@ public: void purgeStaleBlobs(); private: - using BitmapBlobList = SkTInternalLList; + using BitmapBlobList = SkTInternalLList; struct BlobIDCacheEntry { BlobIDCacheEntry() : fID(SK_InvalidGenID) {} @@ -117,32 +117,32 @@ private: return entry.fID; } - void addBlob(sk_sp blob) { + void addBlob(sk_sp blob) { SkASSERT(blob); - SkASSERT(GrAtlasTextBlob::GetKey(*blob).fUniqueID == fID); - SkASSERT(!this->find(GrAtlasTextBlob::GetKey(*blob))); + SkASSERT(GrTextBlob::GetKey(*blob).fUniqueID == fID); + SkASSERT(!this->find(GrTextBlob::GetKey(*blob))); fBlobs.emplace_back(std::move(blob)); } - void removeBlob(GrAtlasTextBlob* blob) { + void removeBlob(GrTextBlob* blob) { SkASSERT(blob); - SkASSERT(GrAtlasTextBlob::GetKey(*blob).fUniqueID == fID); + SkASSERT(GrTextBlob::GetKey(*blob).fUniqueID == fID); - auto index = this->findBlobIndex(GrAtlasTextBlob::GetKey(*blob)); + auto index = this->findBlobIndex(GrTextBlob::GetKey(*blob)); SkASSERT(index >= 0); fBlobs.removeShuffle(index); } - sk_sp find(const GrAtlasTextBlob::Key& key) const { + sk_sp find(const GrTextBlob::Key& key) const { auto index = this->findBlobIndex(key); return index < 0 ? nullptr : fBlobs[index]; } - int findBlobIndex(const GrAtlasTextBlob::Key& key) const{ + int findBlobIndex(const GrTextBlob::Key& key) const{ for (int i = 0; i < fBlobs.count(); ++i) { - if (GrAtlasTextBlob::GetKey(*fBlobs[i]) == key) { + if (GrTextBlob::GetKey(*fBlobs[i]) == key) { return i; } } @@ -152,18 +152,18 @@ private: uint32_t fID; // Current clients don't generate multiple GrAtlasTextBlobs per SkTextBlob, so an array w/ // linear search is acceptable. If usage changes, we should re-evaluate this structure. - SkSTArray<1, sk_sp, true> fBlobs; + SkSTArray<1, sk_sp, true> fBlobs; }; - void add(sk_sp blob) { - auto id = GrAtlasTextBlob::GetKey(*blob).fUniqueID; + void add(sk_sp blob) { + auto id = GrTextBlob::GetKey(*blob).fUniqueID; auto* idEntry = fBlobIDCache.find(id); if (!idEntry) { idEntry = fBlobIDCache.set(id, BlobIDCacheEntry(id)); } // Safe to retain a raw ptr temporarily here, because the cache will hold a ref. - GrAtlasTextBlob* rawBlobPtr = blob.get(); + GrTextBlob* rawBlobPtr = blob.get(); fBlobList.addToHead(rawBlobPtr); fCurrentSize += blob->size(); idEntry->addBlob(std::move(blob)); @@ -171,7 +171,7 @@ private: this->checkPurge(rawBlobPtr); } - void checkPurge(GrAtlasTextBlob* blob = nullptr); + void checkPurge(GrTextBlob* blob = nullptr); static const int kMinGrowthSize = 1 << 16; static const int kDefaultBudget = 1 << 22; diff --git a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp b/src/gpu/text/GrTextBlobVertexRegenerator.cpp similarity index 99% rename from src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp rename to src/gpu/text/GrTextBlobVertexRegenerator.cpp index a0a5f4d9e6..3a1f0aea80 100644 --- a/src/gpu/text/GrAtlasTextBlobVertexRegenerator.cpp +++ b/src/gpu/text/GrTextBlobVertexRegenerator.cpp @@ -6,13 +6,13 @@ */ #include "GrAtlasManager.h" -#include "GrAtlasTextBlob.h" +#include "GrTextBlob.h" #include "GrTextUtils.h" #include "SkDistanceFieldGen.h" #include "SkGlyphCache.h" #include "ops/GrAtlasTextOp.h" -using Regenerator = GrAtlasTextBlob::VertexRegenerator; +using Regenerator = GrTextBlob::VertexRegenerator; enum RegenMask { kNoRegen = 0x0, @@ -191,7 +191,7 @@ inline void regen_vertices(char* vertex, const GrGlyph* glyph, size_t vertexStri } } -Regenerator::VertexRegenerator(GrResourceProvider* resourceProvider, GrAtlasTextBlob* blob, +Regenerator::VertexRegenerator(GrResourceProvider* resourceProvider, GrTextBlob* blob, int runIdx, int subRunIdx, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, GrColor color, GrDeferredUploadTarget* uploadTarget, GrGlyphCache* glyphCache, diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp index dfc6898929..f662fa9c12 100644 --- a/src/gpu/text/GrTextContext.cpp +++ b/src/gpu/text/GrTextContext.cpp @@ -104,9 +104,9 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target return; } - sk_sp cacheBlob; + sk_sp cacheBlob; SkMaskFilterBase::BlurRec blurRec; - GrAtlasTextBlob::Key key; + GrTextBlob::Key key; // It might be worth caching these things, but its not clear at this time // TODO for animated mask filters, this will fill up our cache. We need a safeguard here const SkMaskFilter* mf = skPaint.getMaskFilter(); @@ -158,12 +158,12 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target int glyphCount = 0; int runCount = 0; GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob); - sk_sp sanityBlob(textBlobCache->makeBlob(glyphCount, runCount)); + sk_sp sanityBlob(textBlobCache->makeBlob(glyphCount, runCount)); sanityBlob->setupKey(key, blurRec, skPaint); this->regenerateTextBlob( sanityBlob.get(), glyphCache, *context->contextPriv().caps()->shaderCaps(), paint, scalerContextFlags, viewMatrix, props, blob, x, y, drawFilter); - GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob); + GrTextBlob::AssertEqual(*sanityBlob, *cacheBlob); } } } else { @@ -181,7 +181,7 @@ void GrTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target clip, viewMatrix, clipBounds, x, y); } -void GrTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob, +void GrTextContext::regenerateTextBlob(GrTextBlob* cacheBlob, GrGlyphCache* glyphCache, const GrShaderCaps& shaderCaps, const GrTextUtils::Paint& paint, @@ -251,7 +251,7 @@ void GrTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob, } } -inline sk_sp +inline sk_sp GrTextContext::makeDrawTextBlob(GrTextBlobCache* blobCache, GrGlyphCache* glyphCache, const GrShaderCaps& shaderCaps, @@ -265,7 +265,7 @@ GrTextContext::makeDrawTextBlob(GrTextBlobCache* blobCache, if (!glyphCount) { return nullptr; } - sk_sp blob = blobCache->makeBlob(glyphCount, 1); + sk_sp blob = blobCache->makeBlob(glyphCount, 1); blob->initThrowawayBlob(viewMatrix, x, y); blob->setRunPaintFlags(0, paint.skPaint().getFlags()); @@ -280,7 +280,7 @@ GrTextContext::makeDrawTextBlob(GrTextBlobCache* blobCache, return blob; } -inline sk_sp +inline sk_sp GrTextContext::makeDrawPosTextBlob(GrTextBlobCache* blobCache, GrGlyphCache* glyphCache, const GrShaderCaps& shaderCaps, @@ -296,7 +296,7 @@ GrTextContext::makeDrawPosTextBlob(GrTextBlobCache* blobCache, return nullptr; } - sk_sp blob = blobCache->makeBlob(glyphCount, 1); + sk_sp blob = blobCache->makeBlob(glyphCount, 1); blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y()); blob->setRunPaintFlags(0, paint.skPaint().getFlags()); @@ -324,7 +324,7 @@ void GrTextContext::drawText(GrContext* context, GrTextUtils::Target* target, auto textBlobCache = context->contextPriv().getTextBlobCache(); GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo()); - sk_sp blob(this->makeDrawTextBlob( + sk_sp blob(this->makeDrawTextBlob( textBlobCache, glyphCache, *context->contextPriv().caps()->shaderCaps(), paint, ComputeScalerContextFlags(target->colorSpaceInfo()), viewMatrix, props, text, byteLength, x, y)); @@ -348,7 +348,7 @@ void GrTextContext::drawPosText(GrContext* context, GrTextUtils::Target* target, auto glyphCache = context->contextPriv().getGlyphCache(); auto textBlobCache = context->contextPriv().getTextBlobCache(); - sk_sp blob(this->makeDrawPosTextBlob( + sk_sp blob(this->makeDrawPosTextBlob( textBlobCache, glyphCache, *context->contextPriv().caps()->shaderCaps(), paint, ComputeScalerContextFlags(target->colorSpaceInfo()), viewMatrix, props, text, byteLength, pos, scalarsPerPosition, offset)); @@ -358,7 +358,7 @@ void GrTextContext::drawPosText(GrContext* context, GrTextUtils::Target* target, } } -void GrTextContext::DrawBmpText(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::DrawBmpText(GrTextBlob* blob, int runIndex, GrGlyphCache* glyphCache, const SkSurfaceProps& props, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, @@ -394,7 +394,7 @@ void GrTextContext::DrawBmpText(GrAtlasTextBlob* blob, int runIndex, }); } -void GrTextContext::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::DrawBmpPosText(GrTextBlob* blob, int runIndex, GrGlyphCache* glyphCache, const SkSurfaceProps& props, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, @@ -432,7 +432,7 @@ void GrTextContext::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex, }); } -void GrTextContext::DrawBmpTextAsPaths(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::DrawBmpTextAsPaths(GrTextBlob* blob, int runIndex, GrGlyphCache* glyphCache, const SkSurfaceProps& props, const GrTextUtils::Paint& origPaint, @@ -469,7 +469,7 @@ void GrTextContext::DrawBmpTextAsPaths(GrAtlasTextBlob* blob, int runIndex, fallbackTextHelper.drawText(blob, runIndex, glyphCache, props, origPaint, scalerContextFlags); } -void GrTextContext::DrawBmpPosTextAsPaths(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::DrawBmpPosTextAsPaths(GrTextBlob* blob, int runIndex, GrGlyphCache* glyphCache, const SkSurfaceProps& props, const GrTextUtils::Paint& origPaint, @@ -524,7 +524,7 @@ void GrTextContext::DrawBmpPosTextAsPaths(GrAtlasTextBlob* blob, int runIndex, fallbackTextHelper.drawText(blob, runIndex, glyphCache, props, origPaint, scalerContextFlags); } -void GrTextContext::BmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::BmpAppendGlyph(GrTextBlob* blob, int runIndex, GrGlyphCache* grGlyphCache, sk_sp* strike, const SkGlyph& skGlyph, SkScalar sx, SkScalar sy, @@ -608,7 +608,7 @@ bool GrTextContext::CanDrawAsDistanceFields(const SkPaint& skPaint, const SkMatr return true; } -void GrTextContext::InitDistanceFieldPaint(GrAtlasTextBlob* blob, +void GrTextContext::InitDistanceFieldPaint(GrTextBlob* blob, SkPaint* skPaint, const SkMatrix& viewMatrix, const Options& options, @@ -678,7 +678,7 @@ void GrTextContext::InitDistanceFieldPaint(GrAtlasTextBlob* blob, *flags = SkScalerContextFlags::kNone; } -void GrTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::drawDFText(GrTextBlob* blob, int runIndex, GrGlyphCache* glyphCache, const SkSurfaceProps& props, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, @@ -746,7 +746,7 @@ void GrTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex, viewMatrix, text, byteLength, positions.begin(), 2, offset); } -void GrTextContext::drawDFPosText(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::drawDFPosText(GrTextBlob* blob, int runIndex, GrGlyphCache* glyphCache, const SkSurfaceProps& props, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, @@ -810,7 +810,7 @@ void GrTextContext::drawDFPosText(GrAtlasTextBlob* blob, int runIndex, } // TODO: merge with BmpAppendGlyph -void GrTextContext::DfAppendGlyph(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::DfAppendGlyph(GrTextBlob* blob, int runIndex, GrGlyphCache* grGlyphCache, sk_sp* strike, const SkGlyph& skGlyph, SkScalar sx, SkScalar sy, GrColor color, SkGlyphCache* skGlyphCache, @@ -868,7 +868,7 @@ void GrTextContext::FallbackTextHelper::appendText(const SkGlyph& glyph, int cou *fFallbackPos.append() = glyphPos; } -void GrTextContext::FallbackTextHelper::drawText(GrAtlasTextBlob* blob, int runIndex, +void GrTextContext::FallbackTextHelper::drawText(GrTextBlob* blob, int runIndex, GrGlyphCache* glyphCache, const SkSurfaceProps& props, const GrTextUtils::Paint& paint, @@ -936,7 +936,7 @@ std::unique_ptr GrTextContext::createOp_TestingOnly(GrContext* context // right now we don't handle textblobs, nor do we handle drawPosText. Since we only intend to // test the text op with this unit test, that is okay. - sk_sp blob(textContext->makeDrawTextBlob( + sk_sp blob(textContext->makeDrawTextBlob( context->contextPriv().getTextBlobCache(), glyphCache, *context->contextPriv().caps()->shaderCaps(), utilsPaint, GrTextContext::kTextBlobOpScalerContextFlags, viewMatrix, surfaceProps, text, diff --git a/src/gpu/text/GrTextContext.h b/src/gpu/text/GrTextContext.h index b5bb22f3d5..3dab70ba9b 100644 --- a/src/gpu/text/GrTextContext.h +++ b/src/gpu/text/GrTextContext.h @@ -5,10 +5,10 @@ * found in the LICENSE file. */ -#ifndef GrAtlasTextContext_DEFINED -#define GrAtlasTextContext_DEFINED +#ifndef GrTextContext_DEFINED +#define GrTextContext_DEFINED -#include "GrAtlasTextBlob.h" +#include "GrTextBlob.h" #include "GrDistanceFieldAdjustTable.h" #include "GrGeometryProcessor.h" #include "GrTextUtils.h" @@ -65,7 +65,7 @@ public: const SkSurfaceProps& props, bool contextSupportsDistanceFieldText, const Options& options); - static void InitDistanceFieldPaint(GrAtlasTextBlob* blob, + static void InitDistanceFieldPaint(GrTextBlob* blob, SkPaint* skPaint, const SkMatrix& viewMatrix, const Options& options, @@ -91,7 +91,7 @@ private: } void appendText(const SkGlyph& glyph, int count, const char* text, SkPoint glyphPos); - void drawText(GrAtlasTextBlob* blob, int runIndex, GrGlyphCache*, const SkSurfaceProps&, + void drawText(GrTextBlob* blob, int runIndex, GrGlyphCache*, const SkSurfaceProps&, const GrTextUtils::Paint&, SkScalerContextFlags); private: @@ -111,7 +111,7 @@ private: static SkColor ComputeCanonicalColor(const SkPaint&, bool lcd); // Determines if we need to use fake gamma (and contrast boost): static SkScalerContextFlags ComputeScalerContextFlags(const GrColorSpaceInfo&); - void regenerateTextBlob(GrAtlasTextBlob* bmp, + void regenerateTextBlob(GrTextBlob* bmp, GrGlyphCache*, const GrShaderCaps&, const GrTextUtils::Paint&, @@ -123,7 +123,7 @@ private: static bool HasLCD(const SkTextBlob*); - sk_sp makeDrawTextBlob(GrTextBlobCache*, GrGlyphCache*, + sk_sp makeDrawTextBlob(GrTextBlobCache*, GrGlyphCache*, const GrShaderCaps&, const GrTextUtils::Paint&, SkScalerContextFlags scalerContextFlags, @@ -132,7 +132,7 @@ private: const char text[], size_t byteLength, SkScalar x, SkScalar y) const; - sk_sp makeDrawPosTextBlob(GrTextBlobCache*, GrGlyphCache*, + sk_sp makeDrawPosTextBlob(GrTextBlobCache*, GrGlyphCache*, const GrShaderCaps&, const GrTextUtils::Paint&, SkScalerContextFlags scalerContextFlags, @@ -143,25 +143,25 @@ private: int scalarsPerPosition, const SkPoint& offset) const; - // Functions for appending BMP text to GrAtlasTextBlob - static void DrawBmpText(GrAtlasTextBlob*, int runIndex, GrGlyphCache*, + // Functions for appending BMP text to GrTextBlob + static void DrawBmpText(GrTextBlob*, int runIndex, GrGlyphCache*, const SkSurfaceProps&, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y); - static void DrawBmpPosText(GrAtlasTextBlob*, int runIndex, GrGlyphCache*, + static void DrawBmpPosText(GrTextBlob*, int runIndex, GrGlyphCache*, const SkSurfaceProps&, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, const char text[], size_t byteLength, const SkScalar pos[], int scalarsPerPosition, const SkPoint& offset); - static void DrawBmpTextAsPaths(GrAtlasTextBlob*, int runIndex, GrGlyphCache*, + static void DrawBmpTextAsPaths(GrTextBlob*, int runIndex, GrGlyphCache*, const SkSurfaceProps&, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y); - static void DrawBmpPosTextAsPaths(GrAtlasTextBlob*, int runIndex, GrGlyphCache*, + static void DrawBmpPosTextAsPaths(GrTextBlob*, int runIndex, GrGlyphCache*, const SkSurfaceProps&, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, @@ -170,23 +170,23 @@ private: const SkPoint& offset); // functions for appending distance field text - void drawDFText(GrAtlasTextBlob* blob, int runIndex, GrGlyphCache*, const SkSurfaceProps&, + void drawDFText(GrTextBlob* blob, int runIndex, GrGlyphCache*, const SkSurfaceProps&, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, const char text[], size_t byteLength, SkScalar x, SkScalar y) const; - void drawDFPosText(GrAtlasTextBlob* blob, int runIndex, GrGlyphCache*, + void drawDFPosText(GrTextBlob* blob, int runIndex, GrGlyphCache*, const SkSurfaceProps&, const GrTextUtils::Paint& paint, SkScalerContextFlags scalerContextFlags, const SkMatrix& viewMatrix, const char text[], size_t byteLength, const SkScalar pos[], int scalarsPerPosition, const SkPoint& offset) const; - static void BmpAppendGlyph(GrAtlasTextBlob*, int runIndex, GrGlyphCache*, + static void BmpAppendGlyph(GrTextBlob*, int runIndex, GrGlyphCache*, sk_sp*, const SkGlyph&, SkScalar sx, SkScalar sy, GrColor color, SkGlyphCache*, SkScalar textRatio, bool needsXform); - static void DfAppendGlyph(GrAtlasTextBlob*, int runIndex, GrGlyphCache*, + static void DfAppendGlyph(GrTextBlob*, int runIndex, GrGlyphCache*, sk_sp*, const SkGlyph&, SkScalar sx, SkScalar sy, GrColor color, SkGlyphCache* cache, SkScalar textRatio); @@ -203,4 +203,4 @@ private: #endif }; -#endif +#endif // GrTextContext_DEFINED diff --git a/src/gpu/text/GrTextUtils.h b/src/gpu/text/GrTextUtils.h index 8b07f1c245..3a0ad0ac71 100644 --- a/src/gpu/text/GrTextUtils.h +++ b/src/gpu/text/GrTextUtils.h @@ -16,7 +16,7 @@ #include "SkTextToPathIter.h" #include "SkTLazy.h" -class GrAtlasTextBlob; +class GrTextBlob; class GrAtlasTextOp; class GrTextStrike; class GrClip;