aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHerb Derby <herb@google.com>2018-11-08 16:40:26 -0500
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2018-11-09 20:01:42 +0000
commitc34150079a0aa7b4ef0f79611c536ae336a65089 (patch)
treedca55628ace300493e1eec840f2b204555ede3c9
parent106296323223b6ac9980862ae6e9ce039bbd1534 (diff)
downloadskqp-c34150079a0aa7b4ef0f79611c536ae336a65089.tar.gz
Reland "Move remove ptr args to MakeRecAndEffects"
This is a reland of b07aba42145e29e0e995b373844c59846058a9ba Original change's description: > Move remove ptr args to MakeRecAndEffects > > Move this conversion out through the transitive closure of calls. As you > move up the stack, everything becomes refs instread of pointers. > > Reorder args of MakeRecAndEffects and setupCache to match the majority of other > calls. > > Change-Id: I72baf457cd9140f76ee5f7122493284c4be5bcd0 > Reviewed-on: https://skia-review.googlesource.com/c/169765 > Reviewed-by: Ben Wagner <bungeman@google.com> > Commit-Queue: Herb Derby <herb@google.com> Change-Id: I2ff7f218ecc7b18ae6a2b293cecdb059eea77562 Reviewed-on: https://skia-review.googlesource.com/c/170222 Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Herb Derby <herb@google.com>
-rw-r--r--bench/PathTextBench.cpp2
-rw-r--r--bench/SkGlyphCacheBench.cpp3
-rw-r--r--samplecode/SamplePathText.cpp2
-rw-r--r--src/core/SkGlyphRun.cpp2
-rw-r--r--src/core/SkGlyphRunPainter.cpp14
-rw-r--r--src/core/SkOverdrawCanvas.cpp2
-rw-r--r--src/core/SkPaint_text.cpp19
-rw-r--r--src/core/SkRemoteGlyphCache.cpp2
-rw-r--r--src/core/SkScalerContext.cpp47
-rw-r--r--src/core/SkScalerContext.h29
-rw-r--r--src/core/SkStrikeCache.cpp9
-rw-r--r--src/core/SkStrikeCache.h6
-rw-r--r--src/core/SkSurfacePriv.h4
-rw-r--r--src/core/SkTypeface.cpp6
-rw-r--r--src/gpu/text/GrTextBlob.cpp10
-rw-r--r--src/gpu/text/GrTextBlob.h4
-rw-r--r--src/pdf/SkPDFFont.cpp2
-rw-r--r--src/xps/SkXPSDevice.cpp8
-rw-r--r--tests/SkRemoteGlyphCacheTest.cpp51
19 files changed, 116 insertions, 106 deletions
diff --git a/bench/PathTextBench.cpp b/bench/PathTextBench.cpp
index 8c7c9f7f54..9bc69e7478 100644
--- a/bench/PathTextBench.cpp
+++ b/bench/PathTextBench.cpp
@@ -46,7 +46,7 @@ private:
void onDelayedSetup() override {
SkPaint defaultPaint;
- auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(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 08d43e3eca..be99c9c483 100644
--- a/bench/SkGlyphCacheBench.cpp
+++ b/bench/SkGlyphCacheBench.cpp
@@ -21,7 +21,8 @@ static void do_font_stuff(SkPaint* paint) {
for (SkScalar i = 8; i < 64; i++) {
paint->setTextSize(i);
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
- *paint, nullptr, SkScalerContextFlags::kNone, nullptr);
+ *paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
+ SkScalerContextFlags::kNone, SkMatrix::I());
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 9ad63015dc..b56131daa9 100644
--- a/samplecode/SamplePathText.cpp
+++ b/samplecode/SamplePathText.cpp
@@ -33,7 +33,7 @@ public:
void onOnceBeforeDraw() final {
SkPaint defaultPaint;
- auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(defaultPaint);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(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 b595034f2c..7043de8d1a 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::FindOrCreateStrikeExclusive(runPaint);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(runPaint);
cache->getAdvances(glyphIDs, fScratchAdvances.data());
}
diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp
index e3900aa1d6..1fb42cb5f6 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, nullptr);
+ pathPaint, props, fScalerContextFlags, SkMatrix::I());
SkTDArray<PathAndPos> 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, fProps, fScalerContextFlags,
- fallbackPaint, &glyphCacheMatrix);
+ fBlob->setupCache(fRunIndex,
+ fallbackPaint, fProps, fScalerContextFlags, glyphCacheMatrix);
sk_sp<GrTextStrike> 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, props, flags, distanceFieldPaint, &SkMatrix::I());
+ runIndex, distanceFieldPaint, props, flags, SkMatrix::I());
sk_sp<GrTextStrike> 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, props, scalerContextFlags, runPaint, &viewMatrix);
+ runIndex, runPaint, props, scalerContextFlags, viewMatrix);
sk_sp<GrTextStrike> currStrike = glyphCache->getStrike(cache.get());
diff --git a/src/core/SkOverdrawCanvas.cpp b/src/core/SkOverdrawCanvas.cpp
index 29d30b6b0f..80c5e03c48 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 21a7c9570b..47f7891f31 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::FindOrCreateStrikeExclusive(*this);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(*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::FindOrCreateStrikeExclusive(*this);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(*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, nullptr);
+ *this, props, SkScalerContextFlags::kFakeGammaAndBoostContrast, SkMatrix::I());
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::FindOrCreateStrikeExclusive(paint);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(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::FindOrCreateStrikeExclusive(paint);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint);
GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(),
false);
@@ -486,7 +486,8 @@ SkScalar SkPaint::getFontMetrics(SkFontMetrics* metrics) const {
SkScalerContextEffects effects;
auto desc = SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
- paint, nullptr, SkScalerContextFlags::kNone, nullptr, &ad, &effects);
+ paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry),
+ SkScalerContextFlags::kNone, SkMatrix::I(), &ad, &effects);
{
auto typeface = SkPaintPriv::GetTypefaceOrDefault(paint);
@@ -525,7 +526,7 @@ int SkPaint::getTextWidths(const void* textData, size_t byteLength,
const SkPaint& paint = canon.getPaint();
SkScalar scale = canon.getScale();
- auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(paint);
+ auto cache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(paint);
GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(paint.getTextEncoding(),
nullptr != bounds);
@@ -787,9 +788,7 @@ SkTextBaseIter::SkTextBaseIter(const char text[], size_t length,
}
// SRGBTODO: Is this correct?
- fCache = SkStrikeCache::FindOrCreateStrikeExclusive(
- fPaint, nullptr,
- SkScalerContextFlags::kFakeGammaAndBoostContrast, nullptr);
+ fCache = SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(fPaint);
SkPaint::Style style = SkPaint::kFill_Style;
sk_sp<SkPathEffect> pe;
diff --git a/src/core/SkRemoteGlyphCache.cpp b/src/core/SkRemoteGlyphCache.cpp
index 976469fa8b..c25d68dfcd 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, &m, flags, &deviceRec, effects, enableTypefaceFiltering);
+ font, paint, props, flags, m, &deviceRec, effects, enableTypefaceFiltering);
return SkScalerContext::AutoDescriptorGivenRecAndEffects(deviceRec, *effects, ad);
}
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index f588bda8b4..e667aef793 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -900,15 +900,14 @@ 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,
- const SkMatrix* deviceMatrix,
+void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint,
+ const SkSurfaceProps& surfaceProps,
SkScalerContextFlags scalerContextFlags,
+ const SkMatrix& deviceMatrix,
SkScalerContextRec* rec,
SkScalerContextEffects* effects,
bool enableTypefaceFiltering) {
- SkASSERT(deviceMatrix == nullptr || !deviceMatrix->hasPerspective());
+ SkASSERT(!deviceMatrix.hasPerspective());
sk_bzero(rec, sizeof(SkScalerContextRec));
@@ -921,24 +920,19 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font,
bool checkPost2x2 = false;
- 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;
- }
+ 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;
}
@@ -989,9 +983,8 @@ void SkScalerContext::MakeRecAndEffects(const SkFont& font,
rec->fMaskFormat = SkMask::kA8_Format;
flags |= SkScalerContext::kGenA8FromLCD_Flag;
} else {
- SkPixelGeometry geometry = surfaceProps
- ? surfaceProps->pixelGeometry()
- : SkSurfacePropsDefaultPixelGeometry();
+ SkPixelGeometry geometry = surfaceProps.pixelGeometry();
+
switch (geometry) {
case kUnknown_SkPixelGeometry:
// eeek, can't support LCD
@@ -1113,14 +1106,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, deviceMatrix, scalerContextFlags, &rec, effects);
+ MakeRecAndEffects(font, paint, surfaceProps, scalerContextFlags, deviceMatrix, &rec, effects);
return AutoDescriptorGivenRecAndEffects(rec, *effects, ad);
}
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index e70ca51957..0fa1df402a 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -19,6 +19,7 @@
#include "SkMaskGamma.h"
#include "SkMatrix.h"
#include "SkPaint.h"
+#include "SkSurfacePriv.h"
#include "SkTypeface.h"
#include "SkWriteBuffer.h"
@@ -311,25 +312,23 @@ 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,
- const SkMatrix* deviceMatrix,
+ static void MakeRecAndEffects(const SkFont& font, const SkPaint& paint,
+ const SkSurfaceProps& surfaceProps,
SkScalerContextFlags scalerContextFlags,
+ const SkMatrix& deviceMatrix,
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) {
+ // 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) {
SkPaint paint;
- return MakeRecAndEffects(font, paint, surfaceProps, deviceMatrix, scalerContextFlags,
- rec, effects, enableTypefaceFiltering);
+ return MakeRecAndEffects(
+ font, paint, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
+ SkScalerContextFlags::kNone, SkMatrix::I(), rec, effects, enableTypefaceFiltering);
}
static SkDescriptor* MakeDescriptorForPaths(SkFontID fontID,
@@ -364,9 +363,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 0f3ca2dcb1..477674fe06 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,9 +163,10 @@ SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(
return FindOrCreateStrikeExclusive(*desc, effects, *tf);
}
-SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeExclusive(const SkPaint& paint) {
+SkExclusiveStrikePtr SkStrikeCache::FindOrCreateStrikeWithNoDeviceExclusive(const SkPaint& paint) {
return FindOrCreateStrikeExclusive(
- paint, nullptr, kFakeGammaAndBoostContrast, nullptr);
+ paint, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
+ kFakeGammaAndBoostContrast, SkMatrix::I());
}
void SkStrikeCache::PurgeAll() {
diff --git a/src/core/SkStrikeCache.h b/src/core/SkStrikeCache.h
index 5d88126960..5abaee476e 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 FindOrCreateStrikeExclusive(const SkPaint& paint);
+ static ExclusiveStrikePtr FindOrCreateStrikeWithNoDeviceExclusive(const SkPaint& paint);
static std::unique_ptr<SkScalerContext> CreateScalerContext(
const SkDescriptor&, const SkScalerContextEffects&, const SkTypeface&);
diff --git a/src/core/SkSurfacePriv.h b/src/core/SkSurfacePriv.h
index a41b583f02..e86a6397d5 100644
--- a/src/core/SkSurfacePriv.h
+++ b/src/core/SkSurfacePriv.h
@@ -20,10 +20,6 @@ static inline SkSurfaceProps SkSurfacePropsCopyOrDefault(const SkSurfaceProps* p
}
}
-static inline SkPixelGeometry SkSurfacePropsDefaultPixelGeometry() {
- return SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType).pixelGeometry();
-}
-
constexpr size_t kIgnoreRowBytesValue = static_cast<size_t>(~0);
bool SkSurfaceValidateRasterInfo(const SkImageInfo&, size_t rb = kIgnoreRowBytesValue);
diff --git a/src/core/SkTypeface.cpp b/src/core/SkTypeface.cpp
index 00fe495926..96b61ce11e 100644
--- a/src/core/SkTypeface.cpp
+++ b/src/core/SkTypeface.cpp
@@ -14,6 +14,7 @@
#include "SkOTTable_OS_2.h"
#include "SkOnce.h"
#include "SkStream.h"
+#include "SkSurfacePriv.h"
#include "SkTypeface.h"
#include "SkTypefaceCache.h"
@@ -401,10 +402,7 @@ bool SkTypeface::onComputeBounds(SkRect* bounds) const {
SkScalerContextRec rec;
SkScalerContextEffects effects;
- const SkSurfaceProps* defaultProps = nullptr;
- const SkMatrix* noDeviceMatrix = nullptr;
- SkScalerContext::MakeRecAndEffectsUsingDefaultPaint(
- font, defaultProps, noDeviceMatrix, SkScalerContextFlags::kNone, &rec, &effects);
+ SkScalerContext::MakeRecAndEffectsFromFont(font, &rec, &effects);
SkAutoDescriptor ad;
SkScalerContextEffects noeffects;
diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp
index cc686f558a..e0351241d9 100644
--- a/src/gpu/text/GrTextBlob.cpp
+++ b/src/gpu/text/GrTextBlob.cpp
@@ -59,10 +59,10 @@ sk_sp<GrTextBlob> GrTextBlob::Make(int glyphCount, int runCount) {
}
SkExclusiveStrikePtr GrTextBlob::setupCache(int runIndex,
- const SkSurfaceProps& props,
- SkScalerContextFlags scalerContextFlags,
- const SkPaint& skPaint,
- const SkMatrix* viewMatrix) {
+ const SkPaint& skPaint,
+ const SkSurfaceProps& props,
+ SkScalerContextFlags scalerContextFlags,
+ 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 1cccaca8d2..f773d0b8ee 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 SkPaint& skPaint,
- const SkMatrix* viewMatrix);
+ 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 8f314084ca..da7afbf563 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, nullptr);
+ tmpPaint, props, SkScalerContextFlags::kFakeGammaAndBoostContrast, SkMatrix::I());
}
namespace {
diff --git a/src/xps/SkXPSDevice.cpp b/src/xps/SkXPSDevice.cpp
index eecfe8c06f..b067c4f905 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, nullptr);
+ paint, this->surfaceProps(),
+ SkScalerContextFlags::kNone, SkMatrix::I());
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, nullptr);
+ paint, this->surfaceProps(),
+ SkScalerContextFlags::kNone, SkMatrix::I());
// 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 d6ed10fe68..6e7160f841 100644
--- a/tests/SkRemoteGlyphCacheTest.cpp
+++ b/tests/SkRemoteGlyphCacheTest.cpp
@@ -14,6 +14,7 @@
#include "SkRemoteGlyphCacheImpl.h"
#include "SkStrikeCache.h"
#include "SkSurface.h"
+#include "SkSurfacePriv.h"
#include "SkTestEmptyTypeface.h"
#include "SkTextBlob.h"
#include "SkTypeface_remote.h"
@@ -118,12 +119,21 @@ SkTextBlobCacheDiffCanvas::Settings MakeSettings(GrContext* context) {
return settings;
}
+sk_sp<SkSurface> 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<SkTextBlob> blob, int width, int height, const SkPaint& paint,
GrContext* context, const SkMatrix* matrix = nullptr,
SkScalar x = 0) {
- const SkImageInfo info =
- SkImageInfo::Make(width, height, kN32_SkColorType, kPremul_SkAlphaType);
- auto surface = SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
+ auto surface = MakeSurface(width, height, context);
if (matrix) surface->getCanvas()->concat(*matrix);
surface->getCanvas()->drawTextBlob(blob.get(), x, 0, paint);
SkBitmap bitmap;
@@ -161,7 +171,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_StrikeSerialization, repor
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ auto props = FindSurfaceProps(ctxInfo.grContext());
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -402,7 +412,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsPath, reporter,
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ auto props = FindSurfaceProps(ctxInfo.grContext());
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -479,7 +489,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextAsMaskWithPathFall
auto serverBlob = make_blob_causing_fallback(serverTf, serverTf.get(), reporter);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ auto props = FindSurfaceProps(ctxInfo.grContext());
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0, 0, paint);
@@ -519,7 +529,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkRemoteGlyphCache_DrawTextXY, reporter, ctxI
int glyphCount = 10;
auto serverBlob = buildTextBlob(serverTf, glyphCount);
- const SkSurfaceProps props(SkSurfaceProps::kLegacyFontHost_InitType);
+ auto props = FindSurfaceProps(ctxInfo.grContext());
SkTextBlobCacheDiffCanvas cache_diff_canvas(10, 10, SkMatrix::I(), props, &server,
MakeSettings(ctxInfo.grContext()));
cache_diff_canvas.drawTextBlob(serverBlob.get(), 0.5, 0, paint);
@@ -648,7 +658,9 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
SkScalerContextRec rec;
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
- SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
+ SkScalerContext::MakeRecAndEffects(
+ font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
+ SkMatrix::I(), &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf);
@@ -666,7 +678,9 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
SkScalerContextRec rec;
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
- SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
+ SkScalerContext::MakeRecAndEffects(
+ font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
+ SkMatrix::I(), &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto testCache = strikeCache.findStrikeExclusive(*desc);
REPORTER_ASSERT(reporter, !(testCache == nullptr));
@@ -678,7 +692,10 @@ DEF_TEST(SkRemoteGlyphCache_SearchOfDesperation, reporter) {
SkScalerContextRec rec;
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kNone;
- SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
+ SkScalerContext::MakeRecAndEffects(
+ font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
+ SkMatrix::I(),
+ &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
testCache = strikeCache.findStrikeExclusive(*desc);
REPORTER_ASSERT(reporter, testCache == nullptr);
@@ -754,7 +771,9 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(serverTf);
- SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
+ SkScalerContext::MakeRecAndEffects(
+ font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
+ SkMatrix::I(), &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto context = serverTf->createScalerContext(effects, desc, false);
@@ -772,7 +791,9 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(clientTf);
- SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
+ SkScalerContext::MakeRecAndEffects(
+ font, paint, SkSurfacePropsCopyOrDefault(nullptr), flags,
+ SkMatrix::I(), &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto fallbackCache = strikeCache.findOrCreateStrikeExclusive(*desc, effects, *clientTf);
@@ -791,7 +812,7 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(serverTf);
auto* cacheState = server.getOrCreateCache(
- paint, SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType),
+ paint, SkSurfacePropsCopyOrDefault(nullptr),
SkMatrix::I(), flags, &effects);
cacheState->addGlyph(lostGlyphID, false);
@@ -809,7 +830,9 @@ DEF_TEST(SkRemoteGlyphCache_ReWriteGlyph, reporter) {
SkScalerContextEffects effects;
SkScalerContextFlags flags = SkScalerContextFlags::kFakeGammaAndBoostContrast;
paint.setTypeface(clientTf);
- SkScalerContext::MakeRecAndEffects(font, paint, nullptr, nullptr, flags, &rec, &effects, false);
+ SkScalerContext::MakeRecAndEffects(
+ font, paint, SkSurfaceProps(0, kUnknown_SkPixelGeometry), flags,
+ SkMatrix::I(), &rec, &effects, false);
auto desc = SkScalerContext::AutoDescriptorGivenRecAndEffects(rec, effects, &ad);
auto fallbackCache = strikeCache.findStrikeExclusive(*desc);