diff --git a/bench/PathTextBench.cpp b/bench/PathTextBench.cpp index 9bc69e7478..8c7c9f7f54 100644 --- a/bench/PathTextBench.cpp +++ b/bench/PathTextBench.cpp @@ -46,7 +46,7 @@ private: void onDelayedSetup() override { SkPaint defaultPaint; - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(defaultPaint); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint); for (int i = 0; i < kNumGlyphs; ++i) { SkPackedGlyphID id(cache->unicharToGlyph(kGlyphs[i])); sk_ignore_unused_variable(cache->getScalerContext()->getPath(id, &fGlyphs[i])); diff --git a/bench/SkGlyphCacheBench.cpp b/bench/SkGlyphCacheBench.cpp index be99c9c483..08d43e3eca 100644 --- a/bench/SkGlyphCacheBench.cpp +++ b/bench/SkGlyphCacheBench.cpp @@ -21,8 +21,7 @@ static void do_font_stuff(SkPaint* paint) { for (SkScalar i = 8; i < 64; i++) { paint->setTextSize(i); auto cache = SkStrikeCache::FindOrCreateStrikeExclusive( - *paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), - SkScalerContextFlags::kNone, SkMatrix::I()); + *paint, nullptr, SkScalerContextFlags::kNone, nullptr); uint16_t glyphs['z']; for (int c = ' '; c < 'z'; c++) { glyphs[c] = cache->unicharToGlyph(c); diff --git a/samplecode/SamplePathText.cpp b/samplecode/SamplePathText.cpp index b56131daa9..9ad63015dc 100644 --- a/samplecode/SamplePathText.cpp +++ b/samplecode/SamplePathText.cpp @@ -33,7 +33,7 @@ public: void onOnceBeforeDraw() final { SkPaint defaultPaint; - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(defaultPaint); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint); SkPath glyphPaths[52]; for (int i = 0; i < 52; ++i) { // I and l are rects on OS X ... diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp index 7043de8d1a..b595034f2c 100644 --- a/src/core/SkGlyphRun.cpp +++ b/src/core/SkGlyphRun.cpp @@ -368,7 +368,7 @@ void SkGlyphRunBuilder::simplifyDrawText( if (!glyphIDs.empty()) { fScratchAdvances.resize(runSize); { - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(runPaint); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(runPaint); cache->getAdvances(glyphIDs, fScratchAdvances.data()); } diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp index 1fb42cb5f6..e3900aa1d6 100644 --- a/src/core/SkGlyphRunPainter.cpp +++ b/src/core/SkGlyphRunPainter.cpp @@ -180,7 +180,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice( SkScalar textScale = pathPaint.setupForAsPaths(); auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive( - pathPaint, props, fScalerContextFlags, SkMatrix::I()); + pathPaint, &props, fScalerContextFlags, nullptr); SkTDArray pathsAndPositions; pathsAndPositions.setReserve(runSize); @@ -204,7 +204,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice( paint); } else { auto cache = SkStrikeCache::FindOrCreateStrikeExclusive( - paint, props, fScalerContextFlags, deviceMatrix); + paint, &props, fScalerContextFlags, &deviceMatrix); // Add rounding and origin. SkMatrix matrix = deviceMatrix; @@ -599,8 +599,8 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache, fBlob->setHasBitmap(); fBlob->setSubRunHasW(fRunIndex, glyphCacheMatrix.hasPerspective()); SkExclusiveStrikePtr fallbackCache = - fBlob->setupCache(fRunIndex, - fallbackPaint, fProps, fScalerContextFlags, glyphCacheMatrix); + fBlob->setupCache(fRunIndex, fProps, fScalerContextFlags, + fallbackPaint, &glyphCacheMatrix); sk_sp strike = fGlyphCache->getStrike(fallbackCache.get()); const SkPoint* glyphPos = positions.data(); for (auto glyphID : glyphIDs) { @@ -649,7 +649,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache, { auto cache = this->setupCache( - runIndex, distanceFieldPaint, props, flags, SkMatrix::I()); + runIndex, props, flags, distanceFieldPaint, &SkMatrix::I()); sk_sp currStrike = glyphCache->getStrike(cache.get()); @@ -698,7 +698,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache, SkScalar textScale = pathPaint.setupForAsPaths(); auto pathCache = SkStrikeCache::FindOrCreateStrikeExclusive( - pathPaint, props, scalerContextFlags, SkMatrix::I()); + pathPaint, &props, scalerContextFlags, &SkMatrix::I()); // Given a glyph that is not ARGB, draw it. auto perPath = [textScale, runIndex, this, &pathCache] @@ -723,7 +723,7 @@ void GrTextBlob::generateFromGlyphRunList(GrGlyphCache* glyphCache, this->setHasBitmap(); auto cache = this->setupCache( - runIndex, runPaint, props, scalerContextFlags, viewMatrix); + runIndex, props, scalerContextFlags, runPaint, &viewMatrix); sk_sp currStrike = glyphCache->getStrike(cache.get()); diff --git a/src/core/SkOverdrawCanvas.cpp b/src/core/SkOverdrawCanvas.cpp index 80c5e03c48..29d30b6b0f 100644 --- a/src/core/SkOverdrawCanvas.cpp +++ b/src/core/SkOverdrawCanvas.cpp @@ -73,7 +73,7 @@ void SkOverdrawCanvas::drawPosTextCommon(const void* text, size_t byteLength, co SkSurfaceProps props(0, kUnknown_SkPixelGeometry); this->getProps(&props); auto cache = SkStrikeCache::FindOrCreateStrikeExclusive( - paint, props, SkScalerContextFlags::kNone, this->getTotalMatrix()); + paint, &props, SkScalerContextFlags::kNone, &this->getTotalMatrix()); SkFindAndPlaceGlyph::ProcessPosText(paint.getTextEncoding(), (const char*) text, byteLength, SkPoint::Make(0, 0), SkMatrix(), (const SkScalar*) pos, 2, cache.get(), processBounds); diff --git a/src/core/SkPaint_text.cpp b/src/core/SkPaint_text.cpp index 47f7891f31..21a7c9570b 100644 --- a/src/core/SkPaint_text.cpp +++ b/src/core/SkPaint_text.cpp @@ -102,7 +102,7 @@ int SkPaint::textToGlyphs(const void* textData, size_t byteLength, uint16_t glyp return SkToInt(byteLength >> 1); } - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(*this); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(*this); const void* stop = (const char*)textData + byteLength; uint16_t* gptr = glyphs; @@ -137,7 +137,7 @@ bool SkPaint::containsText(const void* textData, size_t byteLength) const { return true; } - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(*this); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(*this); const void* stop = (const char*)textData + byteLength; const SkTypeface::Encoding encoding = to_encoding(this->getTextEncoding()); while (textData < stop) { @@ -158,7 +158,7 @@ void SkPaint::glyphsToUnichars(const uint16_t glyphs[], int count, SkUnichar tex SkSurfaceProps props(0, kUnknown_SkPixelGeometry); auto cache = SkStrikeCache::FindOrCreateStrikeExclusive( - *this, props, SkScalerContextFlags::kFakeGammaAndBoostContrast, SkMatrix::I()); + *this, &props, SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr); for (int index = 0; index < count; index++) { textData[index] = cache->glyphToUnichar(glyphs[index]); @@ -390,7 +390,7 @@ SkScalar SkPaint::measureText(const void* textData, size_t length, SkRect* bound const SkPaint& paint = canon.getPaint(); SkScalar scale = canon.getScale(); - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint); SkScalar width = 0; @@ -443,7 +443,7 @@ size_t SkPaint::breakText(const void* textD, size_t length, SkScalar maxWidth, maxWidth /= scale; } - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint); GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(), false); @@ -486,8 +486,7 @@ SkScalar SkPaint::getFontMetrics(SkFontMetrics* metrics) const { SkScalerContextEffects effects; auto desc = SkScalerContext::CreateDescriptorAndEffectsUsingPaint( - paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), - SkScalerContextFlags::kNone, SkMatrix::I(), &ad, &effects); + paint, nullptr, SkScalerContextFlags::kNone, nullptr, &ad, &effects); { auto typeface = SkPaintPriv::GetTypefaceOrDefault(paint); @@ -526,7 +525,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength, const SkPaint& paint = canon.getPaint(); SkScalar scale = canon.getScale(); - auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint); + auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint); GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(), nullptr != bounds); @@ -788,7 +787,9 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length, } // SRGBTODO: Is this correct? - fCache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(fPaint); + fCache = SkStrikeCache::FindOrCreateStrikeExclusive( + fPaint, nullptr, + SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr); SkPaint::Style style = SkPaint::kFill_Style; sk_sp pe; diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp index c25d68dfcd..976469fa8b 100644 --- a/src/core/SkRemoteGlyphCache.cpp +++ b/src/core/SkRemoteGlyphCache.cpp @@ -64,7 +64,7 @@ static const SkDescriptor* create_descriptor( SkScalerContextRec deviceRec; bool enableTypefaceFiltering = (type == kDevice); SkScalerContext::MakeRecAndEffects( - font, paint, props, flags, m, &deviceRec, effects, enableTypefaceFiltering); + font, paint, &props, &m, flags, &deviceRec, effects, enableTypefaceFiltering); return SkScalerContext::AutoDescriptorGivenRecAndEffects(deviceRec, *effects, ad); } diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index e667aef793..f588bda8b4 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -900,14 +900,15 @@ static SkFontHinting computeHinting(const SkFont& font) { // The only reason this is not file static is because it needs the context of SkScalerContext to // access SkPaint::computeLuminanceColor. -void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint, - const SkSurfaceProps& surfaceProps, +void SkScalerContext::MakeRecAndEffects(const SkFont& font, + const SkPaint& paint, + const SkSurfaceProps* surfaceProps, + const SkMatrix* deviceMatrix, SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix, SkScalerContextRec* rec, SkScalerContextEffects* effects, bool enableTypefaceFiltering) { - SkASSERT(!deviceMatrix.hasPerspective()); + SkASSERT(deviceMatrix == nullptr || !deviceMatrix->hasPerspective()); sk_bzero(rec, sizeof(SkScalerContextRec)); @@ -920,19 +921,24 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint bool checkPost2x2 = false; - const SkMatrix::TypeMask mask = deviceMatrix.getType(); - if (mask & SkMatrix::kScale_Mask) { - rec->fPost2x2[0][0] = sk_relax(deviceMatrix.getScaleX()); - rec->fPost2x2[1][1] = sk_relax(deviceMatrix.getScaleY()); - checkPost2x2 = true; + if (deviceMatrix) { + const SkMatrix::TypeMask mask = deviceMatrix->getType(); + if (mask & SkMatrix::kScale_Mask) { + rec->fPost2x2[0][0] = sk_relax(deviceMatrix->getScaleX()); + rec->fPost2x2[1][1] = sk_relax(deviceMatrix->getScaleY()); + checkPost2x2 = true; + } else { + rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1; + } + if (mask & SkMatrix::kAffine_Mask) { + rec->fPost2x2[0][1] = sk_relax(deviceMatrix->getSkewX()); + rec->fPost2x2[1][0] = sk_relax(deviceMatrix->getSkewY()); + checkPost2x2 = true; + } else { + rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0; + } } else { rec->fPost2x2[0][0] = rec->fPost2x2[1][1] = SK_Scalar1; - } - if (mask & SkMatrix::kAffine_Mask) { - rec->fPost2x2[0][1] = sk_relax(deviceMatrix.getSkewX()); - rec->fPost2x2[1][0] = sk_relax(deviceMatrix.getSkewY()); - checkPost2x2 = true; - } else { rec->fPost2x2[0][1] = rec->fPost2x2[1][0] = 0; } @@ -983,8 +989,9 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint rec->fMaskFormat = SkMask::kA8_Format; flags |= SkScalerContext::kGenA8FromLCD_Flag; } else { - SkPixelGeometry geometry = surfaceProps.pixelGeometry(); - + SkPixelGeometry geometry = surfaceProps + ? surfaceProps->pixelGeometry() + : SkSurfacePropsDefaultPixelGeometry(); switch (geometry) { case kUnknown_SkPixelGeometry: // eeek, can't support LCD @@ -1106,14 +1113,14 @@ SkDescriptor* SkScalerContext::MakeDescriptorForPaths(SkFontID typefaceID, } SkDescriptor* SkScalerContext::CreateDescriptorAndEffectsUsingPaint( - const SkPaint& paint, const SkSurfaceProps& surfaceProps, + const SkPaint& paint, const SkSurfaceProps* surfaceProps, SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix, SkAutoDescriptor* ad, + const SkMatrix* deviceMatrix, SkAutoDescriptor* ad, SkScalerContextEffects* effects) { SkFont font = SkFont::LEGACY_ExtractFromPaint(paint); SkScalerContextRec rec; - MakeRecAndEffects(font, paint, surfaceProps, scalerContextFlags, deviceMatrix, &rec, effects); + MakeRecAndEffects(font, paint, surfaceProps, deviceMatrix, scalerContextFlags, &rec, effects); return AutoDescriptorGivenRecAndEffects(rec, *effects, ad); } diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h index 1af58ef6fa..e70ca51957 100644 --- a/src/core/SkScalerContext.h +++ b/src/core/SkScalerContext.h @@ -19,7 +19,6 @@ #include "SkMaskGamma.h" #include "SkMatrix.h" #include "SkPaint.h" -#include "SkSurfacePriv.h" #include "SkTypeface.h" #include "SkWriteBuffer.h" @@ -312,23 +311,25 @@ public: static bool GetGammaLUTData(SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma, uint8_t* data); - static void MakeRecAndEffects(const SkFont& font, const SkPaint& paint, - const SkSurfaceProps& surfaceProps, + static void MakeRecAndEffects(const SkFont& font, + const SkPaint& paint, + const SkSurfaceProps* surfaceProps, + const SkMatrix* deviceMatrix, SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix, SkScalerContextRec* rec, SkScalerContextEffects* effects, bool enableTypefaceFiltering = true); - // If we are creating rec and effects from a font only, then there is no device around either. - static void MakeRecAndEffectsFromFont(const SkFont& font, - SkScalerContextRec* rec, - SkScalerContextEffects* effects, - bool enableTypefaceFiltering = true) { + static void MakeRecAndEffectsUsingDefaultPaint(const SkFont& font, + const SkSurfaceProps* surfaceProps, + const SkMatrix* deviceMatrix, + SkScalerContextFlags scalerContextFlags, + SkScalerContextRec* rec, + SkScalerContextEffects* effects, + bool enableTypefaceFiltering = true) { SkPaint paint; - return MakeRecAndEffects( - font, paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), - SkScalerContextFlags::kNone, SkMatrix::I(), rec, effects, enableTypefaceFiltering); + return MakeRecAndEffects(font, paint, surfaceProps, deviceMatrix, scalerContextFlags, + rec, effects, enableTypefaceFiltering); } static SkDescriptor* MakeDescriptorForPaths(SkFontID fontID, @@ -363,9 +364,9 @@ public: SkAxisAlignment computeAxisAlignmentForHText() const; static SkDescriptor* CreateDescriptorAndEffectsUsingPaint( - const SkPaint& paint, const SkSurfaceProps& surfaceProps, + const SkPaint& paint, const SkSurfaceProps* surfaceProps, SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix, SkAutoDescriptor* ad, + const SkMatrix* deviceMatrix, SkAutoDescriptor* ad, SkScalerContextEffects* effects); protected: diff --git a/src/core/SkStrikeCache.cpp b/src/core/SkStrikeCache.cpp index cd48b4e033..0f3ca2dcb1 100644 --- a/src/core/SkStrikeCache.cpp +++ b/src/core/SkStrikeCache.cpp @@ -148,9 +148,9 @@ SkExclusiveStrikePtr SkStrikeCache::findOrCreateStrikeExclusive( SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive( const SkPaint& paint, - const SkSurfaceProps& surfaceProps, + const SkSurfaceProps* surfaceProps, SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix) + const SkMatrix* deviceMatrix) { SkAutoDescriptor ad; SkScalerContextEffects effects; @@ -163,10 +163,9 @@ SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive( return FindOrCreateStrikeExclusive(*desc, effects, *tf); } -SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(const SkPaint& paint) { +SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(const SkPaint& paint) { return FindOrCreateStrikeExclusive( - paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), - kFakeGammaAndBoostContrast, SkMatrix::I()); + paint, nullptr, kFakeGammaAndBoostContrast, nullptr); } void SkStrikeCache::PurgeAll() { diff --git a/src/core/SkStrikeCache.h b/src/core/SkStrikeCache.h index 5abaee476e..5d88126960 100644 --- a/src/core/SkStrikeCache.h +++ b/src/core/SkStrikeCache.h @@ -104,11 +104,11 @@ public: static ExclusiveStrikePtr FindOrCreateStrikeExclusive( const SkPaint& paint, - const SkSurfaceProps& surfaceProps, + const SkSurfaceProps* surfaceProps, SkScalerContextFlags scalerContextFlags, - const SkMatrix& deviceMatrix); + const SkMatrix* deviceMatrix); - static ExclusiveStrikePtr FindOrCreateStrikeWithNoDeviceExclusive(const SkPaint& paint); + static ExclusiveStrikePtr FindOrCreateStrikeExclusive(const SkPaint& paint); static std::unique_ptr CreateScalerContext( const SkDescriptor&, const SkScalerContextEffects&, const SkTypeface&); diff --git a/src/core/SkSurfacePriv.h b/src/core/SkSurfacePriv.h index e86a6397d5..a41b583f02 100644 --- a/src/core/SkSurfacePriv.h +++ b/src/core/SkSurfacePriv.h @@ -20,6 +20,10 @@ static inline SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps* p } } +static inline SkPixelGeometry SkSurfacePropsDefaultPixelGeometry() { + return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType).pixelGeometry(); +} + constexpr size_t kIgnoreRowBytesValue = static_cast(~0); bool SkSurfaceValidateRasterInfo(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue); diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp index 96b61ce11e..00fe495926 100644 --- a/src/core/SkTypeface.cpp +++ b/src/core/SkTypeface.cpp @@ -14,7 +14,6 @@ #include "SkOTTable_OS_2.h" #include "SkOnce.h" #include "SkStream.h" -#include "SkSurfacePriv.h" #include "SkTypeface.h" #include "SkTypefaceCache.h" @@ -402,7 +401,10 @@ bool SkTypeface::onComputeBounds(SkRect* bounds) const { SkScalerContextRec rec; SkScalerContextEffects effects; - SkScalerContext::MakeRecAndEffectsFromFont(font, &rec, &effects); + const SkSurfaceProps* defaultProps = nullptr; + const SkMatrix* noDeviceMatrix = nullptr; + SkScalerContext::MakeRecAndEffectsUsingDefaultPaint( + font, defaultProps, noDeviceMatrix, SkScalerContextFlags::kNone, &rec, &effects); SkAutoDescriptor ad; SkScalerContextEffects noeffects; diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index e0351241d9..cc686f558a 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -59,10 +59,10 @@ sk_sp GrTextBlob::Make(int glyphCount, int runCount) { } SkExclusiveStrikePtr GrTextBlob::setupCache(int runIndex, - const SkPaint& skPaint, - const SkSurfaceProps& props, - SkScalerContextFlags scalerContextFlags, - const SkMatrix& viewMatrix) { + const SkSurfaceProps& props, + SkScalerContextFlags scalerContextFlags, + const SkPaint& skPaint, + const SkMatrix* viewMatrix) { GrTextBlob::Run* run = &fRuns[runIndex]; // if we have an override descriptor for the run, then we should use that @@ -70,7 +70,7 @@ SkExclusiveStrikePtr GrTextBlob::setupCache(int runIndex, &run->fDescriptor; SkScalerContextEffects effects; SkScalerContext::CreateDescriptorAndEffectsUsingPaint( - skPaint, props, scalerContextFlags, viewMatrix, desc, &effects); + skPaint, &props, scalerContextFlags, viewMatrix, desc, &effects); run->fTypeface = SkPaintPriv::RefTypefaceOrDefault(skPaint); run->fPathEffect = sk_ref_sp(effects.fPathEffect); run->fMaskFilter = sk_ref_sp(effects.fMaskFilter); diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index f773d0b8ee..1cccaca8d2 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -180,10 +180,10 @@ public: } SkExclusiveStrikePtr setupCache(int runIndex, - const SkPaint& skPaint, const SkSurfaceProps& props, SkScalerContextFlags scalerContextFlags, - const SkMatrix& viewMatrix); + const SkPaint& skPaint, + const SkMatrix* viewMatrix); // Appends a glyph to the blob. If the glyph is too large, the glyph will be appended // as a path. diff --git a/src/pdf/SkPDFFont.cpp b/src/pdf/SkPDFFont.cpp index da7afbf563..8f314084ca 100644 --- a/src/pdf/SkPDFFont.cpp +++ b/src/pdf/SkPDFFont.cpp @@ -46,7 +46,7 @@ SkExclusiveStrikePtr SkPDFFont::MakeVectorCache(SkTypeface* face, int* size) { tmpPaint.setTextSize((SkScalar)unitsPerEm); const SkSurfaceProps props(0, kUnknown_SkPixelGeometry); return SkStrikeCache::FindOrCreateStrikeExclusive( - tmpPaint, props, SkScalerContextFlags::kFakeGammaAndBoostContrast, SkMatrix::I()); + tmpPaint, &props, SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr); } namespace { diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp index b067c4f905..eecfe8c06f 100644 --- a/src/xps/SkXPSDevice.cpp +++ b/src/xps/SkXPSDevice.cpp @@ -1873,8 +1873,8 @@ HRESULT SkXPSDevice::CreateTypefaceUse(const SkPaint& paint, newTypefaceUse.xpsFont = xpsFontResource.release(); auto glyphCache = SkStrikeCache::FindOrCreateStrikeExclusive( - paint, this->surfaceProps(), - SkScalerContextFlags::kNone, SkMatrix::I()); + paint, &this->surfaceProps(), + SkScalerContextFlags::kNone, nullptr); unsigned int glyphCount = glyphCache->getGlyphCount(); newTypefaceUse.glyphsUsed = new SkBitSet(glyphCount); @@ -2057,8 +2057,8 @@ void SkXPSDevice::drawPosText(const void* text, size_t byteLen, auto cache = SkStrikeCache::FindOrCreateStrikeExclusive( - paint, this->surfaceProps(), - SkScalerContextFlags::kNone, SkMatrix::I()); + paint, &this->surfaceProps(), + SkScalerContextFlags::kNone, nullptr); // Advance width and offsets for glyphs measured in hundredths of the font em size // (XPS Spec 5.1.3). diff --git a/tests/SkRemoteGlyphCacheTest.cpp b/tests/SkRemoteGlyphCacheTest.cpp index 6e7160f841..d6ed10fe68 100644 --- a/tests/SkRemoteGlyphCacheTest.cpp +++ b/tests/SkRemoteGlyphCacheTest.cpp @@ -14,7 +14,6 @@ #include "SkRemoteGlyphCacheImpl.h" #include "SkStrikeCache.h" #include "SkSurface.h" -#include "SkSurfacePriv.h" #include "SkTestEmptyTypeface.h" #include "SkTextBlob.h" #include "SkTypeface_remote.h" @@ -119,21 +118,12 @@ SkTextBlobCacheDiffCanvas::Settings MakeSettings(GrContext* context) { return settings; } -sk_sp MakeSurface(int width, int height, GrContext* context) { - const SkImageInfo info = - SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); - return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); -} - -const SkSurfaceProps FindSurfaceProps(GrContext* context) { - auto surface = MakeSurface(1, 1, context); - return surface->props(); -} - SkBitmap RasterBlob(sk_sp blob, int width, int height, const SkPaint& paint, GrContext* context, const SkMatrix* matrix = nullptr, SkScalar x = 0) { - auto surface = MakeSurface(width, height, context); + const SkImageInfo info = + SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType); + auto surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info); if (matrix) surface->getCanvas()->concat(*matrix); surface->getCanvas()->drawTextBlob(blob.get(), x, 0, paint); SkBitmap bitmap; @@ -171,7 +161,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_StrikeSerialization, repor int glyphCount = 10; auto serverBlob = buildTextBlob(serverTf, glyphCount); - auto props = FindSurfaceProps(ctxInfo.grContext()); + const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server, MakeSettings(ctxInfo.grContext())); cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint); @@ -412,7 +402,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsPath, reporter, int glyphCount = 10; auto serverBlob = buildTextBlob(serverTf, glyphCount); - auto props = FindSurfaceProps(ctxInfo.grContext()); + const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server, MakeSettings(ctxInfo.grContext())); cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint); @@ -489,7 +479,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsMaskWithPathFall auto serverBlob = make_blob_causing_fallback(serverTf, serverTf.get(), reporter); - auto props = FindSurfaceProps(ctxInfo.grContext()); + const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server, MakeSettings(ctxInfo.grContext())); cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint); @@ -529,7 +519,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextXY, reporter, ctxI int glyphCount = 10; auto serverBlob = buildTextBlob(serverTf, glyphCount); - auto props = FindSurfaceProps(ctxInfo.grContext()); + const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType); SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server, MakeSettings(ctxInfo.grContext())); cache_diff_canvas.drawTextBlob(serverBlob.get(), 0.5, 0, paint); @@ -658,9 +648,7 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) { SkScalerContextRec rec; SkScalerContextEffects effects; SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast; - SkScalerContext::MakeRecAndEffects( - font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags, - SkMatrix::I(), &rec, &effects, false); + SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false); auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad); auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf); @@ -678,9 +666,7 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) { SkScalerContextRec rec; SkScalerContextEffects effects; SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast; - SkScalerContext::MakeRecAndEffects( - font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags, - SkMatrix::I(), &rec, &effects, false); + SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false); auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad); auto testCache = strikeCache.findStrikeExclusive(*desc); REPORTER_ASSERT(reporter, !(testCache == nullptr)); @@ -692,10 +678,7 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) { SkScalerContextRec rec; SkScalerContextEffects effects; SkScalerContextFlags flags = SkScalerContextFlags::kNone; - SkScalerContext::MakeRecAndEffects( - font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags, - SkMatrix::I(), - &rec, &effects, false); + SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false); auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad); testCache = strikeCache.findStrikeExclusive(*desc); REPORTER_ASSERT(reporter, testCache == nullptr); @@ -771,9 +754,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) { SkScalerContextEffects effects; SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast; paint.setTypeface(serverTf); - SkScalerContext::MakeRecAndEffects( - font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags, - SkMatrix::I(), &rec, &effects, false); + SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false); auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad); auto context = serverTf->createScalerContext(effects, desc, false); @@ -791,9 +772,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) { SkScalerContextEffects effects; SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast; paint.setTypeface(clientTf); - SkScalerContext::MakeRecAndEffects( - font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags, - SkMatrix::I(), &rec, &effects, false); + SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false); auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad); auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf); @@ -812,7 +791,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) { SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast; paint.setTypeface(serverTf); auto* cacheState = server.getOrCreateCache( - paint, SkSurfacePropsCopyOrDefault(nullptr), + paint, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType), SkMatrix::I(), flags, &effects); cacheState->addGlyph(lostGlyphID, false); @@ -830,9 +809,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) { SkScalerContextEffects effects; SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast; paint.setTypeface(clientTf); - SkScalerContext::MakeRecAndEffects( - font, paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), flags, - SkMatrix::I(), &rec, &effects, false); + SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false); auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad); auto fallbackCache = strikeCache.findStrikeExclusive(*desc);