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(SkFloatToFixed(460.2881309415525f), 12 SkFloatToFixed(303.250847066498)); 13 path.cubicTo(SkFloatToFixed(463.36378422175284), 14 SkFloatToFixed(302.1169735073363), 15 SkFloatToFixed(456.32239330810046), 16 SkFloatToFixed(304.720354932878), 17 SkFloatToFixed(453.15255460013304), 18 SkFloatToFixed(305.788586869862)); 19 20 SkRect fillR, strokeR; 21 fillR = path.getBounds(); 22 23 paint.setStyle(SkPaint::kStroke_Style); 24 paint.setStrokeWidth(SkIntToScalar(2)); 25 paint.getFillPath(path, &stroke); 26 strokeR = stroke.getBounds(); 27 28 SkRect maxR = fillR; 29 SkScalar miter = SkMaxScalar(SK_Scalar1, paint.getStrokeMiter()); 30 SkScalar inset = paint.getStrokeJoin() == SkPaint::kMiter_Join ? 31 SkScalarMul(paint.getStrokeWidth(), miter) : 32 paint.getStrokeWidth(); 33 maxR.inset(-inset, -inset); 34 35 // test that our stroke didn't explode 36 REPORTER_ASSERT(reporter, maxR.contains(strokeR)); 37 } 38 39 static void TestPaint(skiatest::Reporter* reporter) { 40 // TODO add general paint tests 41 42 // regression tests 43 regression_cubic(reporter); 44 } 45 46 #include "TestClassDef.h" 47 DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint) 48