1 #include "Test.h" 2 #include "SkPath.h" 3 #include "SkPaint.h" 4 5 // found and fixed for webkit: mishandling when we hit recursion limit on 6 // mostly degenerate cubic flatness test 7 static void regression_cubic(skiatest::Reporter* reporter) { 8 SkPath path, stroke; 9 SkPaint paint; 10 11 path.moveTo(460.2881309415525, 303.250847066498); 12 path.cubicTo(463.36378422175284, 302.1169735073363, 13 456.32239330810046, 304.720354932878, 14 453.15255460013304, 305.788586869862); 15 16 SkRect fillR, strokeR; 17 fillR = path.getBounds(); 18 19 paint.setStyle(SkPaint::kStroke_Style); 20 paint.setStrokeWidth(SkIntToScalar(2)); 21 paint.getFillPath(path, &stroke); 22 strokeR = stroke.getBounds(); 23 24 SkRect maxR = fillR; 25 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); 26 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? 27 SkScalarMul(paint.getStrokeWidth(), miter) : 28 paint.getStrokeWidth(); 29 maxR.inset(-inset, -inset); 30 31 // test that our stroke didn't explode 32 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); 33 } 34 35 static void TestPaint(skiatest::Reporter* reporter) { 36 // TODO add general paint tests 37 38 // regression tests 39 regression_cubic(reporter); 40 } 41 42 #include "TestClassDef.h" 43 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) 44