Skip to content

Commit

Permalink
Make path position handling consistant with SDF
Browse files Browse the repository at this point in the history
Remove using origin from ARGBfallback; it was never used. Rename position to glyphPos
and calculate only once like SDF painting.

Remove finite check for positions. This is handle latter in the stack. This check is really only done
on device coordinates. All the coordinates in the routine are source space.

Change-Id: I84db6b7298a8fa98faeac9b2227abd3d063b4e28
Reviewed-on: https://skia-review.googlesource.com/c/173430
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
  • Loading branch information
herbderby authored and Skia Commit-Bot committed Nov 30, 2018
1 parent c337a63 commit dfd9c79
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
28 changes: 13 additions & 15 deletions src/core/SkGlyphRunPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ void SkGlyphRunListPainter::drawForBitmapDevice(
// scale factor is used to increase the size of the destination rectangles. The destination
// rectangles are then scaled, rotated, etc. by the GPU using the view matrix.
void SkGlyphRunListPainter::processARGBFallback(
SkScalar maxGlyphDimension, const SkPaint& runPaint, SkPoint origin,
const SkMatrix& viewMatrix, SkScalar textScale, ARGBFallback argbFallback) {
SkScalar maxGlyphDimension, const SkPaint& runPaint, const SkMatrix& viewMatrix,
SkScalar textScale, ARGBFallback argbFallback) {
SkASSERT(!fARGBGlyphsIDs.empty());

SkScalar maxScale = viewMatrix.getMaxScale();
Expand Down Expand Up @@ -332,23 +332,21 @@ void SkGlyphRunListPainter::drawGlyphRunAsPathWithARGBFallback(

const SkPoint* positionCursor = glyphRun.positions().data();
for (auto glyphID : glyphRun.glyphsIDs()) {
SkPoint position = *positionCursor++;
if (SkScalarsAreFinite(position.x(), position.y())) {
const SkGlyph& glyph = pathCache->getGlyphMetrics(glyphID, {0, 0});
if (glyph.fMaskFormat != SkMask::kARGB32_Format) {
perPath(glyph, origin + position);
} else {
SkScalar largestDimension = std::max(glyph.fWidth, glyph.fHeight);
maxFallbackDimension = std::max(maxFallbackDimension, largestDimension);
fARGBGlyphsIDs.push_back(glyphID);
fARGBPositions.push_back(position);
}
SkPoint glyphPos = origin + *positionCursor++;
const SkGlyph& glyph = pathCache->getGlyphMetrics(glyphID, {0, 0});
if (glyph.fMaskFormat != SkMask::kARGB32_Format) {
perPath(glyph, glyphPos);
} else {
SkScalar largestDimension = std::max(glyph.fWidth, glyph.fHeight);
maxFallbackDimension = std::max(maxFallbackDimension, largestDimension);
fARGBGlyphsIDs.push_back(glyphID);
fARGBPositions.push_back(glyphPos);
}
}

if (!fARGBGlyphsIDs.empty()) {
this->processARGBFallback(
maxFallbackDimension, glyphRun.paint(), origin, viewMatrix, textScale,
maxFallbackDimension, glyphRun.paint(), viewMatrix, textScale,
std::move(argbFallback));

}
Expand Down Expand Up @@ -422,7 +420,7 @@ void SkGlyphRunListPainter::drawGlyphRunAsSDFWithARGBFallback(

if (!fARGBGlyphsIDs.empty()) {
this->processARGBFallback(
maxFallbackDimension, glyphRun.paint(), origin, viewMatrix, textScale,
maxFallbackDimension, glyphRun.paint(), viewMatrix, textScale,
std::move(argbFallback));
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/SkGlyphRunPainter.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class SkGlyphRunListPainter {
void ensureBitmapBuffers(size_t runSize);

void processARGBFallback(
SkScalar maxGlyphDimension, const SkPaint& runPaint, SkPoint origin,
const SkMatrix& viewMatrix, SkScalar textScale, ARGBFallback argbFallback);
SkScalar maxGlyphDimension, const SkPaint& runPaint, const SkMatrix& viewMatrix,
SkScalar textScale, ARGBFallback argbFallback);

// The props as on the actual device.
const SkSurfaceProps fDeviceProps;
Expand Down

0 comments on commit dfd9c79

Please sign in to comment.