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

Side by Side Diff: gm/etc1bitmap.cpp

Issue 351133003: Cleanup usage of GetResourcePath() after commit bcbc1788b478b1e54079318ad073e8490aa66fae. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 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
« no previous file with comments | « gm/downsamplebitmap.cpp ('k') | gm/factory.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 } 88 }
89 89
90 virtual SkISize onISize() SK_OVERRIDE { 90 virtual SkISize onISize() SK_OVERRIDE {
91 return SkISize::Make(128, 128); 91 return SkISize::Make(128, 128);
92 } 92 }
93 93
94 virtual SkString fileExtension() const = 0; 94 virtual SkString fileExtension() const = 0;
95 95
96 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 96 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
97 SkBitmap bm; 97 SkBitmap bm;
98 SkString resourcePath = GetResourcePath(); 98 SkString filename = GetResourcePath("mandrill_128.");
99 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill _128.");
100 filename.append(this->fileExtension()); 99 filename.append(this->fileExtension());
101
102 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ; 100 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ;
103 if (NULL == fileData) { 101 if (NULL == fileData) {
104 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n"); 102 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n");
105 return; 103 return;
106 } 104 }
107 105
108 if (!SkInstallDiscardablePixelRef( 106 if (!SkInstallDiscardablePixelRef(
109 SkDecodingImageGenerator::Create( 107 SkDecodingImageGenerator::Create(
110 fileData, SkDecodingImageGenerator::Options()), &bm)) { 108 fileData, SkDecodingImageGenerator::Options()), &bm)) {
111 SkDebugf("Could not install discardable pixel ref.\n"); 109 SkDebugf("Could not install discardable pixel ref.\n");
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 virtual SkString onShortName() SK_OVERRIDE { 161 virtual SkString onShortName() SK_OVERRIDE {
164 return SkString("etc1bitmap_npot"); 162 return SkString("etc1bitmap_npot");
165 } 163 }
166 164
167 virtual SkISize onISize() SK_OVERRIDE { 165 virtual SkISize onISize() SK_OVERRIDE {
168 return SkISize::Make(124, 124); 166 return SkISize::Make(124, 124);
169 } 167 }
170 168
171 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE { 169 virtual void onDraw(SkCanvas* canvas) SK_OVERRIDE {
172 SkBitmap bm; 170 SkBitmap bm;
173 SkString resourcePath = GetResourcePath(); 171 SkString pkmFilename = GetResourcePath("mandrill_128.pkm");
174 SkString filename = SkOSPath::SkPathJoin(resourcePath.c_str(), "mandrill _128.pkm"); 172 SkAutoDataUnref fileData(SkData::NewFromFileName(pkmFilename.c_str()));
175
176 SkAutoDataUnref fileData(SkData::NewFromFileName(filename.c_str()));
177 if (NULL == fileData) { 173 if (NULL == fileData) {
178 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n"); 174 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n");
179 return; 175 return;
180 } 176 }
181 177
182 SkAutoMalloc am(fileData->size()); 178 SkAutoMalloc am(fileData->size());
183 memcpy(am.get(), fileData->data(), fileData->size()); 179 memcpy(am.get(), fileData->data(), fileData->size());
184 180
185 int width, height; 181 int width, height;
186 if (!slice_etc1_data(am.get(), &width, &height)) { 182 if (!slice_etc1_data(am.get(), &width, &height)) {
(...skipping 25 matching lines...) Expand all
212 } // namespace skiagm 208 } // namespace skiagm
213 209
214 ////////////////////////////////////////////////////////////////////////////// 210 //////////////////////////////////////////////////////////////////////////////
215 211
216 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); ) 212 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_PKM_GM); )
217 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); ) 213 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_KTX_GM); )
218 214
219 #ifndef SK_IGNORE_ETC1_SUPPORT 215 #ifndef SK_IGNORE_ETC1_SUPPORT
220 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); ) 216 DEF_GM( return SkNEW(skiagm::ETC1Bitmap_NPOT_GM); )
221 #endif // SK_IGNORE_ETC1_SUPPORT 217 #endif // SK_IGNORE_ETC1_SUPPORT
OLDNEW
« no previous file with comments | « gm/downsamplebitmap.cpp ('k') | gm/factory.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698