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

Unified Diff: tests/GpuDrawPathTest.cpp

Issue 2342873002: Fix key computation for GrPaths (Closed)
Patch Set: more MSVS warnings 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 | « src/gpu/batches/GrStencilAndCoverPathRenderer.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/GpuDrawPathTest.cpp
diff --git a/tests/GpuDrawPathTest.cpp b/tests/GpuDrawPathTest.cpp
index c0b31f0737ab7a9283d0d7878eed19fe7d19d795..1a42a49efd99d2d7cc5707da7a08389e98dd0190 100644
--- a/tests/GpuDrawPathTest.cpp
+++ b/tests/GpuDrawPathTest.cpp
@@ -11,7 +11,7 @@
#include "GrContext.h"
#include "GrPath.h"
-#include "GrStyle.h"
+#include "GrShape.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
#include "SkColor.h"
@@ -92,21 +92,72 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(GpuDrawPath, reporter, ctxInfo) {
}
DEF_GPUTEST(GrPathKeys, reporter, /*factory*/) {
- // Keys should not ignore conic weights.
- SkPath path1, path2;
- path1.setIsVolatile(true);
- path2.setIsVolatile(true);
- SkPoint p0 = SkPoint::Make(100, 0);
- SkPoint p1 = SkPoint::Make(100, 100);
-
- path1.conicTo(p0, p1, .5f);
- path2.conicTo(p0, p1, .7f);
-
- bool isVolatile;
- GrUniqueKey key1, key2;
- GrPath::ComputeKey(path1, GrStyle::SimpleFill(), &key1, &isVolatile);
- GrPath::ComputeKey(path2, GrStyle::SimpleFill(), &key2, &isVolatile);
- REPORTER_ASSERT(reporter, key1 != key2);
+ SkPaint strokePaint;
+ strokePaint.setStyle(SkPaint::kStroke_Style);
+ strokePaint.setStrokeWidth(10.f);
+ GrStyle styles[] = {
+ GrStyle::SimpleFill(),
+ GrStyle::SimpleHairline(),
+ GrStyle(strokePaint)
+ };
+
+ for (const GrStyle& style : styles) {
+ // Keys should not ignore conic weights.
+ SkPath path1, path2;
+ path1.setIsVolatile(true);
+ path2.setIsVolatile(true);
+ SkPoint p0 = SkPoint::Make(100, 0);
+ SkPoint p1 = SkPoint::Make(100, 100);
+
+ path1.conicTo(p0, p1, .5f);
+ path2.conicTo(p0, p1, .7f);
+
+ bool isVolatile;
+ GrUniqueKey key1, key2;
+ // Even though the paths are marked volatile, they should have keys based on the path data
+ // because they have a small amount of data.
+ GrPath::ComputeKey(GrShape(path1, GrStyle::SimpleFill()), &key1, &isVolatile);
+ REPORTER_ASSERT(reporter, !isVolatile);
+ REPORTER_ASSERT(reporter, key1.isValid());
+ GrPath::ComputeKey(GrShape(path2, GrStyle::SimpleFill()), &key2, &isVolatile);
+ REPORTER_ASSERT(reporter, !isVolatile);
+ REPORTER_ASSERT(reporter, key1.isValid());
+ REPORTER_ASSERT(reporter, key1 != key2);
+
+ // Ensure that recreating the GrShape doesn't change the key.
+ {
+ GrUniqueKey tempKey;
+ GrPath::ComputeKey(GrShape(path1, GrStyle::SimpleFill()), &tempKey, &isVolatile);
+ REPORTER_ASSERT(reporter, key1 == tempKey);
+ }
+
+ // Try a large path that is too big to be keyed off its data.
+ SkPath path3;
+ SkPath path4;
+ for (int i = 0; i < 1000; ++i) {
+ SkScalar s = SkIntToScalar(i);
+ path3.conicTo(s, 3.f * s / 4, s + 1.f, s, 0.5f + s / 2000.f);
+ path4.conicTo(s, 3.f * s / 4, s + 1.f, s, 0.3f + s / 2000.f);
+ }
+
+ GrUniqueKey key3, key4;
+ // These aren't marked volatile and so should have keys
+ GrPath::ComputeKey(GrShape(path3, style), &key3, &isVolatile);
+ REPORTER_ASSERT(reporter, !isVolatile);
+ REPORTER_ASSERT(reporter, key3.isValid());
+ GrPath::ComputeKey(GrShape(path4, style), &key4, &isVolatile);
+ REPORTER_ASSERT(reporter, !isVolatile);
+ REPORTER_ASSERT(reporter, key4.isValid());
+ REPORTER_ASSERT(reporter, key3 != key4);
+
+ {
+ GrUniqueKey tempKey;
+ path3.setIsVolatile(true);
+ GrPath::ComputeKey(GrShape(path3, style), &key1, &isVolatile);
+ REPORTER_ASSERT(reporter, isVolatile);
+ REPORTER_ASSERT(reporter, !tempKey.isValid());
+ }
+ }
}
#endif
« no previous file with comments | « src/gpu/batches/GrStencilAndCoverPathRenderer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698