blob: 5b19090bdb2731a8ad4f461479a1977f5b03a410 [file] [log] [blame]
reed@android.coma0f5d152009-06-22 17:38:10 +00001#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
7static void regression_cubic(skiatest::Reporter* reporter) {
8 SkPath path, stroke;
9 SkPaint paint;
10
reed@android.comd4134452011-02-09 02:24:26 +000011 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));
reed@android.coma0f5d152009-06-22 17:38:10 +000019
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
39static 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"
47DEFINE_TESTCLASS("Paint", TestPaintClass, TestPaint)