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/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 050fc4a..5020ec2 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -834,8 +834,6 @@
fclose(f);
#endif
- fPicture = NULL;
-
fDeviceType = kRaster_DeviceType;
#if DEFAULT_TO_GPU
@@ -990,7 +988,6 @@
}
SampleWindow::~SampleWindow() {
- delete fPicture;
delete fPdfCanvas;
fTypeface->unref();
@@ -1379,8 +1376,7 @@
pdfDevice->unref();
canvas = fPdfCanvas;
} else if (kPicture_DeviceType == fDeviceType) {
- fPicture = new SkPicture;
- canvas = fPicture->beginRecording(9999, 9999);
+ canvas = fRecorder.beginRecording(9999, 9999);
} else {
#if SK_SUPPORT_GPU
if (kNullGPU_DeviceType != fDeviceType)
@@ -1459,16 +1455,16 @@
}
if (kPicture_DeviceType == fDeviceType) {
+ SkAutoTUnref<SkPicture> picture(fRecorder.endRecording());
+
if (true) {
- SkPicture* pict = new SkPicture(*fPicture);
- fPicture->unref();
+ SkPicture* pict = new SkPicture(*picture);
this->installDrawFilter(orig);
orig->drawPicture(*pict);
pict->unref();
} else if (true) {
SkDynamicMemoryWStream ostream;
- fPicture->serialize(&ostream);
- fPicture->unref();
+ picture->serialize(&ostream);
SkAutoDataUnref data(ostream.copyToData());
SkMemoryStream istream(data->data(), data->size());
@@ -1477,10 +1473,8 @@
orig->drawPicture(*pict.get());
}
} else {
- fPicture->draw(orig);
- fPicture->unref();
+ picture->draw(orig);
}
- fPicture = NULL;
}
// Do this after presentGL and other finishing, rather than in afterChild