Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: gm/etc1bitmap.cpp

Issue 310793003: Fix memory leak in etc1bitmap GM. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "gm.h" 8 #include "gm.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 20 matching lines...) Expand all
31 virtual SkISize onISize() SK_OVERRIDE { 31 virtual SkISize onISize() SK_OVERRIDE {
32 return make_isize(512, 512); 32 return make_isize(512, 512);
33 } 33 }
34 34
35 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 35 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
36 36
37 SkBitmap bm; 37 SkBitmap bm;
38 SkString filename = SkOSPath::SkPathJoin( 38 SkString filename = SkOSPath::SkPathJoin(
39 INHERITED::gResourcePath.c_str(), "mandrill_512.pkm"); 39 INHERITED::gResourcePath.c_str(), "mandrill_512.pkm");
40 40
41 SkData *fileData = SkData::NewFromFileName(filename.c_str()); 41 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ;
42 if (NULL == fileData) { 42 if (NULL == fileData) {
43 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n"); 43 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n");
44 return; 44 return;
45 } 45 }
46 46
47 if (!SkInstallDiscardablePixelRef( 47 if (!SkInstallDiscardablePixelRef(
48 SkDecodingImageGenerator::Create( 48 SkDecodingImageGenerator::Create(
49 fileData, SkDecodingImageGenerator::Options()), &bm)) { 49 fileData, SkDecodingImageGenerator::Options()), &bm)) {
50 SkDebugf("Could not install discardable pixel ref.\n"); 50 SkDebugf("Could not install discardable pixel ref.\n");
51 return; 51 return;
52 } 52 }
53 53
54 canvas->drawBitmap(bm, 0, 0); 54 canvas->drawBitmap(bm, 0, 0);
55 } 55 }
56 56
57 private: 57 private:
58 typedef GM INHERITED; 58 typedef GM INHERITED;
59 }; 59 };
60 60
61 } // namespace skiagm 61 } // namespace skiagm
62 62
63 ////////////////////////////////////////////////////////////////////////////// 63 //////////////////////////////////////////////////////////////////////////////
64 64
65 DEF_GM( return SkNEW(skiagm::ETC1BitmapGM); ) 65 DEF_GM( return SkNEW(skiagm::ETC1BitmapGM); )
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698