diff options
author | 2017-02-06 13:38:23 -0500 | |
---|---|---|
committer | 2017-02-06 19:15:16 +0000 | |
commit | a84898dbb8d8f7cb8c3e9bdfb4c31d85dff1922f (patch) | |
tree | bb84f0ebbc9354b018fb81351c49d7d4d30469d5 /tests | |
parent | a8f413927951e1b6e6c791526da3c92bc45639e2 (diff) |
Have ShadowTessellators transform path; add SkShadowTessellator base class
BUG=skia:6119
Change-Id: I37639ebab43c9f32f48d2d7dbb8d4619efb9b09e
Reviewed-on: https://skia-review.googlesource.com/8061
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ShadowUtilsTest.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tests/ShadowUtilsTest.cpp b/tests/ShadowUtilsTest.cpp index adcb5031f4..45bb197918 100644 --- a/tests/ShadowUtilsTest.cpp +++ b/tests/ShadowUtilsTest.cpp @@ -11,28 +11,30 @@ #include "SkShadowUtils.h" #include "Test.h" -void tessellate_shadow(skiatest::Reporter* reporter, const SkPath& path, bool expectSuccess) { +void tessellate_shadow(skiatest::Reporter* reporter, const SkPath& path, const SkMatrix& ctm, + bool expectSuccess) { static constexpr SkScalar kRadius = 2.f; static constexpr SkColor kUmbraColor = 0xFFFFFFFF; static constexpr SkColor kPenumbraColor = 0x20202020; - auto verts = SkShadowVertices::MakeAmbient(path, kRadius, kUmbraColor, kPenumbraColor, true); + auto verts = SkShadowVertices::MakeAmbient(path, ctm, kRadius, kUmbraColor, kPenumbraColor, + true); if (expectSuccess != SkToBool(verts)) { ERRORF(reporter, "Expected shadow tessellation to % but it did not.", expectSuccess ? "succeed" : "fail"); } - verts = SkShadowVertices::MakeAmbient(path, kRadius, kUmbraColor, kPenumbraColor, false); + verts = SkShadowVertices::MakeAmbient(path, ctm, kRadius, kUmbraColor, kPenumbraColor, false); if (expectSuccess != SkToBool(verts)) { ERRORF(reporter, "Expected shadow tessellation to % but it did not.", expectSuccess ? "succeed" : "fail"); } - verts = SkShadowVertices::MakeSpot(path, 1.5f, {0, 0}, kRadius, kUmbraColor, kPenumbraColor, - false); + verts = SkShadowVertices::MakeSpot(path, ctm, 1.5f, {0, 0}, kRadius, kUmbraColor, + kPenumbraColor, false); if (expectSuccess != SkToBool(verts)) { ERRORF(reporter, "Expected shadow tessellation to % but it did not.", expectSuccess ? "succeed" : "fail"); } - verts = SkShadowVertices::MakeSpot(path, 1.5f, {0, 0}, kRadius, kUmbraColor, kPenumbraColor, - true); + verts = SkShadowVertices::MakeSpot(path, ctm, 1.5f, {0, 0}, kRadius, kUmbraColor, + kPenumbraColor, true); if (expectSuccess != SkToBool(verts)) { ERRORF(reporter, "Expected shadow tessellation to % but it did not.", expectSuccess ? "succeed" : "fail"); @@ -41,21 +43,21 @@ void tessellate_shadow(skiatest::Reporter* reporter, const SkPath& path, bool ex DEF_TEST(ShadowUtils, reporter) { SkCanvas canvas(100, 100); - // Currently SkShadowUtils doesn't really stupport cubics when compiled without SK_SUPPORT_GPU. - // However, this should now crash. + // Currently SkShadowUtils doesn't really support cubics when compiled without SK_SUPPORT_GPU. + // However, this should now not crash. SkPath path; path.cubicTo(100, 50, 20, 100, 0, 0); - tessellate_shadow(reporter, path, (bool)SK_SUPPORT_GPU); + tessellate_shadow(reporter, path, canvas.getTotalMatrix(), (bool)SK_SUPPORT_GPU); // This line segment has no area and no shadow. path.reset(); path.lineTo(10.f, 10.f); - tessellate_shadow(reporter, path, false); + tessellate_shadow(reporter, path, canvas.getTotalMatrix(), false); // A series of colinear line segments path.reset(); for (int i = 0; i < 10; ++i) { path.lineTo((SkScalar)i, (SkScalar)i); } - tessellate_shadow(reporter, path, false); + tessellate_shadow(reporter, path, canvas.getTotalMatrix(), false); } |