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/SampleTiling.cpp b/samplecode/SampleTiling.cpp
index 9ffcceb..faa8d80 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -62,21 +62,19 @@
static const int gHeight = 32;
class TilingView : public SampleView {
- SkPicture* fTextPicture;
- SkBlurDrawLooper fLooper;
+ SkAutoTUnref<SkPicture> fTextPicture;
+ SkBlurDrawLooper fLooper;
public:
TilingView()
: fLooper(0x88000000,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(1)),
SkIntToScalar(2), SkIntToScalar(2)) {
- fTextPicture = new SkPicture();
for (size_t i = 0; i < SK_ARRAY_COUNT(gColorTypes); i++) {
makebm(&fTexture[i], gColorTypes[i], gWidth, gHeight);
}
}
- ~TilingView() {
- fTextPicture->unref();
+ virtual ~TilingView() {
}
SkBitmap fTexture[SK_ARRAY_COUNT(gColorTypes)];
@@ -105,12 +103,13 @@
SkScalar y = SkIntToScalar(24);
SkScalar x = SkIntToScalar(10);
+ SkPictureRecorder recorder;
SkCanvas* textCanvas = NULL;
if (fTextPicture->width() == 0) {
- textCanvas = fTextPicture->beginRecording(1000, 1000);
+ textCanvas = recorder.beginRecording(1000, 1000);
}
- if (textCanvas) {
+ if (NULL != textCanvas) {
for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
SkPaint p;
@@ -160,6 +159,8 @@
}
}
+ fTextPicture.reset(recorder.endRecording());
+
canvas->drawPicture(*fTextPicture);
}