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

Side by Side Diff: gm/factory.cpp

Issue 834633006: add ImageGenerator::NewFromData to porting layer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add helper for SkInstallDiscardablePixelRef(SkData*, ...) Created 5 years, 11 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
OLDNEW
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 "SkDecodingImageGenerator.h"
14 #include "SkDiscardableMemoryPool.h" 13 #include "SkDiscardableMemoryPool.h"
15 #include "SkDiscardablePixelRef.h" 14 #include "SkDiscardablePixelRef.h"
16 #include "SkImageDecoder.h" 15 #include "SkImageDecoder.h"
17 #include "SkImageGeneratorPriv.h" 16 #include "SkImageGeneratorPriv.h"
18 #include "SkOSFile.h" 17 #include "SkOSFile.h"
19 #include "SkStream.h" 18 #include "SkStream.h"
20 19
21 namespace skiagm { 20 namespace skiagm {
22 21
23 /** 22 /**
24 * Draw a PNG created by SkBitmapFactory. 23 * Draw a PNG created by SkBitmapFactory.
25 */ 24 */
26 class FactoryGM : public GM { 25 class FactoryGM : public GM {
27 public: 26 public:
28 FactoryGM() {} 27 FactoryGM() {}
29 28
30 protected: 29 protected:
31 virtual void onOnceBeforeDraw() SK_OVERRIDE { 30 virtual void onOnceBeforeDraw() SK_OVERRIDE {
32 // 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
33 SkString pngFilename = GetResourcePath("plane.png"); 32 SkString pngFilename = GetResourcePath("plane.png");
34 SkAutoDataUnref data(SkData::NewFromFileName(pngFilename.c_str())); 33 SkAutoDataUnref data(SkData::NewFromFileName(pngFilename.c_str()));
35 if (data.get()) { 34 if (data.get()) {
36 // Create a cache which will boot the pixels out anytime the 35 // Create a cache which will boot the pixels out anytime the
37 // bitmap is unlocked. 36 // bitmap is unlocked.
38 SkAutoTUnref<SkDiscardableMemoryPool> pool( 37 SkAutoTUnref<SkDiscardableMemoryPool> pool(
39 SkDiscardableMemoryPool::Create(1)); 38 SkDiscardableMemoryPool::Create(1));
40 SkAssertResult(SkInstallDiscardablePixelRef( 39 SkAssertResult(SkInstallDiscardablePixelRef(SkImageGenerator::NewFro mData(data),
41 SkDecodingImageGenerator::Create( 40 &fBitmap, pool));
42 data, SkDecodingImageGenerator::Options()),
43 &fBitmap, pool));
44 } 41 }
45 } 42 }
46 43
47 virtual SkString onShortName() { 44 virtual SkString onShortName() {
48 return SkString("factory"); 45 return SkString("factory");
49 } 46 }
50 47
51 virtual SkISize onISize() { 48 virtual SkISize onISize() {
52 return SkISize::Make(640, 480); 49 return SkISize::Make(640, 480);
53 } 50 }
(...skipping 12 matching lines...) Expand all
66 63
67 typedef GM INHERITED; 64 typedef GM INHERITED;
68 }; 65 };
69 66
70 ////////////////////////////////////////////////////////////////////////////// 67 //////////////////////////////////////////////////////////////////////////////
71 68
72 static GM* MyFactory(void*) { return new FactoryGM; } 69 static GM* MyFactory(void*) { return new FactoryGM; }
73 static GMRegistry reg(MyFactory); 70 static GMRegistry reg(MyFactory);
74 71
75 } // namespace skiagm 72 } // namespace skiagm
OLDNEW
« no previous file with comments | « gm/etc1bitmap.cpp ('k') | gm/image.cpp » ('j') | include/core/SkImageGenerator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698