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