aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkMatrixPriv.h
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-10-17 09:11:04 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-10-17 17:30:12 +0000
commitfa2d604a7ded95a3ace905519b476129cd0fffcb (patch)
treed885e28a4f54375418d97c76ce668ffbc17cf9c0 /src/core/SkMatrixPriv.h
parent8580d51cd8cb733321978966621056fa38b7be8c (diff)
Make GPU backend triangulate rects such that they are rendered as tri strips rather than tri fans.
Right now when we turn rects into quads we use a vertex order compatible with a tri fan rather than a tri strip. I wanted it to be the case that the same code could be used to generate a non-indexed mesh for a single rect or indexed using the quad index buffer when batching. Triangle fanning is not available in all APIS (e.g. is emulated in ANGLE and not supported in Metal) so it seems better to use a triangle strip over a fan in the single rect case. Change-Id: I31eebd794e7328f4b39e3ec3377bf2ec556360ca Reviewed-on: https://skia-review.googlesource.com/60081 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/core/SkMatrixPriv.h')
-rw-r--r--src/core/SkMatrixPriv.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/core/SkMatrixPriv.h b/src/core/SkMatrixPriv.h
index ee6f8a153d..47a1d5f287 100644
--- a/src/core/SkMatrixPriv.h
+++ b/src/core/SkMatrixPriv.h
@@ -66,7 +66,7 @@ public:
}
}
- static void SetMappedRectFan(const SkMatrix& mx, const SkRect& rect, SkPoint quad[4]) {
+ static void SetMappedRectTriStrip(const SkMatrix& mx, const SkRect& rect, SkPoint quad[4]) {
SkMatrix::TypeMask tm = mx.getType();
SkScalar l = rect.fLeft;
SkScalar t = rect.fTop;
@@ -88,12 +88,9 @@ public:
r = sx * r + tx;
b = sy * b + ty;
}
- quad[0].set(l, t);
- quad[1].set(l, b);
- quad[2].set(r, b);
- quad[3].set(r, t);
+ quad[0].setRectTriStrip(l, t, r, b, sizeof(SkPoint));
} else {
- quad[0].setRectFan(l, t, r, b);
+ quad[0].setRectTriStrip(l, t, r, b, sizeof(SkPoint));
mx.mapPoints(quad, quad, 4);
}
}