OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 9 |
10 #include "Resources.h" | 10 #include "Resources.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 /** | 23 /** |
24 * Draw a PNG created by SkBitmapFactory. | 24 * Draw a PNG created by SkBitmapFactory. |
25 */ | 25 */ |
26 class FactoryGM : public GM { | 26 class FactoryGM : public GM { |
27 public: | 27 public: |
28 FactoryGM() {} | 28 FactoryGM() {} |
29 | 29 |
30 protected: | 30 protected: |
31 virtual void onOnceBeforeDraw() SK_OVERRIDE { | 31 virtual void onOnceBeforeDraw() SK_OVERRIDE { |
32 SkString resourcePath = GetResourcePath(); | |
33 // Copyright-free file from http://openclipart.org/detail/29213/paper-pl
ane-by-ddoo | 32 // Copyright-free file from http://openclipart.org/detail/29213/paper-pl
ane-by-ddoo |
34 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "plane.pn
g"); | 33 SkString pngFilename = GetResourcePath("plane.png"); |
35 SkAutoDataUnref data(SkData::NewFromFileName(filename.c_str())); | 34 SkAutoDataUnref data(SkData::NewFromFileName(pngFilename.c_str())); |
36 if (NULL != data.get()) { | 35 if (NULL != data.get()) { |
37 // Create a cache which will boot the pixels out anytime the | 36 // Create a cache which will boot the pixels out anytime the |
38 // bitmap is unlocked. | 37 // bitmap is unlocked. |
39 SkAutoTUnref<SkDiscardableMemoryPool> pool( | 38 SkAutoTUnref<SkDiscardableMemoryPool> pool( |
40 SkDiscardableMemoryPool::Create(1)); | 39 SkDiscardableMemoryPool::Create(1)); |
41 SkAssertResult(SkInstallDiscardablePixelRef( | 40 SkAssertResult(SkInstallDiscardablePixelRef( |
42 SkDecodingImageGenerator::Create( | 41 SkDecodingImageGenerator::Create( |
43 data, SkDecodingImageGenerator::Options()), | 42 data, SkDecodingImageGenerator::Options()), |
44 &fBitmap, pool)); | 43 &fBitmap, pool)); |
45 } | 44 } |
(...skipping 21 matching lines...) Expand all Loading... |
67 | 66 |
68 typedef GM INHERITED; | 67 typedef GM INHERITED; |
69 }; | 68 }; |
70 | 69 |
71 ////////////////////////////////////////////////////////////////////////////// | 70 ////////////////////////////////////////////////////////////////////////////// |
72 | 71 |
73 static GM* MyFactory(void*) { return new FactoryGM; } | 72 static GM* MyFactory(void*) { return new FactoryGM; } |
74 static GMRegistry reg(MyFactory); | 73 static GMRegistry reg(MyFactory); |
75 | 74 |
76 } // namespace skiagm | 75 } // namespace skiagm |
OLD | NEW |