aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
authorGravatar fmalita <fmalita@chromium.org>2015-11-18 14:07:13 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-11-18 14:07:13 -0800
commitf9b1577d763988ebc043ddabf80674f71571ecff (patch)
treebee79110fb74f9b061794a1892f3eb6a82b6af3d /src/gpu
parentc8e8fc6e98e9272293fcf24d53428ddd6129b011 (diff)
Fix NVPR assert for equivalent ovals
For oval paths, GrPath ignores the point order and only uses the bounds when building its key. This is problematic because 1) point order is important when dashing 2) GrStencilAndCoverPathRenderer asserts that the lookup SkPath is equal to the cached SkPath - which is not the case for ovals with different directions/different point order. With this CL we no longer use the reduced oval key when dashing, and instead fall through to the more general path cases. The assert is adjusted to accommodate "equivalent" ovals (when not dashing). Also re-enabled & updated the GpuDrawPath unit test (disabled in https://codereview.chromium.org/1456463003/, presumably due to the use of uninitialized SkRects). R=bsalomon@google.com,robertphillips@google.com,cdalton@nvidia.com Review URL: https://codereview.chromium.org/1457073002
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/GrPath.cpp20
-rw-r--r--src/gpu/GrPath.h4
2 files changed, 20 insertions, 4 deletions
diff --git a/src/gpu/GrPath.cpp b/src/gpu/GrPath.cpp
index 4e1119dfbb..8ac356dd2d 100644
--- a/src/gpu/GrPath.cpp
+++ b/src/gpu/GrPath.cpp
@@ -36,7 +36,8 @@ inline static bool compute_key_for_line_path(const SkPath& path, const GrStrokeI
inline static bool compute_key_for_oval_path(const SkPath& path, const GrStrokeInfo& stroke,
GrUniqueKey* key) {
SkRect rect;
- if (!path.isOval(&rect)) {
+ // Point order is significant when dashing, so we cannot devolve to a rect key.
+ if (stroke.isDashed() || !path.isOval(&rect)) {
return false;
}
static_assert((sizeof(rect) % sizeof(uint32_t)) == 0 && sizeof(rect) > sizeof(uint32_t),
@@ -171,3 +172,20 @@ void GrPath::ComputeKey(const SkPath& path, const GrStrokeInfo& stroke, GrUnique
*outIsVolatile = path.isVolatile();
}
+#ifdef SK_DEBUG
+bool GrPath::isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) const {
+ if (!fStroke.hasEqualEffect(stroke)) {
+ return false;
+ }
+
+ // We treat same-rect ovals as identical - but only when not dashing.
+ SkRect ovalBounds;
+ if (!fStroke.isDashed() && fSkPath.isOval(&ovalBounds)) {
+ SkRect otherOvalBounds;
+ return path.isOval(&otherOvalBounds) && ovalBounds == otherOvalBounds;
+ }
+
+ return fSkPath == path;
+}
+#endif
+
diff --git a/src/gpu/GrPath.h b/src/gpu/GrPath.h
index f74baf317d..2edfd4cb5e 100644
--- a/src/gpu/GrPath.h
+++ b/src/gpu/GrPath.h
@@ -36,9 +36,7 @@ public:
const SkRect& getBounds() const { return fBounds; }
#ifdef SK_DEBUG
- bool isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) {
- return fSkPath == path && fStroke.hasEqualEffect(stroke);
- }
+ bool isEqualTo(const SkPath& path, const GrStrokeInfo& stroke) const;
#endif
protected: