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

Side by Side Diff: gm/etc1bitmap.cpp

Issue 1810813003: update callsites for Make image factories (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: start to take advantage of sk_sp drawImage Created 4 years, 9 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/drawminibitmaprect.cpp ('k') | gm/filterfastbounds.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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 SkISize onISize() override { 91 SkISize onISize() override {
92 return SkISize::Make(128, 128); 92 return SkISize::Make(128, 128);
93 } 93 }
94 94
95 virtual SkString fileExtension() const = 0; 95 virtual SkString fileExtension() const = 0;
96 96
97 void onDraw(SkCanvas* canvas) override { 97 void onDraw(SkCanvas* canvas) override {
98 SkBitmap bm; 98 SkBitmap bm;
99 SkString filename = GetResourcePath("mandrill_128."); 99 SkString filename = GetResourcePath("mandrill_128.");
100 filename.append(this->fileExtension()); 100 filename.append(this->fileExtension());
101 SkAutoTUnref<SkData> fileData(SkData::NewFromFileName(filename.c_str())) ; 101 sk_sp<SkData> fileData(SkData::MakeFromFileName(filename.c_str()));
102 if (nullptr == fileData) { 102 if (nullptr == fileData) {
103 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n"); 103 SkDebugf("Could not open the file. Did you forget to set the resourc ePath?\n");
104 return; 104 return;
105 } 105 }
106 106
107 SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(fileData)); 107 sk_sp<SkImage> image(SkImage::MakeFromEncoded(std::move(fileData)));
108 if (nullptr == image) { 108 if (nullptr == image) {
109 SkDebugf("Could not decode the ETC file. ETC may not be included in this platform.\n"); 109 SkDebugf("Could not decode the ETC file. ETC may not be included in this platform.\n");
110 return; 110 return;
111 } 111 }
112 canvas->drawImage(image, 0, 0); 112 canvas->drawImage(image, 0, 0);
113 } 113 }
114 114
115 private: 115 private:
116 typedef GM INHERITED; 116 typedef GM INHERITED;
117 }; 117 };
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 int width, height; 194 int width, height;
195 if (!slice_etc1_data(am.get(), &width, &height)) { 195 if (!slice_etc1_data(am.get(), &width, &height)) {
196 SkDebugf("ETC1 Data is poorly formatted.\n"); 196 SkDebugf("ETC1 Data is poorly formatted.\n");
197 return; 197 return;
198 } 198 }
199 199
200 SkASSERT(124 == width); 200 SkASSERT(124 == width);
201 SkASSERT(124 == height); 201 SkASSERT(124 == height);
202 202
203 size_t dataSz = etc1_get_encoded_data_size(width, height) + ETC_PKM_HEAD ER_SIZE; 203 size_t dataSz = etc1_get_encoded_data_size(width, height) + ETC_PKM_HEAD ER_SIZE;
204 SkAutoDataUnref nonPOTData(SkData::NewWithCopy(am.get(), dataSz)); 204 sk_sp<SkData> nonPOTData(SkData::MakeWithCopy(am.get(), dataSz));
205 205 canvas->drawImage(SkImage::MakeFromEncoded(std::move(nonPOTData)).get(), 0, 0);
206 SkAutoTUnref<SkImage> image(SkImage::NewFromEncoded(nonPOTData));
207 canvas->drawImage(image, 0, 0);
208 } 206 }
209 207
210 private: 208 private:
211 typedef GM INHERITED; 209 typedef GM INHERITED;
212 }; 210 };
213 #endif // SK_IGNORE_ETC1_SUPPORT 211 #endif // SK_IGNORE_ETC1_SUPPORT
214 212
215 } // namespace skiagm 213 } // namespace skiagm
216 214
217 ////////////////////////////////////////////////////////////////////////////// 215 //////////////////////////////////////////////////////////////////////////////
218 216
219 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;) 217 DEF_GM(return new skiagm::ETC1Bitmap_PKM_GM;)
220 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;) 218 DEF_GM(return new skiagm::ETC1Bitmap_KTX_GM;)
221 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;) 219 DEF_GM(return new skiagm::ETC1Bitmap_R11_KTX_GM;)
222 220
223 #ifndef SK_IGNORE_ETC1_SUPPORT 221 #ifndef SK_IGNORE_ETC1_SUPPORT
224 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;) 222 DEF_GM(return new skiagm::ETC1Bitmap_NPOT_GM;)
225 #endif // SK_IGNORE_ETC1_SUPPORT 223 #endif // SK_IGNORE_ETC1_SUPPORT
OLDNEW
« no previous file with comments | « gm/drawminibitmaprect.cpp ('k') | gm/filterfastbounds.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698