aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-09-12 12:07:17 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-12 12:07:17 -0700
commit6ade6dd9910be25c15e25c90d76f8471ff23f62c (patch)
tree10dce4fb5c59f6637ec3a9491160e79fcd605a58 /src/gpu
parent2af83ac4f6c1b162e17ee70bc97c0553606d7f24 (diff)
Match Android framework's non-AA point and line offset
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/SkGpuDevice.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 1970711ac4..9ee71bc708 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -281,7 +281,7 @@ void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
}
// must be in SkCanvas::PointMode order
-static const GrPrimitiveType gPointMode2PrimtiveType[] = {
+static const GrPrimitiveType gPointMode2PrimitiveType[] = {
kPoints_GrPrimitiveType,
kLines_GrPrimitiveType,
kLineStrip_GrPrimitiveType
@@ -335,23 +335,42 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode,
return;
}
+ SkScalar scales[2];
+ bool isHairline = (0 == width) || (1 == width && draw.fMatrix->getMinMaxScales(scales) &&
+ SkScalarNearlyEqual(scales[0], 1.f) &&
+ SkScalarNearlyEqual(scales[1], 1.f));
// we only handle non-antialiased hairlines and paints without path effects or mask filters,
// else we let the SkDraw call our drawPath()
- if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() ||
+ if (!isHairline || paint.getPathEffect() || paint.getMaskFilter() ||
(paint.isAntiAlias() && needs_antialiasing(mode, count, pts))) {
draw.drawPoints(mode, count, pts, paint, true);
return;
}
+ GrPrimitiveType primitiveType = gPointMode2PrimitiveType[mode];
+
+ const SkMatrix* viewMatrix = draw.fMatrix;
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+ // This offsetting in device space matches the expectations of the Android framework for non-AA
+ // points and lines.
+ SkMatrix tempMatrix;
+ if (GrIsPrimTypeLines(primitiveType) || kPoints_GrPrimitiveType == primitiveType) {
+ tempMatrix = *viewMatrix;
+ static const SkScalar kOffset = 0.063f; // Just greater than 1/16.
+ tempMatrix.postTranslate(kOffset, kOffset);
+ viewMatrix = &tempMatrix;
+ }
+#endif
+
GrPaint grPaint;
- if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *draw.fMatrix, &grPaint)) {
+ if (!SkPaintToGrPaint(this->context(), fDrawContext.get(), paint, *viewMatrix, &grPaint)) {
return;
}
fDrawContext->drawVertices(fClip,
grPaint,
- *draw.fMatrix,
- gPointMode2PrimtiveType[mode],
+ *viewMatrix,
+ primitiveType,
SkToS32(count),
(SkPoint*)pts,
nullptr,