OLD | NEW |
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 Loading... |
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); ) |
OLD | NEW |