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

Side by Side Diff: gm/astcbitmap.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 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 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" 13 #include "SkImageGenerator.h"
14 #include "SkImageDecoder.h" 14 #include "SkImageDecoder.h"
15 #include "SkOSFile.h" 15 #include "SkOSFile.h"
16 #include "SkTextureCompressor.h" 16 #include "SkTextureCompressor.h"
17 17
18 static const char *kASTCFilenames[] = { 18 static const char *kASTCFilenames[] = {
19 "mandrill_128x128_4x4.astc", // kASTC_4x4_Format 19 "mandrill_128x128_4x4.astc", // kASTC_4x4_Format
20 "mandrill_130x128_5x4.astc", // kASTC_5x4_Format 20 "mandrill_130x128_5x4.astc", // kASTC_5x4_Format
21 "mandrill_130x130_5x5.astc", // kASTC_5x5_Format 21 "mandrill_130x130_5x5.astc", // kASTC_5x5_Format
22 "mandrill_132x130_6x5.astc", // kASTC_6x5_Format 22 "mandrill_132x130_6x5.astc", // kASTC_6x5_Format
23 "mandrill_132x132_6x6.astc", // kASTC_6x6_Format 23 "mandrill_132x132_6x6.astc", // kASTC_6x6_Format
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 continue; 69 continue;
70 } 70 }
71 71
72 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c _str())); 72 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c _str()));
73 if (NULL == fileData) { 73 if (NULL == fileData) {
74 SkDebugf("Could not open the file. Did you forget to set the resourcePath?\n"); 74 SkDebugf("Could not open the file. Did you forget to set the resourcePath?\n");
75 return; 75 return;
76 } 76 }
77 77
78 SkBitmap bm; 78 SkBitmap bm;
79 if (!SkInstallDiscardablePixelRef( 79 if (!SkInstallDiscardablePixelRef(fileData, &bm)) {
80 SkDecodingImageGenerator::Create(
81 fileData, SkDecodingImageGenerator::Options()), &bm) ) {
82 SkDebugf("Could not install discardable pixel ref.\n"); 80 SkDebugf("Could not install discardable pixel ref.\n");
83 return; 81 return;
84 } 82 }
85 83
86 const SkScalar bmX = static_cast<SkScalar>(i*kBitmapDimension); 84 const SkScalar bmX = static_cast<SkScalar>(i*kBitmapDimension);
87 const SkScalar bmY = static_cast<SkScalar>(j*kBitmapDimension); 85 const SkScalar bmY = static_cast<SkScalar>(j*kBitmapDimension);
88 canvas->drawBitmap(bm, bmX, bmY); 86 canvas->drawBitmap(bm, bmX, bmY);
89 } 87 }
90 } 88 }
91 } 89 }
92 90
93 private: 91 private:
94 static const int kGMDimension = 600; 92 static const int kGMDimension = 600;
95 static const int kBitmapDimension = kGMDimension/4; 93 static const int kBitmapDimension = kGMDimension/4;
96 94
97 typedef GM INHERITED; 95 typedef GM INHERITED;
98 }; 96 };
99 97
100 } // namespace skiagm 98 } // namespace skiagm
101 99
102 ////////////////////////////////////////////////////////////////////////////// 100 //////////////////////////////////////////////////////////////////////////////
103 101
104 DEF_GM( return SkNEW(skiagm::ASTCBitmapGM); ) 102 DEF_GM( return SkNEW(skiagm::ASTCBitmapGM); )
OLDNEW
« no previous file with comments | « bench/ETCBitmapBench.cpp ('k') | gm/colorwheel.cpp » ('j') | include/core/SkImageGenerator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698