From 2984d2601ed51a2c2aa32e87adbaff844c0cdcf7 Mon Sep 17 00:00:00 2001 From: Herb Derby Date: Wed, 20 Nov 2019 14:40:39 -0500 Subject: [PATCH] Remove device paths from SubRun The ability to have device paths was removed a while ago. Remove the code for device paths. Change-Id: I09418eaa464b040c7bb13eac2e167997363e49d1 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/255530 Reviewed-by: Ben Wagner Commit-Queue: Herb Derby --- src/core/SkGlyphRunPainter.cpp | 2 +- src/gpu/text/GrTextBlob.cpp | 80 ++++++++++++---------------------- src/gpu/text/GrTextBlob.h | 9 ++-- 3 files changed, 32 insertions(+), 59 deletions(-) diff --git a/src/core/SkGlyphRunPainter.cpp b/src/core/SkGlyphRunPainter.cpp index 4c7e277319..0fb699eac8 100644 --- a/src/core/SkGlyphRunPainter.cpp +++ b/src/core/SkGlyphRunPainter.cpp @@ -572,7 +572,7 @@ void GrTextBlob::processSourcePaths(const SkZip& drawab for (auto t : drawables) { const SkPath* path; SkPoint pos; std::tie(path, pos) = t; - run->appendPathGlyph(*path, pos, strikeSpec.strikeToSourceRatio(), false); + run->appendPathGlyph(*path, pos, strikeSpec.strikeToSourceRatio()); } } diff --git a/src/gpu/text/GrTextBlob.cpp b/src/gpu/text/GrTextBlob.cpp index 14f505511b..41736c0993 100644 --- a/src/gpu/text/GrTextBlob.cpp +++ b/src/gpu/text/GrTextBlob.cpp @@ -68,9 +68,8 @@ void GrTextBlob::Run::setupFont(const SkStrikeSpec& strikeSpec) { } } -void GrTextBlob::Run::appendPathGlyph(const SkPath& path, SkPoint position, - SkScalar scale, bool preTransformed) { - fPathGlyphs.push_back(PathGlyph(path, position.x(), position.y(), scale, preTransformed)); +void GrTextBlob::Run::appendPathGlyph(const SkPath& path, SkPoint position, SkScalar scale) { + fPathGlyphs.emplace_back(path, position.x(), position.y(), scale); } bool GrTextBlob::mustRegenerate(const SkPaint& paint, bool anyRunHasSubpixelPosition, @@ -242,62 +241,39 @@ void GrTextBlob::flush(GrTextTarget* target, const SkSurfaceProps& props, // TmpPath must be in the same scope as GrShape shape below. SkTLazy tmpPath; - // The glyph positions and glyph outlines are either in device space or in source - // space based on fPreTransformed. - if (!pathGlyph.fPreTransformed) { - // Positions and outlines are in source space. + // Positions and outlines are in source space. + ctm = viewMatrix; - ctm = viewMatrix; + SkMatrix pathMatrix = SkMatrix::MakeScale(pathGlyph.fScale, pathGlyph.fScale); - SkMatrix pathMatrix = SkMatrix::MakeScale(pathGlyph.fScale, pathGlyph.fScale); + // The origin for the blob may have changed, so figure out the delta. + SkVector originShift = SkPoint{x, y} - SkPoint{fInitialX, fInitialY}; - // The origin for the blob may have changed, so figure out the delta. - SkVector originShift = SkPoint{x, y} - SkPoint{fInitialX, fInitialY}; - - // Shift the original glyph location in source space to the position of the new - // blob. - pathMatrix.postTranslate(originShift.x() + pathGlyph.fX, - originShift.y() + pathGlyph.fY); - - // If there are shaders, blurs or styles, the path must be scaled into source - // space independently of the CTM. This allows the CTM to be correct for the - // different effects. - GrStyle style(runPaint); - bool scalePath = runPaint.getShader() - || style.applies() - || runPaint.getMaskFilter(); - if (!scalePath) { - // Scale can be applied to CTM -- no effects. - - ctm.preConcat(pathMatrix); - } else { - // Scale the outline into source space. - - // Transform the path form the normalized outline to source space. This - // way the CTM will remain the same so it can be used by the effects. - SkPath* sourceOutline = tmpPath.init(); - path->transform(pathMatrix, sourceOutline); - sourceOutline->setIsVolatile(true); - path = sourceOutline; - } + // Shift the original glyph location in source space to the position of the new + // blob. + pathMatrix.postTranslate(originShift.x() + pathGlyph.fX, + originShift.y() + pathGlyph.fY); + // If there are shaders, blurs or styles, the path must be scaled into source + // space independently of the CTM. This allows the CTM to be correct for the + // different effects. + GrStyle style(runPaint); + bool scalePath = runPaint.getShader() + || style.applies() + || runPaint.getMaskFilter(); + if (!scalePath) { + // Scale can be applied to CTM -- no effects. + ctm.preConcat(pathMatrix); } else { - // Positions and outlines are in device space. + // Scale the outline into source space. - SkPoint originalOrigin = {fInitialX, fInitialY}; - fInitialViewMatrix.mapPoints(&originalOrigin, 1); - - SkPoint newOrigin = {x, y}; - viewMatrix.mapPoints(&newOrigin, 1); - - // The origin shift in device space. - SkPoint originShift = newOrigin - originalOrigin; - - // Shift the original glyph location in device space to the position of the - // new blob. - ctm = SkMatrix::MakeTrans(originShift.x() + pathGlyph.fX, - originShift.y() + pathGlyph.fY); + // Transform the path form the normalized outline to source space. This + // way the CTM will remain the same so it can be used by the effects. + SkPath* sourceOutline = tmpPath.init(); + path->transform(pathMatrix, sourceOutline); + sourceOutline->setIsVolatile(true); + path = sourceOutline; } // TODO: we are losing the mutability of the path here diff --git a/src/gpu/text/GrTextBlob.h b/src/gpu/text/GrTextBlob.h index 8f13165340..7fd625e7c4 100644 --- a/src/gpu/text/GrTextBlob.h +++ b/src/gpu/text/GrTextBlob.h @@ -422,8 +422,7 @@ public: } // Appends a glyph to the blob as a path only. - void appendPathGlyph( - const SkPath& path, SkPoint position, SkScalar scale, bool preTransformed); + void appendPathGlyph(const SkPath& path, SkPoint position, SkScalar scale); // Append a glyph to the sub run taking care to switch the glyph if needed. void switchSubRunIfNeededAndAppendGlyph(GrGlyph* glyph, @@ -472,17 +471,15 @@ public: // Any glyphs that can't be rendered with the base or override descriptor // are rendered as paths struct PathGlyph { - PathGlyph(const SkPath& path, SkScalar x, SkScalar y, SkScalar scale, bool preXformed) + PathGlyph(const SkPath& path, SkScalar x, SkScalar y, SkScalar scale) : fPath(path) , fX(x) , fY(y) - , fScale(scale) - , fPreTransformed(preXformed) {} + , fScale(scale) { } SkPath fPath; SkScalar fX; SkScalar fY; SkScalar fScale; - bool fPreTransformed; }; SkSTArray<1, SubRun> fSubRunInfo;