aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-12 21:11:18 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-03-12 21:11:18 +0000
commit0a0726542ed62f07a2df5e1ac082472006355e66 (patch)
tree29c54b9322344ae5cc5539a3a48509aaddd94423 /tests
parentadb2e240188ecd3deef2b31f3836f44968d71d65 (diff)
add unittest for rev. 3366 -- clipping antihairlines
git-svn-id: http://skia.googlecode.com/svn/trunk@3367 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests')
-rw-r--r--tests/ClipperTest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/ClipperTest.cpp b/tests/ClipperTest.cpp
index 7bb225417e..607561d752 100644
--- a/tests/ClipperTest.cpp
+++ b/tests/ClipperTest.cpp
@@ -10,6 +10,43 @@
#include "SkLineClipper.h"
#include "SkEdgeClipper.h"
+#include "SkCanvas.h"
+static void test_hairclipping(skiatest::Reporter* reporter) {
+ SkBitmap bm;
+ bm.setConfig(SkBitmap::kARGB_8888_Config, 4, 4);
+ bm.allocPixels();
+ bm.eraseColor(SK_ColorWHITE);
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+
+ SkCanvas canvas(bm);
+ canvas.clipRect(SkRect::MakeWH(4, 2));
+ canvas.drawLine(1.5, 1.5, 3.5, 3.5, paint);
+
+ /**
+ * We had a bug where we misinterpreted the bottom of the clip, and
+ * would draw another pixel (to the right in this case) on the same
+ * last scanline. i.e. we would draw to [2,1], even though this hairline
+ * should just draw to [1,1], [2,2], [3,3] modulo the clip.
+ *
+ * The result of this entire draw should be that we only draw to [1,1]
+ *
+ * Fixed in rev. 3366
+ */
+ for (int y = 0; y < 4; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ bool nonWhite = (1 == y) && (1 == x);
+ SkPMColor c = *bm.getAddr32(x, y);
+ if (nonWhite) {
+ REPORTER_ASSERT(reporter, 0xFFFFFFFF != c);
+ } else {
+ REPORTER_ASSERT(reporter, 0xFFFFFFFF == c);
+ }
+ }
+ }
+}
+
static void test_edgeclipper(skiatest::Reporter* reporter) {
SkEdgeClipper clipper;
@@ -109,6 +146,7 @@ static void test_intersectline(skiatest::Reporter* reporter) {
void TestClipper(skiatest::Reporter* reporter) {
test_intersectline(reporter);
test_edgeclipper(reporter);
+ test_hairclipping(reporter);
}
#include "TestClassDef.h"