Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1286)

Unified Diff: src/gpu/SkGpuDevice.cpp

Issue 2336623002: Match Android framework's non-AA point and line offset (Closed)
Patch Set: fix speeling Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/SkGpuDevice.cpp
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 4b7743123993c6369c19006da9315066b97ff676..4bef603e1d9640da9982106510ad572f8e211e18 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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698