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