add comment
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 23 May 2013 19:30:48 +0000 (19:30 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 23 May 2013 19:30:48 +0000 (19:30 +0000)
add test for skbug/com/1316

BUG=

Review URL: https://codereview.chromium.org/15790006

git-svn-id: http://skia.googlecode.com/svn/trunk@9261 2bbb7eff-a529-9590-31e7-b0007b416f81

gm/cubicpaths.cpp

index 9ab710a..00a7412 100644 (file)
@@ -9,6 +9,47 @@
 #include "SkPaint.h"
 #include "SkRandom.h"
 
+// skbug.com/1316 shows that this cubic, when slightly clipped, creates big
+// (incorrect) changes to its control points.
+class ClippedCubicGM : public skiagm::GM {
+public:
+    ClippedCubicGM() {}
+    
+protected:
+    SkString onShortName() {
+        return SkString("cubicpath");
+    }
+    
+    SkISize onISize() { return SkISize::Make(1240, 390); }
+    
+    virtual void onDraw(SkCanvas* canvas) {
+        SkPath path;
+        path.moveTo(0, 0);
+        path.cubicTo(140, 150, 40, 10, 170, 150);
+        
+        SkPaint paint;
+        SkRect bounds = path.getBounds();
+        
+        for (int dy = -1; dy <= 1; ++dy) {
+            canvas->save();
+            for (int dx = -1; dx <= 1; ++dx) {
+                canvas->save();
+                canvas->clipRect(bounds);
+                canvas->translate(dx, dy);
+                canvas->drawPath(path, paint);
+                canvas->restore();
+                
+                canvas->translate(bounds.width(), 0);
+            }
+            canvas->restore();
+            canvas->translate(0, bounds.height());
+        }
+    }
+    
+private:
+    typedef skiagm::GM INHERITED;
+};
+
 class CubicPathGM : public skiagm::GM {
 public:
     CubicPathGM() {}
@@ -300,3 +341,4 @@ private:
 
 DEF_GM( return new CubicPathGM; )
 DEF_GM( return new CubicClosePathGM; )
+DEF_GM( return new ClippedCubicGM; )