aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PaintTest.cpp
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-06-22 17:38:10 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-06-22 17:38:10 +0000
commita0f5d1546d499ef0cd7dbfba9a866ae5a27e1541 (patch)
tree4e74bc93f6d794826a8eb1a78d4642ab9b215143 /tests/PaintTest.cpp
parent1a2fec55d914f0a01cbee37077105ef6c8a7366f (diff)
move xfermode modes from porterduff into xfermode itself
git-svn-id: http://skia.googlecode.com/svn/trunk@232 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PaintTest.cpp')
-rw-r--r--tests/PaintTest.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/PaintTest.cpp b/tests/PaintTest.cpp
new file mode 100644
index 0000000000..4e6c8b9d59
--- /dev/null
+++ b/tests/PaintTest.cpp
@@ -0,0 +1,43 @@
+#include "Test.h"
+#include "SkPath.h"
+#include "SkPaint.h"
+
+// found and fixed for webkit: mishandling when we hit recursion limit on
+// mostly degenerate cubic flatness test
+static void regression_cubic(skiatest::Reporter* reporter) {
+ SkPath path, stroke;
+ SkPaint paint;
+
+ path.moveTo(460.2881309415525, 303.250847066498);
+ path.cubicTo(463.36378422175284, 302.1169735073363,
+ 456.32239330810046, 304.720354932878,
+ 453.15255460013304, 305.788586869862);
+
+ SkRect fillR, strokeR;
+ fillR = path.getBounds();
+
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(SkIntToScalar(2));
+ paint.getFillPath(path, &stroke);
+ strokeR = stroke.getBounds();
+
+ SkRect maxR = fillR;
+ SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter());
+ SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ?
+ SkScalarMul(paint.getStrokeWidth(), miter) :
+ paint.getStrokeWidth();
+ maxR.inset(-inset, -inset);
+
+ // test that our stroke didn't explode
+ REPORTER_ASSERT(reporter, maxR.contains(strokeR));
+}
+
+static void TestPaint(skiatest::Reporter* reporter) {
+ // TODO add general paint tests
+
+ // regression tests
+ regression_cubic(reporter);
+}
+
+#include "TestClassDef.h"
+DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint)