diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-26 21:27:03 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-08-26 21:27:03 +0000 |
commit | f272e3554aec86b5d6f7ba44f81f37e5a2070bdc (patch) | |
tree | f03d43c0c87a03a8352ba70e18666383485394b0 | |
parent | b9050d73f98912cdac6a4e058523e6a92e497f69 (diff) |
test drawing large-coord aa rects
git-svn-id: http://skia.googlecode.com/svn/trunk@10926 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | tests/DrawPathTest.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/DrawPathTest.cpp b/tests/DrawPathTest.cpp index b791a9a25c..aea07c10cd 100644 --- a/tests/DrawPathTest.cpp +++ b/tests/DrawPathTest.cpp @@ -9,6 +9,7 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkDashPathEffect.h" +#include "SkSurface.h" static SkCanvas* create(SkBitmap::Config config, int w, int h, int rb, void* addr = NULL) { @@ -28,6 +29,49 @@ static SkCanvas* new_canvas(int w, int h) { /////////////////////////////////////////////////////////////////////////////// +// test that we can draw an aa-rect at coordinates > 32K (bigger than fixedpoint) +static void test_big_aa_rect(skiatest::Reporter* reporter) { + SkBitmap output; + SkPMColor pixel[1]; + output.setConfig(SkBitmap::kARGB_8888_Config, 1, 1, 4); + output.setPixels(pixel); + + SkImage::Info info = { + 300, 33300, SkImage::kPMColor_ColorType, SkImage::kPremul_AlphaType + }; + SkSurface* surf = SkSurface::NewRaster(info); + SkCanvas* canvas = surf->getCanvas(); + + SkRect r = { 0, 33000, 300, 33300 }; + int x = SkScalarRoundToInt(r.left()); + int y = SkScalarRoundToInt(r.top()); + + // check that the pixel in question starts as transparent (by the surface) + if (canvas->readPixels(&output, x, y)) { + REPORTER_ASSERT(reporter, 0 == pixel[0]); + } else { + REPORTER_ASSERT(reporter, !"readPixels failed"); + } + + SkPaint paint; + paint.setAntiAlias(true); + paint.setColor(SK_ColorWHITE); + + canvas->drawRect(r, paint); + + // Now check that it is BLACK + if (canvas->readPixels(&output, x, y)) { + // don't know what swizzling PMColor did, but white should always + // appear the same. + REPORTER_ASSERT(reporter, 0xFFFFFFFF == pixel[0]); + } else { + REPORTER_ASSERT(reporter, !"readPixels failed"); + } + surf->unref(); +} + +/////////////////////////////////////////////////////////////////////////////// + static void moveToH(SkPath* path, const uint32_t raw[]) { const float* fptr = (const float*)raw; path->moveTo(fptr[0], fptr[1]); @@ -276,6 +320,10 @@ static void TestDrawPath(skiatest::Reporter* reporter) { if (false) test_crbug131181(); test_infinite_dash(reporter); test_crbug_165432(reporter); + + if (false) { // working on a fix + test_big_aa_rect(reporter); + } } #include "TestClassDef.h" |