Move source space fallback strike calculations to SkStrikeSpecStorage
This will move the cache to source ration onto the SkStrikeSpecStorage instead of passing it along as an extra parameter. Change-Id: Ie19665c8cd8f02798f9ea75d421a4c9337eb1f37 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/216358 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
parent
633db4db76
commit
bfa8767bb2
@ -339,29 +339,8 @@ 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.
|
||||
|
||||
// Subtract 2 to account for the bilerp pad around the glyph
|
||||
SkScalar maxAtlasDimension = SkStrikeCommon::kSkSideTooBigForAtlas - 2;
|
||||
|
||||
SkScalar runFontTextSize = runFont.getSize();
|
||||
|
||||
// Scale the text size down so the long side of all the glyphs will fit in the atlas.
|
||||
SkScalar fallbackTextSize = SkScalarFloorToScalar(
|
||||
(maxAtlasDimension / maxSourceGlyphDimension) * runFontTextSize);
|
||||
|
||||
SkFont fallbackFont{runFont};
|
||||
fallbackFont.setSize(fallbackTextSize);
|
||||
|
||||
// No sub-pixel needed. The transform to the screen will take care of sub-pixel positioning.
|
||||
fallbackFont.setSubpixel(false);
|
||||
|
||||
// The scale factor to go from strike size to the source size for glyphs.
|
||||
SkScalar fallbackTextScale = runFontTextSize / fallbackTextSize;
|
||||
|
||||
SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeMask(fallbackFont,
|
||||
runPaint,
|
||||
fDeviceProps,
|
||||
fScalerContextFlags,
|
||||
SkMatrix::I());
|
||||
SkStrikeSpecStorage strikeSpec = SkStrikeSpecStorage::MakeSourceFallback(
|
||||
runFont, runPaint, fDeviceProps, fScalerContextFlags, maxSourceGlyphDimension);
|
||||
|
||||
SkScopedStrike strike = strikeSpec.findOrCreateScopedStrike(fStrikeCache);
|
||||
|
||||
@ -376,7 +355,6 @@ void SkGlyphRunListPainter::processARGBFallback(SkScalar maxSourceGlyphDimension
|
||||
process->processSourceFallback(
|
||||
glyphPosSpan,
|
||||
strikeSpec,
|
||||
fallbackTextScale,
|
||||
viewMatrix.hasPerspective());
|
||||
}
|
||||
}
|
||||
@ -901,7 +879,6 @@ void GrTextBlob::processSourceSDFT(SkSpan<const SkGlyphPos> masks,
|
||||
|
||||
void GrTextBlob::processSourceFallback(SkSpan<const SkGlyphPos> masks,
|
||||
const SkStrikeSpecStorage& strikeSpec,
|
||||
SkScalar strikeToSourceRatio,
|
||||
bool hasW) {
|
||||
Run* run = this->currentRun();
|
||||
|
||||
@ -914,7 +891,7 @@ void GrTextBlob::processSourceFallback(SkSpan<const SkGlyphPos> masks,
|
||||
run->setupFont(strikeSpec);
|
||||
for (const auto& mask : masks) {
|
||||
run->appendSourceSpaceGlyph
|
||||
(grStrike, *mask.glyph, mask.position, strikeToSourceRatio);
|
||||
(grStrike, *mask.glyph, mask.position, strikeSpec.strikeToSourceRatio());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,12 +160,8 @@ public:
|
||||
SkScalar maxScale,
|
||||
bool hasWCoord) = 0;
|
||||
|
||||
// While strikeSpec has .strikeToSourceRatio(), it should be ignored in favor of the argument.
|
||||
// The fallback code currently calculates all this itself.
|
||||
// TODO: move into strike spec?
|
||||
virtual void processSourceFallback(SkSpan<const SkGlyphPos> masks,
|
||||
const SkStrikeSpecStorage& strikeSpec,
|
||||
SkScalar strikeToSourceRatio,
|
||||
bool hasW) = 0;
|
||||
|
||||
virtual void processDeviceFallback(SkSpan<const SkGlyphPos> masks,
|
||||
|
@ -43,6 +43,37 @@ SkStrikeSpecStorage SkStrikeSpecStorage::MakePath(const SkFont& font, const SkPa
|
||||
return storage;
|
||||
}
|
||||
|
||||
SkStrikeSpecStorage SkStrikeSpecStorage::MakeSourceFallback(
|
||||
const SkFont& font,
|
||||
const SkPaint& paint,
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
SkScalerContextFlags scalerContextFlags,
|
||||
SkScalar maxSourceGlyphDimension) {
|
||||
SkStrikeSpecStorage storage;
|
||||
|
||||
// Subtract 2 to account for the bilerp pad around the glyph
|
||||
SkScalar maxAtlasDimension = SkStrikeCommon::kSkSideTooBigForAtlas - 2;
|
||||
|
||||
SkScalar runFontTextSize = font.getSize();
|
||||
|
||||
// Scale the text size down so the long side of all the glyphs will fit in the atlas.
|
||||
SkScalar fallbackTextSize = SkScalarFloorToScalar(
|
||||
(maxAtlasDimension / maxSourceGlyphDimension) * runFontTextSize);
|
||||
|
||||
SkFont fallbackFont{font};
|
||||
fallbackFont.setSize(fallbackTextSize);
|
||||
|
||||
// No sub-pixel needed. The transform to the screen will take care of sub-pixel positioning.
|
||||
fallbackFont.setSubpixel(false);
|
||||
|
||||
// The scale factor to go from strike size to the source size for glyphs.
|
||||
storage.fStrikeToSourceRatio = runFontTextSize / fallbackTextSize;
|
||||
|
||||
storage.commonSetup(fallbackFont, paint, surfaceProps, scalerContextFlags, SkMatrix::I());
|
||||
|
||||
return storage;
|
||||
}
|
||||
|
||||
SkStrikeSpecStorage SkStrikeSpecStorage::MakeCanonicalized(
|
||||
const SkFont& font, const SkPaint* paint) {
|
||||
SkStrikeSpecStorage storage;
|
||||
|
@ -40,6 +40,12 @@ public:
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
SkScalerContextFlags scalerContextFlags);
|
||||
|
||||
static SkStrikeSpecStorage 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(
|
||||
const SkFont& font, const SkPaint* paint = nullptr);
|
||||
|
@ -535,7 +535,6 @@ private:
|
||||
|
||||
void processSourceFallback(SkSpan<const SkGlyphPos> masks,
|
||||
const SkStrikeSpecStorage& strikeSpec,
|
||||
SkScalar strikeToSourceRatio,
|
||||
bool hasW) override;
|
||||
|
||||
void processDeviceFallback(SkSpan<const SkGlyphPos> masks,
|
||||
|
Loading…
Reference in New Issue
Block a user