blob: a66e69a5be724d0eca30d3bb1af87bfae4a96c03 [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
12static void test_trim_bounds(skiatest::Reporter* reporter) {
13 SkPath path;
14 SkAAClip clip;
15 const int height = 40;
16 const SkScalar sheight = SkIntToScalar(height);
17
18 path.addOval(SkRect::MakeWH(sheight, sheight));
19 REPORTER_ASSERT(reporter, sheight == path.getBounds().height());
20 clip.setPath(path, NULL, true);
21 REPORTER_ASSERT(reporter, height == clip.getBounds().height());
22
23 // this is the trimmed height of this cubic (with aa). The critical thing
24 // for this test is that it is less than height, which represents just
25 // the bounds of the path's control-points.
26 //
27 // This used to fail until we tracked the MinY in the BuilderBlitter.
28 //
29 const int teardrop_height = 12;
30 path.reset();
31 path.moveTo(0, 20);
32 path.cubicTo(40, 40, 40, 0, 0, 20);
33 REPORTER_ASSERT(reporter, sheight == path.getBounds().height());
34 clip.setPath(path, NULL, true);
35 REPORTER_ASSERT(reporter, teardrop_height == clip.getBounds().height());
36}
37
38static void TestAAClip(skiatest::Reporter* reporter) {
39 test_trim_bounds(reporter);
40}
41
42#include "TestClassDef.h"
43DEFINE_TESTCLASS("AAClip", AAClipTestClass, TestAAClip)