Chromium Code Reviews| Index: samplecode/SampleTiling.cpp |
| =================================================================== |
| --- samplecode/SampleTiling.cpp (revision 14159) |
| +++ samplecode/SampleTiling.cpp (working copy) |
| @@ -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) { |
|
bungeman-chromium
2014/04/15 21:07:08
fTextPicture is still uninitialized here!
|
| - 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); |
| } |