From f3cf9429cc8f483bc5287ca09206a0fc81d98729 Mon Sep 17 00:00:00 2001 From: "junov@google.com" Date: Tue, 13 Sep 2011 18:15:52 +0000 Subject: SampleApp: fixing bad ref counting on non dynamically allocated object REVIEW=http://codereview.appspot.com/4969079/ git-svn-id: http://skia.googlecode.com/svn/trunk@2259 2bbb7eff-a529-9590-31e7-b0007b416f81 --- samplecode/SampleTiling.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'samplecode/SampleTiling.cpp') diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp index a18a16e661..d72544bafb 100644 --- a/samplecode/SampleTiling.cpp +++ b/samplecode/SampleTiling.cpp @@ -63,17 +63,22 @@ static const int gWidth = 32; static const int gHeight = 32; class TilingView : public SampleView { - SkPicture fTextPicture; + SkPicture* fTextPicture; SkBlurDrawLooper fLooper; public: TilingView() : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2), 0x88000000) { + fTextPicture = new SkPicture(); for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { makebm(&fTexture[i], gConfigs[i], gWidth, gHeight); } } + ~TilingView() { + fTextPicture->unref(); + } + SkBitmap fTexture[SK_ARRAY_COUNT(gConfigs)]; protected: @@ -101,8 +106,8 @@ protected: SkScalar x = SkIntToScalar(10); SkCanvas* textCanvas = NULL; - if (fTextPicture.width() == 0) { - textCanvas = fTextPicture.beginRecording(1000, 1000); + if (fTextPicture->width() == 0) { + textCanvas = fTextPicture->beginRecording(1000, 1000); } if (textCanvas) { @@ -155,7 +160,7 @@ protected: } } - canvas->drawPicture(fTextPicture); + canvas->drawPicture(*fTextPicture); } private: -- cgit v1.2.3