diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-26 15:03:48 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-10-26 15:03:48 +0000 |
commit | 209c41511eb0d06f8c19f8fb1fc0393c502a1b18 (patch) | |
tree | bd83511d61c0005c91b6f5a25be221fa6183c5ce /tests/AAClipTest.cpp | |
parent | 67cdbf5c63cfd77523d2a3070a44a200fabf0739 (diff) |
add initial unittests for aaclip. Fix case where BuilderBlitter skipped the top
few scanlines (of its bounds) and therefore didn't know to trim its bounds back
down. This can happen when the path's bounds are larger than the curve's bounds
(i.e. the control points are outside of the tight-bounds of the shape.)
git-svn-id: http://skia.googlecode.com/svn/trunk@2534 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/AAClipTest.cpp')
-rw-r--r-- | tests/AAClipTest.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/AAClipTest.cpp b/tests/AAClipTest.cpp new file mode 100644 index 0000000000..a66e69a5be --- /dev/null +++ b/tests/AAClipTest.cpp @@ -0,0 +1,43 @@ +/* + * Copyright 2011 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "Test.h" +#include "SkAAClip.h" +#include "SkPath.h" + +static void test_trim_bounds(skiatest::Reporter* reporter) { + SkPath path; + SkAAClip clip; + const int height = 40; + const SkScalar sheight = SkIntToScalar(height); + + path.addOval(SkRect::MakeWH(sheight, sheight)); + REPORTER_ASSERT(reporter, sheight == path.getBounds().height()); + clip.setPath(path, NULL, true); + REPORTER_ASSERT(reporter, height == clip.getBounds().height()); + + // this is the trimmed height of this cubic (with aa). The critical thing + // for this test is that it is less than height, which represents just + // the bounds of the path's control-points. + // + // This used to fail until we tracked the MinY in the BuilderBlitter. + // + const int teardrop_height = 12; + path.reset(); + path.moveTo(0, 20); + path.cubicTo(40, 40, 40, 0, 0, 20); + REPORTER_ASSERT(reporter, sheight == path.getBounds().height()); + clip.setPath(path, NULL, true); + REPORTER_ASSERT(reporter, teardrop_height == clip.getBounds().height()); +} + +static void TestAAClip(skiatest::Reporter* reporter) { + test_trim_bounds(reporter); +} + +#include "TestClassDef.h" +DEFINE_TESTCLASS("AAClip", AAClipTestClass, TestAAClip) |