aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-10-13 13:31:27 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-10-13 13:31:27 +0000
commitd0d0e65a6313f01dfd952e8cc214a7c193bec57a (patch)
tree0bd13b88949493a43d437b774fa4b78f2ba55224 /samplecode
parent8af9602f6161e8d031ea175d7a5e4bd206d8e72b (diff)
add new cubic test for overflow
git-svn-id: http://skia.googlecode.com/svn/trunk@379 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SamplePath.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index e63c513064..1eb4222b1c 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -11,6 +11,7 @@
#include "SkXfermode.h"
#include "SkColorPriv.h"
#include "SkColorFilter.h"
+#include "SkParsePath.h"
#include "SkTime.h"
#include "SkTypeface.h"
@@ -37,6 +38,36 @@ static void test_cubic() {
#endif
}
+static void test_cubic2() {
+ const char* str = "M2242 -590088L-377758 9.94099e+07L-377758 9.94099e+07L2242 -590088Z";
+ SkPath path;
+ SkParsePath::FromSVGString(str, &path);
+
+ {
+ float x = strtof("9.94099e+07", NULL);
+ int ix = (int)x;
+ int fx = (int)(x * 65536);
+ int ffx = SkScalarToFixed(x);
+ printf("%g %x %x %x\n", x, ix, fx, ffx);
+
+ SkRect r = path.getBounds();
+ SkIRect ir;
+ r.round(&ir);
+ printf("[%g %g %g %g] [%x %x %x %x]\n",
+ r.fLeft, r.fTop, r.fRight, r.fBottom,
+ ir.fLeft, ir.fTop, ir.fRight, ir.fBottom);
+ }
+
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, 300, 200);
+ bitmap.allocPixels();
+
+ SkCanvas canvas(bitmap);
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ canvas.drawPath(path, paint);
+}
+
class PathView : public SkView {
public:
int fDStroke, fStroke, fMinStroke, fMaxStroke;
@@ -45,6 +76,7 @@ public:
PathView() {
test_cubic();
+ test_cubic2();
fShowHairline = false;