split SkPictureRecorder out of SkPicture
https://codereview.chromium.org/214953003/
git-svn-id: http://skia.googlecode.com/svn/trunk@14171 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 50371d1..9b34b08 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -495,12 +495,13 @@
static void DrawPictureTestStep(SkCanvas* canvas,
skiatest::Reporter*,
CanvasTestStep*) {
- SkPicture* testPicture = SkNEW_ARGS(SkPicture, ());
- SkAutoUnref aup(testPicture);
- SkCanvas* testCanvas = testPicture->beginRecording(kWidth, kHeight);
+ SkPictureRecorder recorder;
+ SkCanvas* testCanvas = recorder.beginRecording(kWidth, kHeight);
testCanvas->scale(SkIntToScalar(2), SkIntToScalar(1));
testCanvas->clipRect(kTestRect);
testCanvas->drawRect(kTestRect, kTestPaint);
+ SkAutoTUnref<SkPicture> testPicture(recorder.endRecording());
+
canvas->drawPicture(*testPicture);
}
TEST_STEP(DrawPicture, DrawPictureTestStep);
@@ -722,24 +723,23 @@
// Verify that when a test step is executed twice, no extra resources
// are flattened during the second execution
testStep->setAssertMessageFormat(kPictureDrawAssertMessageFormat);
- SkPicture referencePicture;
- SkCanvas* referenceCanvas = referencePicture.beginRecording(kWidth,
- kHeight, recordFlags);
+ SkPictureRecorder referenceRecorder;
+ SkCanvas* referenceCanvas = referenceRecorder.beginRecording(kWidth,
+ kHeight, recordFlags);
testStep->draw(referenceCanvas, reporter);
- SkPicture testPicture;
- SkCanvas* testCanvas = testPicture.beginRecording(kWidth,
- kHeight, recordFlags);
+
+ SkPictureRecorder testRecorder;
+ SkCanvas* testCanvas = testRecorder.beginRecording(kWidth,
+ kHeight, recordFlags);
testStep->draw(testCanvas, reporter);
testStep->setAssertMessageFormat(kPictureSecondDrawAssertMessageFormat);
testStep->draw(testCanvas, reporter);
- SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>(
- referenceCanvas);
- SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(
- testCanvas);
+ SkPictureRecord* referenceRecord = static_cast<SkPictureRecord*>(referenceCanvas);
+ SkPictureRecord* testRecord = static_cast<SkPictureRecord*>(testCanvas);
testStep->setAssertMessageFormat(kPictureResourceReuseMessageFormat);
AssertFlattenedObjectsEqual(referenceRecord, testRecord,
- reporter, testStep);
+ reporter, testStep);
}
};