Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: tests/TileGridTest.cpp

Issue 214953003: split SkPictureRecorder out of SkPicture (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: update to ToT (again) Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/TileGridTest.cpp
===================================================================
--- tests/TileGridTest.cpp (revision 14159)
+++ tests/TileGridTest.cpp (working copy)
@@ -56,16 +56,17 @@
info.fMargin.setEmpty();
info.fOffset.setZero();
info.fTileInterval.set(10, 10);
- SkTileGridPicture picture(20, 20, info);
SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
SkIntToScalar(8), SkIntToScalar(8));
SkRect rect2 = SkRect::MakeXYWH(SkIntToScalar(11), SkIntToScalar(11),
SkIntToScalar(1), SkIntToScalar(1));
- SkCanvas* canvas = picture.beginRecording(20, 20, SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
+ SkAutoTUnref<SkPictureFactory> factory(SkNEW_ARGS(SkTileGridPictureFactory, (info)));
+ SkPictureRecorder recorder(factory);
+ SkCanvas* canvas = recorder.beginRecording(20, 20, SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
SkPaint paint;
canvas->drawRect(rect1, paint);
canvas->drawRect(rect2, paint);
- picture.endRecording();
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
SkBitmap store;
store.allocN32Pixels(1, 1);
@@ -73,14 +74,14 @@
// Test parts of top-left tile
{
MockCanvas mockCanvas(store);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
{
MockCanvas mockCanvas(store);
mockCanvas.translate(-7.99f, -7.99f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
@@ -88,7 +89,7 @@
{
MockCanvas mockCanvas(store);
mockCanvas.translate(-9.5f, -9.5f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
@@ -97,7 +98,7 @@
{
MockCanvas mockCanvas(store);
mockCanvas.translate(-16.0f, -16.0f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
}
@@ -105,28 +106,28 @@
{
MockCanvas mockCanvas(store);
mockCanvas.translate(2.0f, 0.0f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
{
MockCanvas mockCanvas(store);
mockCanvas.translate(0.0f, 2.0f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
{
MockCanvas mockCanvas(store);
mockCanvas.translate(-22.0f, -16.0f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
}
{
MockCanvas mockCanvas(store);
mockCanvas.translate(-16.0f, -22.0f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
}
@@ -138,7 +139,6 @@
info.fMargin.set(1, 1);
info.fOffset.set(-1, -1);
info.fTileInterval.set(8, 8);
- SkTileGridPicture picture(20, 20, info);
// rect landing entirely in top left tile
SkRect rect1 = SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
@@ -149,12 +149,14 @@
// rect landing entirely in bottomright tile
SkRect rect3 = SkRect::MakeXYWH(SkIntToScalar(19), SkIntToScalar(19),
SkIntToScalar(1), SkIntToScalar(1));
- SkCanvas* canvas = picture.beginRecording(20, 20, SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
+ SkAutoTUnref<SkPictureFactory> factory(SkNEW_ARGS(SkTileGridPictureFactory, (info)));
+ SkPictureRecorder recorder(factory);
+ SkCanvas* canvas = recorder.beginRecording(20, 20, SkPicture::kOptimizeForClippedPlayback_RecordingFlag);
SkPaint paint;
canvas->drawRect(rect1, paint);
canvas->drawRect(rect2, paint);
canvas->drawRect(rect3, paint);
- picture.endRecording();
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
SkBitmap tileBitmap;
tileBitmap.allocN32Pixels(10, 10);
@@ -167,14 +169,14 @@
// The offset should cancel the top and left borders of the top left tile
// So a look-up at interval 0-10 should be grid aligned,
MockCanvas mockCanvas(tileBitmap);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
}
{
// Encroaching border by one pixel
MockCanvas mockCanvas(moreThanATileBitmap);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
@@ -185,14 +187,14 @@
// with middle tile.
MockCanvas mockCanvas(tileBitmap);
mockCanvas.translate(SkIntToScalar(-8), SkIntToScalar(-8));
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 1 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
}
{
MockCanvas mockCanvas(tileBitmap);
mockCanvas.translate(-7.9f, -7.9f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect1 == mockCanvas.fRects[0]);
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[1]);
@@ -200,7 +202,7 @@
{
MockCanvas mockCanvas(tileBitmap);
mockCanvas.translate(-8.1f, -8.1f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
REPORTER_ASSERT(reporter, 2 == mockCanvas.fRects.count());
REPORTER_ASSERT(reporter, rect2 == mockCanvas.fRects[0]);
REPORTER_ASSERT(reporter, rect3 == mockCanvas.fRects[1]);
@@ -211,7 +213,7 @@
// adjusted region, sitting right on top of the tile boundary.
MockCanvas mockCanvas(tinyBitmap);
mockCanvas.translate(-8.0f, -8.0f);
- picture.draw(&mockCanvas);
+ picture->draw(&mockCanvas);
// This test passes by not asserting. We do not validate the rects recorded
// because the result is numerically unstable (floating point equality).
// The content of any one of the four tiles of the tilegrid would be a valid

Powered by Google App Engine
This is Rietveld 408576698