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

Unified Diff: tests/StrokeTest.cpp

Issue 1130153002: Fix SkStrokeRec == to report true for all fills (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: the testcase had some doubles Created 5 years, 7 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/GrPath.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/StrokeTest.cpp
diff --git a/tests/StrokeTest.cpp b/tests/StrokeTest.cpp
index b8abbd3a8a7ecf79f46649668287e1273401da25..43b293fc120e324817b4f363c07a0b29738480f0 100644
--- a/tests/StrokeTest.cpp
+++ b/tests/StrokeTest.cpp
@@ -9,6 +9,7 @@
#include "SkPath.h"
#include "SkRect.h"
#include "SkStroke.h"
+#include "SkStrokeRec.h"
#include "Test.h"
static bool equal(const SkRect& a, const SkRect& b) {
@@ -84,7 +85,83 @@ static void test_strokerect(skiatest::Reporter* reporter) {
}
}
+static void test_strokerec_equality(skiatest::Reporter* reporter) {
+ {
+ SkStrokeRec s1(SkStrokeRec::kFill_InitStyle);
+ SkStrokeRec s2(SkStrokeRec::kFill_InitStyle);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+
+ // Test that style mismatch is detected.
+ s2.setHairlineStyle();
+ REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
+
+ s1.setHairlineStyle();
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+
+ // ResScale is not part of equality.
+ s1.setResScale(2.1f);
+ s2.setResScale(1.2f);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+ s1.setFillStyle();
+ s2.setFillStyle();
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+ s1.setStrokeStyle(1.0f, false);
+ s2.setStrokeStyle(1.0f, false);
+ s1.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.9f);
+ s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.9f);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+ }
+
+ // Stroke parameters on fill or hairline style are not part of equality.
+ {
+ SkStrokeRec s1(SkStrokeRec::kFill_InitStyle);
+ SkStrokeRec s2(SkStrokeRec::kFill_InitStyle);
+ for (int i = 0; i < 2; ++i) {
+ s1.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.9f);
+ s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.1f);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+ s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kBevel_Join, 2.9f);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+ s2.setStrokeParams(SkPaint::kRound_Cap, SkPaint::kRound_Join, 2.9f);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+ s1.setHairlineStyle();
+ s2.setHairlineStyle();
+ }
+ }
+
+ // Stroke parameters on stroke style are part of equality.
+ {
+ SkStrokeRec s1(SkStrokeRec::kFill_InitStyle);
+ SkStrokeRec s2(SkStrokeRec::kFill_InitStyle);
+ s1.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.9f);
+ s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.9f);
+ s1.setStrokeStyle(1.0f, false);
+
+ s2.setStrokeStyle(1.0f, true);
+ REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
+
+ s2.setStrokeStyle(2.1f, false);
+ REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
+
+ s2.setStrokeStyle(1.0f, false);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+
+ s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kRound_Join, 2.1f);
+ REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
+ s2.setStrokeParams(SkPaint::kButt_Cap, SkPaint::kBevel_Join, 2.9f);
+ REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
+ s2.setStrokeParams(SkPaint::kRound_Cap, SkPaint::kRound_Join, 2.9f);
+ REPORTER_ASSERT(reporter, !s1.hasEqualEffect(s2));
+
+ // Sets fill.
+ s1.setStrokeStyle(0.0f, true);
+ s2.setStrokeStyle(0.0f, true);
+ REPORTER_ASSERT(reporter, s1.hasEqualEffect(s2));
+ }
+}
+
DEF_TEST(Stroke, reporter) {
test_strokecubic(reporter);
test_strokerect(reporter);
+ test_strokerec_equality(reporter);
}
« no previous file with comments | « src/gpu/GrPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698