From 36a54c1b1af0e62fb8cf53f177214b11ca5460d1 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Thu, 6 Jun 2019 10:50:56 -0400 Subject: [PATCH] Rename SkStrikeSpecStorage -> SkStrikeSpec SkStrikeSpecStorage was a temporary name until all uses of SkStrikeSpec were cleaned up. Do the final rename. Change-Id: Iaba987ecdfe46ca9eee8d530d5095840cdca300d Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219209 Reviewed-by: Herb Derby Reviewed-by: Mike Klein Reviewed-by: Ben Wagner Commit-Queue: Herb Derby --- bench/PathTextBench.cpp | 2 +- bench/SkGlyphCacheBench.cpp | 2 +- include/core/SkFont.h | 2 +- samplecode/SamplePathText.cpp | 2 +- src/core/SkFont.cpp | 14 ++--- src/core/SkGlyphRun.cpp | 2 +- src/core/SkGlyphRunPainter.cpp | 38 ++++++------- src/core/SkGlyphRunPainter.h | 12 ++-- src/core/SkStrikeSpec.cpp | 59 ++++++++++---------- src/core/SkStrikeSpec.h | 17 +++--- src/core/SkTextBlob.cpp | 2 +- src/gpu/text/GrTextBlob.cpp | 2 +- src/gpu/text/GrTextBlob.h | 26 ++++----- src/gpu/text/GrTextBlobVertexRegenerator.cpp | 2 +- src/pdf/SkPDFDevice.cpp | 2 +- src/pdf/SkPDFFont.cpp | 4 +- src/pdf/SkPDFType1Font.cpp | 2 +- tests/SkRemoteGlyphCacheTest.cpp | 4 +- 18 files changed, 95 insertions(+), 99 deletions(-) diff --git a/bench/PathTextBench.cpp b/bench/PathTextBench.cpp index 6c914858e9..3554ff8031 100644 --- a/bench/PathTextBench.cpp +++ b/bench/PathTextBench.cpp @@ -47,7 +47,7 @@ private: void onDelayedSetup() override { SkFont defaultFont; - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(defaultFont); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(defaultFont); auto cache = strikeSpec.findOrCreateExclusiveStrike(); for (int i = 0; i < kNumGlyphs; ++i) { SkPackedGlyphID id(defaultFont.unicharToGlyph(kGlyphs[i])); diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp index c754685b2a..66b3a668a4 100644 --- a/bench/SkGlyphCacheBench.cpp +++ b/bench/SkGlyphCacheBench.cpp @@ -21,7 +21,7 @@ static void do_font_stuff(SkFont* font) { SkPaint defaultPaint; for (SkScalar i = 8; i < 64; i++) { font->setSize(i); - auto strikeSpec = SkStrikeSpecStorage::MakeMask( + auto strikeSpec = SkStrikeSpec::MakeMask( *font, defaultPaint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), SkScalerContextFlags::kNone, SkMatrix::I()); auto cache = strikeSpec.findOrCreateExclusiveStrike(); diff --git a/include/core/SkFont.h b/include/core/SkFont.h index 211c8e646d..8f32363cb9 100644 --- a/include/core/SkFont.h +++ b/include/core/SkFont.h @@ -512,7 +512,7 @@ private: friend class SkFontPriv; friend class SkGlyphRunListPainter; friend class SkTextBlobCacheDiffCanvas; - friend class SkStrikeSpecStorage; + friend class SkStrikeSpec; }; #endif diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp index e350f84412..1d96d1b096 100644 --- a/samplecode/SamplePathText.cpp +++ b/samplecode/SamplePathText.cpp @@ -34,7 +34,7 @@ public: void onOnceBeforeDraw() final { SkFont defaultFont; - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(defaultFont); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(defaultFont); auto cache = strikeSpec.findOrCreateExclusiveStrike(); SkPath glyphPaths[52]; for (int i = 0; i < 52; ++i) { diff --git a/src/core/SkFont.cpp b/src/core/SkFont.cpp index c84bca76a8..cee35223fd 100644 --- a/src/core/SkFont.cpp +++ b/src/core/SkFont.cpp @@ -231,7 +231,7 @@ using SmallPointsArray = SkAutoSTArray; SkScalar SkFont::measureText(const void* text, size_t length, SkTextEncoding encoding, SkRect* bounds, const SkPaint* paint) const { - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(*this, paint); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this, paint); SkAutoToGlyphs atg(*this, text, length, encoding); const int count = atg.count(); @@ -293,7 +293,7 @@ void VisitGlyphs(const SkFont& origFont, const SkPaint* paint, const SkGlyphID g return; } - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(origFont, paint); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(origFont, paint); auto cache = strikeSpec.findOrCreateExclusiveStrike(); handler(cache.get(), glyphs, count, strikeSpec.strikeToSourceRatio()); @@ -314,7 +314,7 @@ void SkFont::getWidthsBounds(const SkGlyphID glyphs[], int count, SkScalar width } }); } else if (widths) { - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(*this, paint); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this, paint); auto cache = strikeSpec.findOrCreateExclusiveStrike(); SmallPointsArray advances{count}; cache->getAdvances(SkSpan{glyphs, SkTo(count)}, advances.get()); @@ -326,7 +326,7 @@ void SkFont::getWidthsBounds(const SkGlyphID glyphs[], int count, SkScalar width void SkFont::getPos(const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint origin) const { - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(*this); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this); auto cache = strikeSpec.findOrCreateExclusiveStrike(); SmallPointsArray advances{count}; cache->getAdvances(SkSpan{glyphs, SkTo(count)}, advances.get()); @@ -340,7 +340,7 @@ void SkFont::getPos(const SkGlyphID glyphs[], int count, SkPoint pos[], SkPoint void SkFont::getXPos(const SkGlyphID glyphs[], int count, SkScalar xpos[], SkScalar origin) const { - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(*this); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this); auto cache = strikeSpec.findOrCreateExclusiveStrike(); SmallPointsArray advances{count}; cache->getAdvances(SkSpan{glyphs, SkTo(count)}, advances.get()); @@ -357,7 +357,7 @@ void SkFont::getPaths(const SkGlyphID glyphs[], int count, SkScalar scale = font.setupForAsPaths(nullptr); const SkMatrix mx = SkMatrix::MakeScale(scale, scale); - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(font); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(font); auto exclusive = strikeSpec.findOrCreateExclusiveStrike(); auto cache = exclusive.get(); @@ -384,7 +384,7 @@ bool SkFont::getPath(SkGlyphID glyphID, SkPath* path) const { SkScalar SkFont::getMetrics(SkFontMetrics* metrics) const { - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(*this, nullptr); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(*this, nullptr); SkFontMetrics storage; if (nullptr == metrics) { diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp index b8541d0a90..3941cba368 100644 --- a/src/core/SkGlyphRun.cpp +++ b/src/core/SkGlyphRun.cpp @@ -310,7 +310,7 @@ void SkGlyphRunBuilder::simplifyDrawText( if (!glyphIDs.empty()) { fScratchAdvances.resize(runSize); { - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(font); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(font); auto cache = strikeSpec.findOrCreateExclusiveStrike(); cache->getAdvances(glyphIDs, fScratchAdvances.data()); } diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp index 2f33a3ce21..061bc1751d 100644 --- a/src/core/SkGlyphRunPainter.cpp +++ b/src/core/SkGlyphRunPainter.cpp @@ -142,11 +142,11 @@ void SkGlyphRunListPainter::drawForBitmapDevice( const SkFont& runFont = glyphRun.font(); auto runSize = glyphRun.runSize(); - if (SkStrikeSpecStorage::ShouldDrawAsPath(runPaint, runFont, deviceMatrix)) { + if (SkStrikeSpec::ShouldDrawAsPath(runPaint, runFont, deviceMatrix)) { SkMatrix::MakeTrans(origin.x(), origin.y()).mapPoints( fPositions, glyphRun.positions().data(), runSize); - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakePath( + SkStrikeSpec strikeSpec = SkStrikeSpec::MakePath( runFont, runPaint, props, fScalerContextFlags); SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); @@ -190,9 +190,8 @@ void SkGlyphRunListPainter::drawForBitmapDevice( SkSpan{pathsAndPositions.begin(), pathsAndPositions.size()}, strikeSpec.strikeToSourceRatio(), pathPaint); } else { - SkStrikeSpecStorage strikeSpec = - SkStrikeSpecStorage::MakeMask(runFont, runPaint, - props, fScalerContextFlags, deviceMatrix); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask( + runFont, runPaint, props, fScalerContextFlags, deviceMatrix); SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); @@ -284,9 +283,8 @@ void SkGlyphRunListPainter::processARGBFallback(SkScalar maxSourceGlyphDimension point.fY = SkScalarFloorToScalar(point.fY); } - SkStrikeSpecStorage strikeSpec = - SkStrikeSpecStorage::MakeMask(runFont, runPaint, - fDeviceProps, fScalerContextFlags, viewMatrix); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask( + runFont, runPaint, fDeviceProps, fScalerContextFlags, viewMatrix); SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); @@ -306,7 +304,7 @@ void SkGlyphRunListPainter::processARGBFallback(SkScalar maxSourceGlyphDimension // If the matrix is complicated or if scaling is used to fit the glyphs in the cache, // then this case is used. - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeSourceFallback( + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeSourceFallback( runFont, runPaint, fDeviceProps, fScalerContextFlags, maxSourceGlyphDimension); SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); @@ -364,9 +362,9 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi .mapPoints(fPositions, glyphRun.positions().data(), glyphRun.runSize()); SkScalar minScale, maxScale; - SkStrikeSpecStorage strikeSpec; + SkStrikeSpec strikeSpec; std::tie(strikeSpec, minScale, maxScale) = - SkStrikeSpecStorage::MakeSDFT( + SkStrikeSpec::MakeSDFT( runFont, runPaint,fDeviceProps, viewMatrix, options); SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); @@ -431,13 +429,13 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi this->processARGBFallback(maxFallbackDimension * strikeSpec.strikeToSourceRatio(), runPaint, runFont, viewMatrix, process); } - } else if (SkStrikeSpecStorage::ShouldDrawAsPath(runPaint, runFont, viewMatrix)) { + } else if (SkStrikeSpec::ShouldDrawAsPath(runPaint, runFont, viewMatrix)) { // Translate all glyphs to the origin. SkMatrix::MakeTrans(origin.x(), origin.y()).mapPoints( fPositions, glyphRun.positions().data(), glyphRun.runSize()); - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakePath( + SkStrikeSpec strikeSpec = SkStrikeSpec::MakePath( runFont, runPaint, fDeviceProps, fScalerContextFlags); SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); @@ -480,8 +478,8 @@ void SkGlyphRunListPainter::processGlyphRunList(const SkGlyphRunList& glyphRunLi } } else { - SkStrikeSpecStorage strikeSpec = - SkStrikeSpecStorage::MakeMask(runFont, runPaint, + SkStrikeSpec strikeSpec = + SkStrikeSpec::MakeMask(runFont, runPaint, fDeviceProps, fScalerContextFlags, viewMatrix); SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache); @@ -785,7 +783,7 @@ void GrTextBlob::startRun(const SkGlyphRun& glyphRun, bool useSDFT) { } void GrTextBlob::processDeviceMasks(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec) { + const SkStrikeSpec& strikeSpec) { Run* run = this->currentRun(); this->setHasBitmap(); run->setupFont(strikeSpec); @@ -798,7 +796,7 @@ void GrTextBlob::processDeviceMasks(SkSpan masks, } void GrTextBlob::processSourcePaths(SkSpan paths, - const SkStrikeSpecStorage& strikeSpec) { + const SkStrikeSpec& strikeSpec) { Run* run = this->currentRun(); this->setHasBitmap(); run->setupFont(strikeSpec); @@ -824,7 +822,7 @@ void GrTextBlob::processDevicePaths(SkSpan paths) { } void GrTextBlob::processSourceSDFT(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec, + const SkStrikeSpec& strikeSpec, const SkFont& runFont, SkScalar minScale, SkScalar maxScale, @@ -845,7 +843,7 @@ void GrTextBlob::processSourceSDFT(SkSpan masks, } void GrTextBlob::processSourceFallback(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec, + const SkStrikeSpec& strikeSpec, bool hasW) { Run* run = this->currentRun(); @@ -863,7 +861,7 @@ void GrTextBlob::processSourceFallback(SkSpan masks, } void GrTextBlob::processDeviceFallback(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec) { + const SkStrikeSpec& strikeSpec) { Run* run = this->currentRun(); this->setHasBitmap(); sk_sp grStrike = strikeSpec.findOrCreateGrStrike(fStrikeCache); diff --git a/src/core/SkGlyphRunPainter.h b/src/core/SkGlyphRunPainter.h index 48d8c6b9cb..2d824873d7 100644 --- a/src/core/SkGlyphRunPainter.h +++ b/src/core/SkGlyphRunPainter.h @@ -21,7 +21,7 @@ class GrRenderTargetContext; #endif class SkGlyphRunPainterInterface; -class SkStrikeSpecStorage; +class SkStrikeSpec; class SkStrikeCommon { public: @@ -143,26 +143,26 @@ public: virtual void startRun(const SkGlyphRun& glyphRun, bool useSDFT) = 0; virtual void processDeviceMasks(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec) = 0; + const SkStrikeSpec& strikeSpec) = 0; virtual void processSourcePaths(SkSpan paths, - const SkStrikeSpecStorage& strikeSpec) = 0; + const SkStrikeSpec& strikeSpec) = 0; virtual void processDevicePaths(SkSpan paths) = 0; virtual void processSourceSDFT(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec, + const SkStrikeSpec& strikeSpec, const SkFont& runFont, SkScalar minScale, SkScalar maxScale, bool hasWCoord) = 0; virtual void processSourceFallback(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec, + const SkStrikeSpec& strikeSpec, bool hasW) = 0; virtual void processDeviceFallback(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec) = 0; + const SkStrikeSpec& strikeSpec) = 0; }; diff --git a/src/core/SkStrikeSpec.cpp b/src/core/SkStrikeSpec.cpp index 7dc53530d6..608c09fbab 100644 --- a/src/core/SkStrikeSpec.cpp +++ b/src/core/SkStrikeSpec.cpp @@ -13,21 +13,21 @@ #include "src/core/SkStrikeCache.h" #include "src/core/SkTLazy.h" -SkStrikeSpecStorage SkStrikeSpecStorage::MakeMask(const SkFont& font, const SkPaint& paint, - const SkSurfaceProps& surfaceProps, - SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix) { - SkStrikeSpecStorage storage; +SkStrikeSpec SkStrikeSpec::MakeMask(const SkFont& font, const SkPaint& paint, + const SkSurfaceProps& surfaceProps, + SkScalerContextFlags scalerContextFlags, + const SkMatrix& deviceMatrix) { + SkStrikeSpec storage; storage.commonSetup(font, paint, surfaceProps, scalerContextFlags, deviceMatrix); return storage; } -SkStrikeSpecStorage SkStrikeSpecStorage::MakePath(const SkFont& font, const SkPaint& paint, - const SkSurfaceProps& surfaceProps, - SkScalerContextFlags scalerContextFlags) { - SkStrikeSpecStorage storage; +SkStrikeSpec SkStrikeSpec::MakePath(const SkFont& font, const SkPaint& paint, + const SkSurfaceProps& surfaceProps, + SkScalerContextFlags scalerContextFlags) { + SkStrikeSpec storage; // setup our std runPaint, in hopes of getting hits in the cache SkPaint pathPaint{paint}; @@ -45,13 +45,13 @@ SkStrikeSpecStorage SkStrikeSpecStorage::MakePath(const SkFont& font, const SkPa return storage; } -SkStrikeSpecStorage SkStrikeSpecStorage::MakeSourceFallback( +SkStrikeSpec SkStrikeSpec::MakeSourceFallback( const SkFont& font, const SkPaint& paint, const SkSurfaceProps& surfaceProps, SkScalerContextFlags scalerContextFlags, SkScalar maxSourceGlyphDimension) { - SkStrikeSpecStorage storage; + SkStrikeSpec storage; // Subtract 2 to account for the bilerp pad around the glyph SkScalar maxAtlasDimension = SkStrikeCommon::kSkSideTooBigForAtlas - 2; @@ -76,9 +76,8 @@ SkStrikeSpecStorage SkStrikeSpecStorage::MakeSourceFallback( return storage; } -SkStrikeSpecStorage SkStrikeSpecStorage::MakeCanonicalized( - const SkFont& font, const SkPaint* paint) { - SkStrikeSpecStorage storage; +SkStrikeSpec SkStrikeSpec::MakeCanonicalized(const SkFont& font, const SkPaint* paint) { + SkStrikeSpec storage; SkPaint canonicalizedPaint; if (paint != nullptr) { @@ -101,12 +100,12 @@ SkStrikeSpecStorage SkStrikeSpecStorage::MakeCanonicalized( return storage; } -SkStrikeSpecStorage SkStrikeSpecStorage::MakeDefault() { +SkStrikeSpec SkStrikeSpec::MakeDefault() { SkFont defaultFont; return MakeCanonicalized(defaultFont); } -bool SkStrikeSpecStorage::ShouldDrawAsPath( +bool SkStrikeSpec::ShouldDrawAsPath( const SkPaint& paint, const SkFont& font, const SkMatrix& viewMatrix) { // hairline glyphs are fast enough so we don't need to cache them @@ -134,7 +133,7 @@ bool SkStrikeSpecStorage::ShouldDrawAsPath( || distance(SkMatrix::kMSkewX, SkMatrix::kMScaleY) > maxSizeSquared; } -SkStrikeSpecStorage SkStrikeSpecStorage::MakePDFVector(const SkTypeface& typeface, int* size) { +SkStrikeSpec SkStrikeSpec::MakePDFVector(const SkTypeface& typeface, int* size) { SkFont font; font.setHinting(SkFontHinting::kNone); font.setEdging(SkFont::Edging::kAlias); @@ -148,7 +147,7 @@ SkStrikeSpecStorage SkStrikeSpecStorage::MakePDFVector(const SkTypeface& typefac } font.setSize((SkScalar)unitsPerEm); - SkStrikeSpecStorage storage; + SkStrikeSpec storage; storage.commonSetup(font, SkPaint(), SkSurfaceProps(0, kUnknown_SkPixelGeometry), @@ -159,11 +158,11 @@ SkStrikeSpecStorage SkStrikeSpecStorage::MakePDFVector(const SkTypeface& typefac } #if SK_SUPPORT_GPU -std::tuple -SkStrikeSpecStorage::MakeSDFT(const SkFont& font, const SkPaint& paint, - const SkSurfaceProps& surfaceProps, const SkMatrix& deviceMatrix, - const GrTextContext::Options& options) { - SkStrikeSpecStorage storage; +std::tuple +SkStrikeSpec::MakeSDFT(const SkFont& font, const SkPaint& paint, + const SkSurfaceProps& surfaceProps, const SkMatrix& deviceMatrix, + const GrTextContext::Options& options) { + SkStrikeSpec storage; SkPaint dfPaint = GrTextContext::InitDistanceFieldPaint(paint); SkFont dfFont = GrTextContext::InitDistanceFieldFont( @@ -182,15 +181,15 @@ SkStrikeSpecStorage::MakeSDFT(const SkFont& font, const SkPaint& paint, return std::tie(storage, minScale, maxScale); } -sk_sp SkStrikeSpecStorage::findOrCreateGrStrike(GrStrikeCache* cache) const { +sk_sp SkStrikeSpec::findOrCreateGrStrike(GrStrikeCache* cache) const { return cache->getStrike(*fAutoDescriptor.getDesc()); } #endif -void SkStrikeSpecStorage::commonSetup(const SkFont& font, const SkPaint& paint, - const SkSurfaceProps& surfaceProps, - SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix) { +void SkStrikeSpec::commonSetup(const SkFont& font, const SkPaint& paint, + const SkSurfaceProps& surfaceProps, + SkScalerContextFlags scalerContextFlags, + const SkMatrix& deviceMatrix) { SkScalerContextEffects effects; SkScalerContext::CreateDescriptorAndEffectsUsingPaint( @@ -202,12 +201,12 @@ void SkStrikeSpecStorage::commonSetup(const SkFont& font, const SkPaint& paint, fTypeface = font.refTypefaceOrDefault(); } -SkScopedStrike SkStrikeSpecStorage::findOrCreateScopedStrike(SkStrikeCacheInterface* cache) const { +SkScopedStrike SkStrikeSpec::findOrCreateScopedStrike(SkStrikeCacheInterface* cache) const { SkScalerContextEffects effects{fPathEffect.get(), fMaskFilter.get()}; return cache->findOrCreateScopedStrike(*fAutoDescriptor.getDesc(), effects, *fTypeface); } -SkExclusiveStrikePtr SkStrikeSpecStorage::findOrCreateExclusiveStrike(SkStrikeCache* cache) const { +SkExclusiveStrikePtr SkStrikeSpec::findOrCreateExclusiveStrike(SkStrikeCache* cache) const { SkScalerContextEffects effects{fPathEffect.get(), fMaskFilter.get()}; return cache->findOrCreateStrikeExclusive(*fAutoDescriptor.getDesc(), effects, *fTypeface); } diff --git a/src/core/SkStrikeSpec.h b/src/core/SkStrikeSpec.h index 1eefe67e36..26b15791f5 100644 --- a/src/core/SkStrikeSpec.h +++ b/src/core/SkStrikeSpec.h @@ -22,11 +22,10 @@ class SkPaint; class SkStrikeCache; class SkSurfaceProps; -// TODO: rename to SkStrikeSpec when the current SkStrikeSpec is remove from the code. -class SkStrikeSpecStorage { +class SkStrikeSpec { public: // Create a strike spec for mask style cache entries. - static SkStrikeSpecStorage MakeMask( + static SkStrikeSpec MakeMask( const SkFont& font, const SkPaint& paint, const SkSurfaceProps& surfaceProps, @@ -34,31 +33,31 @@ public: const SkMatrix& deviceMatrix); // Create a strike spec for path style cache entries. - static SkStrikeSpecStorage MakePath( + static SkStrikeSpec MakePath( const SkFont& font, const SkPaint& paint, const SkSurfaceProps& surfaceProps, SkScalerContextFlags scalerContextFlags); - static SkStrikeSpecStorage MakeSourceFallback(const SkFont& font, + static SkStrikeSpec MakeSourceFallback(const SkFont& font, const SkPaint& paint, const SkSurfaceProps& surfaceProps, SkScalerContextFlags scalerContextFlags, SkScalar maxSourceGlyphDimension); // Create a canonical strike spec for device-less measurements. - static SkStrikeSpecStorage MakeCanonicalized( + static SkStrikeSpec MakeCanonicalized( const SkFont& font, const SkPaint* paint = nullptr); // Make a canonical strike spec for device-less measurements using default typeface and size. - static SkStrikeSpecStorage MakeDefault(); + static SkStrikeSpec MakeDefault(); // Make a strike spec for PDF Vector strikes - static SkStrikeSpecStorage MakePDFVector(const SkTypeface& typeface, int* size); + static SkStrikeSpec MakePDFVector(const SkTypeface& typeface, int* size); #if SK_SUPPORT_GPU // Create a strike spec for scaled distance field text. - static std::tuple MakeSDFT( + static std::tuple MakeSDFT( const SkFont& font, const SkPaint& paint, const SkSurfaceProps& surfaceProps, diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp index d75d00f98d..21c37a9cb2 100644 --- a/src/core/SkTextBlob.cpp +++ b/src/core/SkTextBlob.cpp @@ -918,7 +918,7 @@ TextInterceptsIter::TextInterceptsIter(const SkGlyphID glyphs[], fPaint.setStyle(SkPaint::kFill_Style); fPaint.setPathEffect(nullptr); - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeCanonicalized(fFont, &fPaint); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakeCanonicalized(fFont, &fPaint); fCache = strikeSpec.findOrCreateExclusiveStrike(); fPaint.setStyle(prevStyle); diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index 7bb6540fbc..f382cf627b 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -59,7 +59,7 @@ sk_sp GrTextBlob::Make(int glyphCount, return blob; } -void GrTextBlob::Run::setupFont(const SkStrikeSpecStorage& strikeSpec) { +void GrTextBlob::Run::setupFont(const SkStrikeSpec& strikeSpec) { if (fFallbackStrikeSpec != nullptr) { *fFallbackStrikeSpec = strikeSpec; diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index 8074c2bd21..5bd633ca81 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -276,7 +276,7 @@ private: class SubRun { public: - SubRun(Run* run, const SkStrikeSpecStorage& strikeSpec, GrColor color) + SubRun(Run* run, const SkStrikeSpec& strikeSpec, GrColor color) : fColor{color} , fRun{run} , fStrikeSpec{strikeSpec} {} @@ -349,7 +349,7 @@ private: void setFallback() { fFlags.argbFallback = true; } bool isFallback() { return fFlags.argbFallback; } - const SkStrikeSpecStorage& strikeSpec() const { return fStrikeSpec; } + const SkStrikeSpec& strikeSpec() const { return fStrikeSpec; } private: GrDrawOpAtlas::BulkUseTokenUpdater fBulkUseToken; @@ -374,7 +374,7 @@ private: bool argbFallback:1; } fFlags{false, false, false, false, false, false}; Run* const fRun; - const SkStrikeSpecStorage& fStrikeSpec; + const SkStrikeSpec& fStrikeSpec; }; // SubRunInfo /* @@ -416,7 +416,7 @@ private: // inits the override descriptor on the current run. All following subruns must use this // descriptor SubRun* initARGBFallback() { - fFallbackStrikeSpec.reset(new SkStrikeSpecStorage{}); + fFallbackStrikeSpec.reset(new SkStrikeSpec{}); // Push back a new subrun to fill and set the override descriptor SubRun* subRun = this->pushBackSubRun(*fFallbackStrikeSpec, fColor); subRun->setMaskFormat(kARGB_GrMaskFormat); @@ -446,7 +446,7 @@ private: SkPoint origin, SkScalar textScale); - void setupFont(const SkStrikeSpecStorage& strikeSpec); + void setupFont(const SkStrikeSpec& strikeSpec); void setRunFontAntiAlias(bool aa) { fAntiAlias = aa; @@ -461,7 +461,7 @@ private: subRun.setHasWCoord(hasWCoord); } - SubRun* pushBackSubRun(const SkStrikeSpecStorage& desc, GrColor color) { + SubRun* pushBackSubRun(const SkStrikeSpec& desc, GrColor color) { // Forward glyph / vertex information to seed the new sub run SubRun& newSubRun = fSubRunInfo.emplace_back(this, desc, color); @@ -489,13 +489,13 @@ private: }; SkSTArray<1, SubRun> fSubRunInfo; - SkStrikeSpecStorage fStrikeSpec; + SkStrikeSpec fStrikeSpec; // Distance field text cannot draw coloremoji, and so has to fall back. However, // though the distance field text and the coloremoji may share the same run, they // will have different descriptors. If fFallbackStrikeSpec is non-nullptr, then it // will be used in place of the run's descriptor to regen texture coords - std::unique_ptr fFallbackStrikeSpec; + std::unique_ptr fFallbackStrikeSpec; SkTArray fPathGlyphs; @@ -519,26 +519,26 @@ private: void startRun(const SkGlyphRun& glyphRun, bool useSDFT) override; void processDeviceMasks(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec) override; + const SkStrikeSpec& strikeSpec) override; void processSourcePaths(SkSpan paths, - const SkStrikeSpecStorage& strikeSpec) override; + const SkStrikeSpec& strikeSpec) override; void processDevicePaths(SkSpan paths) override; void processSourceSDFT(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec, + const SkStrikeSpec& strikeSpec, const SkFont& runFont, SkScalar minScale, SkScalar maxScale, bool hasWCoord) override; void processSourceFallback(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec, + const SkStrikeSpec& strikeSpec, bool hasW) override; void processDeviceFallback(SkSpan masks, - const SkStrikeSpecStorage& strikeSpec) override; + const SkStrikeSpec& strikeSpec) override; struct StrokeInfo { SkScalar fFrameWidth; diff --git a/src/gpu/text/GrTextBlobVertexRegenerator.cpp b/src/gpu/text/GrTextBlobVertexRegenerator.cpp index 96bf4ce1f1..f8f1853df0 100644 --- a/src/gpu/text/GrTextBlobVertexRegenerator.cpp +++ b/src/gpu/text/GrTextBlobVertexRegenerator.cpp @@ -164,7 +164,7 @@ bool GrTextBlob::VertexRegenerator::doRegen(GrTextBlob::VertexRegenerator::Resul if (regenTexCoords) { fSubRun->resetBulkUseToken(); - const SkStrikeSpecStorage& strikeSpec = fSubRun->strikeSpec(); + const SkStrikeSpec& strikeSpec = fSubRun->strikeSpec(); if (!*fLazyStrike || (*fLazyStrike)->getDescriptor() != strikeSpec.descriptor()) { *fLazyStrike = diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 50d8d19e7b..7781f26725 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -829,7 +829,7 @@ void SkPDFDevice::internalDrawGlyphRun( SkClusterator clusterator(glyphRun); int emSize; - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakePDFVector(*typeface, &emSize); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakePDFVector(*typeface, &emSize); auto glyphCache = strikeSpec.findOrCreateExclusiveStrike(); SkScalar textSize = glyphRunFont.getSize(); diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index a1cd112191..f7b4577198 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -374,7 +374,7 @@ static void emit_subset_type0(const SkPDFFont& font, SkPDFDocument* doc) { int16_t defaultWidth = 0; { int emSize; - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakePDFVector(*face, &emSize); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakePDFVector(*face, &emSize); auto glyphCache = strikeSpec.findOrCreateExclusiveStrike(); std::unique_ptr widths = SkPDFMakeCIDGlyphWidthsArray( glyphCache.get(), &font.glyphUsage(), SkToS16(emSize), &defaultWidth); @@ -529,7 +529,7 @@ static void emit_subset_type3(const SkPDFFont& pdfFont, SkPDFDocument* doc) { --lastGlyphID; } int unitsPerEm; - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakePDFVector(*typeface, &unitsPerEm); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakePDFVector(*typeface, &unitsPerEm); auto cache = strikeSpec.findOrCreateExclusiveStrike(); SkASSERT(cache); SkScalar emSize = (SkScalar)unitsPerEm; diff --git a/src/pdf/SkPDFType1Font.cpp b/src/pdf/SkPDFType1Font.cpp index 8ba91d64bf..5697cf3bc7 100644 --- a/src/pdf/SkPDFType1Font.cpp +++ b/src/pdf/SkPDFType1Font.cpp @@ -300,7 +300,7 @@ void SkPDFEmitType1Font(const SkPDFFont& pdfFont, SkPDFDocument* doc) { font.insertInt("LastChar", (size_t)glyphCount); { int emSize; - SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakePDFVector(*typeface, &emSize); + SkStrikeSpec strikeSpec = SkStrikeSpec::MakePDFVector(*typeface, &emSize); auto glyphCache = strikeSpec.findOrCreateExclusiveStrike(); auto widths = SkPDFMakeArray(); diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp index 53109611c7..2452ed0cfc 100644 --- a/tests/SkRemoteGlyphCacheTest.cpp +++ b/tests/SkRemoteGlyphCacheTest.cpp @@ -451,7 +451,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsPath, reporter, paint.setStyle(SkPaint::kStroke_Style); paint.setStrokeWidth(0); REPORTER_ASSERT(reporter, - SkStrikeSpecStorage::ShouldDrawAsPath(paint, SkFont(), SkMatrix::I())); + SkStrikeSpec::ShouldDrawAsPath(paint, SkFont(), SkMatrix::I())); // Server. auto serverTf = SkTypeface::MakeFromName("monospace", SkFontStyle()); @@ -492,7 +492,7 @@ sk_sp make_blob_causing_fallback( font.setTypeface(targetTf); REPORTER_ASSERT(reporter, - !SkStrikeSpecStorage::ShouldDrawAsPath(SkPaint(), font, SkMatrix::I())); + !SkStrikeSpec::ShouldDrawAsPath(SkPaint(), font, SkMatrix::I())); char s[] = "Skia"; int runSize = strlen(s);