In which a series of things around attachToCanvas and writePixels are fixed
Review URL: https://codereview.appspot.com/6506051/
git-svn-id: http://skia.googlecode.com/svn/trunk@5341 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 4f045ef..9c3a5fb 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -418,8 +418,17 @@
SkCanvas::Config8888 config8888 = gSrcConfigs[c];
SkBitmap bmp;
REPORTER_ASSERT(reporter, setupBitmap(&bmp, config8888, rect.width(), rect.height(), SkToBool(tightBmp)));
+ uint32_t idBefore = canvas.getDevice()->accessBitmap(false).getGenerationID();
canvas.writePixels(bmp, rect.fLeft, rect.fTop, config8888);
+ uint32_t idAfter = canvas.getDevice()->accessBitmap(false).getGenerationID();
REPORTER_ASSERT(reporter, checkWrite(reporter, &canvas, bmp, rect.fLeft, rect.fTop, config8888));
+
+ // we should change the genID iff pixels were actually written.
+ SkIRect canvasRect = SkIRect::MakeSize(canvas.getDeviceSize());
+ SkIRect writeRect = SkIRect::MakeXYWH(rect.fLeft, rect.fTop,
+ bmp.width(), bmp.height());
+ bool intersects = SkIRect::Intersects(canvasRect, writeRect) ;
+ REPORTER_ASSERT(reporter, intersects == (idBefore != idAfter));
}
}
}