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 <bungeman@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2019-11-20 14:40:39 -05:00 committed by Skia Commit-Bot
parent 2885ac3fe4
commit 2984d2601e
3 changed files with 32 additions and 59 deletions

View File

@ -572,7 +572,7 @@ void GrTextBlob::processSourcePaths(const SkZip<SkGlyphVariant, SkPoint>& 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());
}
}

View File

@ -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<SkPath> 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

View File

@ -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;