aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/cubicpaths.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-08-20 08:23:52 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2015-08-20 08:23:52 -0700
commit7d173403f47bb85cfd5c42b69c734668e25e47f9 (patch)
treef8591c88ed8ada294932022d506550b2e8e3990e /gm/cubicpaths.cpp
parent725c62054354dc0c7fb699bcd69687ec78083ae8 (diff)
subdivide path when side-clipping fails
Please review concept; I'm OK not to check this in. If the root finder fails, subdivide the curve and try again. This is complicated by the reversed nature of the curves; maybe it can be simpler, but how to do that escapes me. R=reed@google.com BUG=514246 Review URL: https://codereview.chromium.org/1299243002
Diffstat (limited to 'gm/cubicpaths.cpp')
-rw-r--r--gm/cubicpaths.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/gm/cubicpaths.cpp b/gm/cubicpaths.cpp
index 74fbe8d58b..ca6c057ec0 100644
--- a/gm/cubicpaths.cpp
+++ b/gm/cubicpaths.cpp
@@ -53,6 +53,58 @@ private:
typedef skiagm::GM INHERITED;
};
+
+class ClippedCubic2GM : public skiagm::GM {
+public:
+ ClippedCubic2GM() {}
+
+protected:
+
+ SkString onShortName() {
+ return SkString("clippedcubic2");
+ }
+
+ SkISize onISize() { return SkISize::Make(1240, 390); }
+
+ void onDraw(SkCanvas* canvas) override {
+ canvas->save();
+ canvas->translate(-2, 20);
+ drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 150));
+ canvas->translate(0, 170);
+ drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 80, 100));
+ canvas->translate(0, 170);
+ drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 30, 150));
+ canvas->translate(0, 170);
+ drawOne(canvas, fPath, SkRect::MakeLTRB(0, 0, 10, 150));
+ canvas->restore();
+ }
+
+ void drawOne(SkCanvas* canvas, const SkPath& path, const SkRect& clip) {
+ SkPaint framePaint, fillPaint;
+ framePaint.setStyle(SkPaint::kStroke_Style);
+ canvas->drawRect(clip, framePaint);
+ canvas->drawPath(path, framePaint);
+ canvas->save();
+ canvas->clipRect(clip);
+ canvas->drawPath(path, fillPaint);
+ canvas->restore();
+ }
+
+ void onOnceBeforeDraw() override {
+ fPath.moveTo(69.7030518991886f, 0);
+ fPath.cubicTo( 69.7030518991886f, 21.831149999999997f,
+ 58.08369508178456f, 43.66448333333333f, 34.8449814469765f, 65.5f);
+ fPath.cubicTo( 11.608591683531916f, 87.33115f, -0.010765133872116195f, 109.16448333333332f,
+ -0.013089005235602302f, 131);
+ fPath.close();
+ }
+
+ SkPath fPath;
+private:
+ typedef skiagm::GM INHERITED;
+};
+
+
class CubicPathGM : public skiagm::GM {
public:
CubicPathGM() {}
@@ -347,3 +399,4 @@ private:
DEF_GM( return new CubicPathGM; )
DEF_GM( return new CubicClosePathGM; )
DEF_GM( return new ClippedCubicGM; )
+DEF_GM( return new ClippedCubic2GM; )