pathProcessing: switch to explicit strikeToSourceScale
Change-Id: Icf7947588e83f736ad9963f79b6215ea20b4f2d5 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/467136 Commit-Queue: Herb Derby <herb@google.com> Reviewed-by: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
f2b5dc8aaf
commit
37afdbc22e
@ -100,8 +100,8 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
|
||||
|
||||
if (SkStrikeSpec::ShouldDrawAsPath(paint, runFont, deviceMatrix)) {
|
||||
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakePath(
|
||||
runFont, paint, props, fScalerContextFlags);
|
||||
auto [strikeSpec, strikeToSourceScale] =
|
||||
SkStrikeSpec::MakePath(runFont, paint, props, fScalerContextFlags);
|
||||
|
||||
auto strike = strikeSpec.findOrCreateStrike();
|
||||
|
||||
@ -115,7 +115,7 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
|
||||
pathPaint.setAntiAlias(runFont.hasSomeAntiAliasing());
|
||||
|
||||
bitmapDevice->paintPaths(
|
||||
&fDrawable, strikeSpec.strikeToSourceRatio(), drawOrigin, pathPaint);
|
||||
&fDrawable, strikeToSourceScale, drawOrigin, pathPaint);
|
||||
}
|
||||
if (!fRejects.source().empty() && !deviceMatrix.hasPerspective()) {
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakeMask(
|
||||
@ -305,8 +305,8 @@ void SkGlyphRunListPainter::processGlyphRun(const SkGlyphRun& glyphRun,
|
||||
SkScalar maxDimensionInSourceSpace = 0.0;
|
||||
if (!fRejects.source().empty()) {
|
||||
// Path case - handle big things without color and that have a path.
|
||||
SkStrikeSpec strikeSpec = SkStrikeSpec::MakePath(
|
||||
runFont, runPaint, fDeviceProps, fScalerContextFlags);
|
||||
auto [strikeSpec, strikeToSourceScale] =
|
||||
SkStrikeSpec::MakePath(runFont, runPaint, fDeviceProps, fScalerContextFlags);
|
||||
|
||||
#if defined(SK_TRACE_GLYPH_RUN_PROCESS)
|
||||
msg.appendf(" Path case:\n%s", strikeSpec.dump().c_str());
|
||||
@ -321,13 +321,13 @@ void SkGlyphRunListPainter::processGlyphRun(const SkGlyphRun& glyphRun,
|
||||
#endif
|
||||
strike->prepareForPathDrawing(&fDrawable, &fRejects);
|
||||
fRejects.flipRejectsToSource();
|
||||
maxDimensionInSourceSpace =
|
||||
fRejects.rejectedMaxDimension() * strikeSpec.strikeToSourceRatio();
|
||||
maxDimensionInSourceSpace = fRejects.rejectedMaxDimension() * strikeToSourceScale;
|
||||
|
||||
if (process && !fDrawable.drawableIsEmpty()) {
|
||||
// processSourcePaths must be called even if there are no glyphs to make sure
|
||||
// runs are set correctly.
|
||||
process->processSourcePaths(fDrawable.drawable(), runFont, strikeSpec);
|
||||
process->processSourcePaths(
|
||||
fDrawable.drawable(), runFont, strikeSpec, strikeToSourceScale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +147,8 @@ public:
|
||||
|
||||
virtual void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkFont& runFont,
|
||||
const SkStrikeSpec& strikeSpec) = 0;
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale) = 0;
|
||||
|
||||
virtual void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
|
@ -27,9 +27,10 @@ SkStrikeSpec SkStrikeSpec::MakeMask(const SkFont& font, const SkPaint& paint,
|
||||
return SkStrikeSpec(font, paint, surfaceProps, scalerContextFlags, deviceMatrix, 1);
|
||||
}
|
||||
|
||||
SkStrikeSpec SkStrikeSpec::MakePath(const SkFont& font, const SkPaint& paint,
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
SkScalerContextFlags scalerContextFlags) {
|
||||
std::tuple<SkStrikeSpec, SkScalar> SkStrikeSpec::MakePath(
|
||||
const SkFont& font, const SkPaint& paint,
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
SkScalerContextFlags scalerContextFlags) {
|
||||
|
||||
// setup our std runPaint, in hopes of getting hits in the cache
|
||||
SkPaint pathPaint{paint};
|
||||
@ -42,8 +43,9 @@ SkStrikeSpec SkStrikeSpec::MakePath(const SkFont& font, const SkPaint& paint,
|
||||
// The sub-pixel position will always happen when transforming to the screen.
|
||||
pathFont.setSubpixel(false);
|
||||
|
||||
return SkStrikeSpec(pathFont, pathPaint, surfaceProps, scalerContextFlags,
|
||||
SkMatrix::I(), strikeToSourceRatio);
|
||||
return {SkStrikeSpec(pathFont, pathPaint, surfaceProps, scalerContextFlags,
|
||||
SkMatrix::I(), strikeToSourceRatio),
|
||||
strikeToSourceRatio};
|
||||
}
|
||||
|
||||
SkStrikeSpec SkStrikeSpec::MakeSourceFallback(
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
const SkMatrix& deviceMatrix);
|
||||
|
||||
// Create a strike spec for path style cache entries.
|
||||
static SkStrikeSpec MakePath(
|
||||
static std::tuple<SkStrikeSpec, SkScalar> MakePath(
|
||||
const SkFont& font,
|
||||
const SkPaint& paint,
|
||||
const SkSurfaceProps& surfaceProps,
|
||||
|
@ -172,6 +172,7 @@ class PathSubRun final : public GrSubRun {
|
||||
public:
|
||||
PathSubRun(bool isAntiAliased,
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrTextBlob& blob,
|
||||
SkSpan<PathGlyph> paths,
|
||||
std::unique_ptr<PathGlyph[], GrSubRunAllocator::ArrayDestroyer> pathData);
|
||||
@ -189,6 +190,7 @@ public:
|
||||
static GrSubRunOwner Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
bool isAntiAliased,
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrTextBlob& blob,
|
||||
GrSubRunAllocator* alloc);
|
||||
|
||||
@ -201,17 +203,20 @@ private:
|
||||
|
||||
const bool fIsAntiAliased;
|
||||
const SkStrikeSpec fStrikeSpec;
|
||||
const SkScalar fStrikeToSourceScale;
|
||||
const SkSpan<const PathGlyph> fPaths;
|
||||
const std::unique_ptr<PathGlyph[], GrSubRunAllocator::ArrayDestroyer> fPathData;
|
||||
};
|
||||
|
||||
PathSubRun::PathSubRun(bool isAntiAliased,
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrTextBlob& blob,
|
||||
SkSpan<PathGlyph> paths,
|
||||
std::unique_ptr<PathGlyph[], GrSubRunAllocator::ArrayDestroyer> pathData)
|
||||
: fIsAntiAliased{isAntiAliased}
|
||||
, fStrikeSpec{strikeSpec}
|
||||
, fStrikeToSourceScale{strikeToSourceScale}
|
||||
, fPaths{paths}
|
||||
, fPathData{std::move(pathData)} { }
|
||||
|
||||
@ -235,8 +240,7 @@ void PathSubRun::draw(const GrClip* clip,
|
||||
|
||||
// Calculate the matrix that maps the path glyphs from their size in the strike to
|
||||
// the graphics source space.
|
||||
SkScalar scale = this->fStrikeSpec.strikeToSourceRatio();
|
||||
SkMatrix strikeToSource = SkMatrix::Scale(scale, scale);
|
||||
SkMatrix strikeToSource = SkMatrix::Scale(fStrikeToSourceScale, fStrikeToSourceScale);
|
||||
strikeToSource.postTranslate(drawOrigin.x(), drawOrigin.y());
|
||||
if (!needsExactCTM) {
|
||||
for (const auto& pathPos : fPaths) {
|
||||
@ -247,8 +251,8 @@ void PathSubRun::draw(const GrClip* clip,
|
||||
SkPreConcatMatrixProvider strikeToDevice(viewMatrix, pathMatrix);
|
||||
|
||||
GrStyledShape shape(path, paint);
|
||||
GrBlurUtils::drawShapeWithMaskFilter(sdc->recordingContext(), sdc, clip, runPaint,
|
||||
strikeToDevice, shape);
|
||||
GrBlurUtils::drawShapeWithMaskFilter(
|
||||
sdc->recordingContext(), sdc, clip, runPaint, strikeToDevice, shape);
|
||||
}
|
||||
} else {
|
||||
// Transform the path to device because the deviceMatrix must be unchanged to
|
||||
@ -277,6 +281,7 @@ bool PathSubRun::canReuse(const SkPaint& paint, const SkMatrix& drawMatrix) cons
|
||||
GrSubRunOwner PathSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
bool isAntiAliased,
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale,
|
||||
const GrTextBlob& blob,
|
||||
GrSubRunAllocator* alloc) {
|
||||
auto pathData = alloc->makeUniqueArray<PathGlyph>(
|
||||
@ -288,7 +293,7 @@ GrSubRunOwner PathSubRun::Make(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
SkSpan<PathGlyph> paths{pathData.get(), drawables.size()};
|
||||
|
||||
return alloc->makeUnique<PathSubRun>(
|
||||
isAntiAliased, strikeSpec, blob, paths, std::move(pathData));
|
||||
isAntiAliased, strikeSpec, strikeToSourceScale, blob, paths, std::move(pathData));
|
||||
}
|
||||
|
||||
GrAtlasSubRun* PathSubRun::testingOnly_atlasSubRun() {
|
||||
@ -1605,10 +1610,12 @@ void GrTextBlob::processDeviceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawab
|
||||
|
||||
void GrTextBlob::processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkFont& runFont,
|
||||
const SkStrikeSpec& strikeSpec) {
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale) {
|
||||
fSubRunList.append(PathSubRun::Make(drawables,
|
||||
has_some_antialiasing(runFont),
|
||||
strikeSpec,
|
||||
strikeToSourceScale,
|
||||
*this,
|
||||
&fAlloc));
|
||||
}
|
||||
@ -2339,7 +2346,8 @@ void GrSubRunNoCachePainter::processSourceMasks(
|
||||
|
||||
void GrSubRunNoCachePainter::processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkFont& runFont,
|
||||
const SkStrikeSpec& strikeSpec) {
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale) {
|
||||
SkASSERT(!drawables.empty());
|
||||
SkPoint drawOrigin = fGlyphRunList.origin();
|
||||
const SkPaint& drawPaint = fPaint;
|
||||
@ -2356,8 +2364,7 @@ void GrSubRunNoCachePainter::processSourcePaths(const SkZip<SkGlyphVariant, SkPo
|
||||
|
||||
// Calculate the matrix that maps the path glyphs from their size in the strike to
|
||||
// the graphics source space.
|
||||
SkScalar scale = strikeSpec.strikeToSourceRatio();
|
||||
SkMatrix strikeToSource = SkMatrix::Scale(scale, scale);
|
||||
SkMatrix strikeToSource = SkMatrix::Scale(strikeToSourceScale, strikeToSourceScale);
|
||||
strikeToSource.postTranslate(drawOrigin.x(), drawOrigin.y());
|
||||
if (!needsExactCTM) {
|
||||
for (auto [variant, pos] : drawables) {
|
||||
|
@ -256,7 +256,8 @@ private:
|
||||
const SkStrikeSpec& strikeSpec) override;
|
||||
void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkFont& runFont,
|
||||
const SkStrikeSpec& strikeSpec) override;
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale) override;
|
||||
void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkStrikeSpec& strikeSpec,
|
||||
const SkFont& runFont,
|
||||
@ -305,7 +306,8 @@ public:
|
||||
void processSourceMasks(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkStrikeSpec& strikeSpec) override;
|
||||
void processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkFont& runFont, const SkStrikeSpec& strikeSpec) override;
|
||||
const SkFont& runFont, const SkStrikeSpec& strikeSpec,
|
||||
SkScalar strikeToSourceScale) override;
|
||||
void processSourceSDFT(const SkZip<SkGlyphVariant, SkPoint>& drawables,
|
||||
const SkStrikeSpec& strikeSpec, const SkFont& runFont,
|
||||
SkScalar minScale, SkScalar maxScale) override;
|
||||
|
Loading…
Reference in New Issue
Block a user