From af88ec37124846a0168a4ab061bf10cc6030c2d6 Mon Sep 17 00:00:00 2001 From: Mike Klein Date: Tue, 24 Apr 2018 12:18:37 +0000 Subject: Revert "Add arcs as a specialized geometry to GrShape." This reverts commit 255bcf57ffd9db368cd66ca9697549efd799153e. Reason for revert: layout and scuba image diffs Original change's description: > Add arcs as a specialized geometry to GrShape. > > BUG: skia:7794 > > Change-Id: I484693711f48e55631732a0f4ee97e2848dec89d > Reviewed-on: https://skia-review.googlesource.com/122900 > Commit-Queue: Brian Salomon > Reviewed-by: Robert Phillips TBR=bsalomon@google.com,robertphillips@google.com Change-Id: I9293b8fbb535d940bca5fc30a95908416b9eb7a7 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/123362 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- tests/GrShapeTest.cpp | 110 +------------------------------------------------- 1 file changed, 1 insertion(+), 109 deletions(-) (limited to 'tests/GrShapeTest.cpp') diff --git a/tests/GrShapeTest.cpp b/tests/GrShapeTest.cpp index a53dad8517..e8ec08785f 100644 --- a/tests/GrShapeTest.cpp +++ b/tests/GrShapeTest.cpp @@ -60,7 +60,7 @@ static bool test_bounds_by_rasterizing(const SkPath& path, const SkRect& bounds) // everything got clipped out. static constexpr int kRes = 2000; // This tolerance is in units of 1/kRes fractions of the bounds width/height. - static constexpr int kTol = 2; + static constexpr int kTol = 0; GR_STATIC_ASSERT(kRes % 4 == 0); SkImageInfo info = SkImageInfo::MakeA8(kRes, kRes); sk_sp surface = SkSurface::MakeRaster(info); @@ -389,34 +389,6 @@ private: SkRRect fRRect; }; -class ArcGeo : public Geo { -public: - ArcGeo(const SkRect& oval, SkScalar startAngle, SkScalar sweepAngle, bool useCenter) - : fOval(oval) - , fStartAngle(startAngle) - , fSweepAngle(sweepAngle) - , fUseCenter(useCenter) {} - - SkPath path() const override { - SkPath path; - SkPathPriv::CreateDrawArcPath(&path, fOval, fStartAngle, fSweepAngle, fUseCenter, false); - return path; - } - - GrShape makeShape(const SkPaint& paint) const override { - return GrShape::MakeArc(fOval, fStartAngle, fSweepAngle, fUseCenter, GrStyle(paint)); - } - - // GrShape specializes when created from arc params but it doesn't recognize arcs from SkPath. - bool isNonPath(const SkPaint& paint) const override { return false; } - -private: - SkRect fOval; - SkScalar fStartAngle; - SkScalar fSweepAngle; - bool fUseCenter; -}; - class PathGeo : public Geo { public: enum class Invert { kNo, kYes }; @@ -2149,10 +2121,6 @@ DEF_TEST(GrShape, reporter) { PathGeo::Invert::kNo)); } - // Arcs - geos.emplace_back(new ArcGeo(SkRect::MakeWH(200, 100), 12.f, 110.f, false)); - geos.emplace_back(new ArcGeo(SkRect::MakeWH(200, 100), 12.f, 110.f, true)); - { SkPath openRectPath; openRectPath.moveTo(0, 0); @@ -2253,80 +2221,4 @@ DEF_TEST(GrShape, reporter) { test_volatile_path(reporter, PathGeo(SkPath(), PathGeo::Invert::kNo)); } -DEF_TEST(GrShape_arcs, reporter) { - SkStrokeRec roundStroke(SkStrokeRec::kFill_InitStyle); - roundStroke.setStrokeStyle(2.f); - roundStroke.setStrokeParams(SkPaint::kRound_Cap, SkPaint::kRound_Join, 1.f); - - SkStrokeRec squareStroke(roundStroke); - squareStroke.setStrokeParams(SkPaint::kSquare_Cap, SkPaint::kRound_Join, 1.f); - - SkStrokeRec roundStrokeAndFill(roundStroke); - roundStrokeAndFill.setStrokeStyle(2.f, true); - - static constexpr SkScalar kIntervals[] = {1, 2}; - auto dash = SkDashPathEffect::Make(kIntervals, SK_ARRAY_COUNT(kIntervals), 1.5f); - - SkTArray styles; - styles.push_back(GrStyle::SimpleFill()); - styles.push_back(GrStyle::SimpleHairline()); - styles.push_back(GrStyle(roundStroke, nullptr)); - styles.push_back(GrStyle(squareStroke, nullptr)); - styles.push_back(GrStyle(roundStrokeAndFill, nullptr)); - styles.push_back(GrStyle(roundStroke, dash)); - - for (const auto& style : styles) { - // An empty rect never draws anything according to SkCanvas::drawArc() docs. - TestCase emptyArc(GrShape::MakeArc(SkRect::MakeEmpty(), 0, 90.f, false, style), reporter); - TestCase emptyPath(reporter, SkPath(), style); - emptyArc.compare(reporter, emptyPath, TestCase::kAllSame_ComparisonExpecation); - - static constexpr SkRect kOval1{0, 0, 50, 50}; - static constexpr SkRect kOval2{50, 0, 100, 50}; - // Test that swapping starting and ending angle doesn't change the shape unless the arc - // has a path effect. Also test that different ovals produce different shapes. - TestCase arc1CW(GrShape::MakeArc(kOval1, 0, 90.f, false, style), reporter); - TestCase arc1CCW(GrShape::MakeArc(kOval1, 90.f, -90.f, false, style), reporter); - - TestCase arc1CWWithCenter(GrShape::MakeArc(kOval1, 0, 90.f, true, style), reporter); - TestCase arc1CCWWithCenter(GrShape::MakeArc(kOval1, 90.f, -90.f, true, style), reporter); - - TestCase arc2CW(GrShape::MakeArc(kOval2, 0, 90.f, false, style), reporter); - TestCase arc2CWWithCenter(GrShape::MakeArc(kOval2, 0, 90.f, true, style), reporter); - - auto reversedExepectations = style.hasPathEffect() - ? TestCase::kAllDifferent_ComparisonExpecation - : TestCase::kAllSame_ComparisonExpecation; - arc1CW.compare(reporter, arc1CCW, reversedExepectations); - arc1CWWithCenter.compare(reporter, arc1CCWWithCenter, reversedExepectations); - arc1CW.compare(reporter, arc2CW, TestCase::kAllDifferent_ComparisonExpecation); - arc1CW.compare(reporter, arc1CWWithCenter, TestCase::kAllDifferent_ComparisonExpecation); - arc1CWWithCenter.compare(reporter, arc2CWWithCenter, - TestCase::kAllDifferent_ComparisonExpecation); - - // Test that two arcs that start at the same angle but specified differently are equivalent. - TestCase arc3A(GrShape::MakeArc(kOval1, 224.f, 73.f, false, style), reporter); - TestCase arc3B(GrShape::MakeArc(kOval1, 224.f - 360.f, 73.f, false, style), reporter); - arc3A.compare(reporter, arc3B, TestCase::kAllDifferent_ComparisonExpecation); - - // Test that an arc that traverses the entire oval (and then some) is equivalent to the - // oval itself unless there is a path effect. - TestCase ovalArc(GrShape::MakeArc(kOval1, 150.f, -790.f, false, style), reporter); - TestCase oval(GrShape(SkRRect::MakeOval(kOval1)), reporter); - auto ovalExpectations = style.hasPathEffect() ? TestCase::kAllDifferent_ComparisonExpecation - : TestCase::kAllSame_ComparisonExpecation; - if (style.strokeRec().getWidth() >= 0 && style.strokeRec().getCap() != SkPaint::kButt_Cap) { - ovalExpectations = TestCase::kAllDifferent_ComparisonExpecation; - } - ovalArc.compare(reporter, oval, ovalExpectations); - - // If the the arc starts/ends at the center then it is then equivalent to the oval only for - // simple fills. - TestCase ovalArcWithCenter(GrShape::MakeArc(kOval1, 304.f, 1225.f, true, style), reporter); - ovalExpectations = style.isSimpleFill() ? TestCase::kAllSame_ComparisonExpecation - : TestCase::kAllDifferent_ComparisonExpecation; - ovalArcWithCenter.compare(reporter, oval, ovalExpectations); - } -} - #endif -- cgit v1.2.3