blob: 63bb15fdd52fc67546c1a05039a9bcec63c075e2 [file] [log] [blame]
reed@google.com209c4152011-10-26 15:03:48 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "Test.h"
9#include "SkAAClip.h"
10#include "SkPath.h"
11
reed@google.com12e15252011-10-26 15:19:36 +000012static void imoveTo(SkPath& path, int x, int y) {
13 path.moveTo(SkIntToScalar(x), SkIntToScalar(y));
14}
15
16static void icubicTo(SkPath& path, int x0, int y0, int x1, int y1, int x2, int y2) {
17 path.cubicTo(SkIntToScalar(x0), SkIntToScalar(y0),
18 SkIntToScalar(x1), SkIntToScalar(y1),
19 SkIntToScalar(x2), SkIntToScalar(y2));
20}
21
reed@google.com209c4152011-10-26 15:03:48 +000022static void test_trim_bounds(skiatest::Reporter* reporter) {
23 SkPath path;
24 SkAAClip clip;
25 const int height = 40;
26 const SkScalar sheight = SkIntToScalar(height);
27
28 path.addOval(SkRect::MakeWH(sheight, sheight));
29 REPORTER_ASSERT(reporter, sheight == path.getBounds().height());
30 clip.setPath(path, NULL, true);
31 REPORTER_ASSERT(reporter, height == clip.getBounds().height());
32
33 // this is the trimmed height of this cubic (with aa). The critical thing
34 // for this test is that it is less than height, which represents just
35 // the bounds of the path's control-points.
36 //
37 // This used to fail until we tracked the MinY in the BuilderBlitter.
38 //
39 const int teardrop_height = 12;
40 path.reset();
reed@google.com12e15252011-10-26 15:19:36 +000041 imoveTo(path, 0, 20);
42 icubicTo(path, 40, 40, 40, 0, 0, 20);
reed@google.com209c4152011-10-26 15:03:48 +000043 REPORTER_ASSERT(reporter, sheight == path.getBounds().height());
44 clip.setPath(path, NULL, true);
45 REPORTER_ASSERT(reporter, teardrop_height == clip.getBounds().height());
46}
47
48static void TestAAClip(skiatest::Reporter* reporter) {
49 test_trim_bounds(reporter);
50}
51
52#include "TestClassDef.h"
53DEFINE_TESTCLASS("AAClip", AAClipTestClass, TestAAClip)