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

Side by Side Diff: gm/image.cpp

Issue 1473373002: optimize the disable-caching case for SkImage::readPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | « no previous file | src/core/SkImageCacherator.h » ('j') | src/core/SkImageCacherator.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 #include "SkData.h" 9 #include "SkData.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 SkAutoCanvasRestore acr(canvas, true); 207 SkAutoCanvasRestore acr(canvas, true);
208 208
209 canvas->drawImage(image, 0, 0, nullptr); 209 canvas->drawImage(image, 0, 0, nullptr);
210 canvas->translate(110, 10); 210 canvas->translate(110, 10);
211 211
212 const SkImageInfo info = SkImageInfo::MakeN32Premul(40, 40); 212 const SkImageInfo info = SkImageInfo::MakeN32Premul(40, 40);
213 SkAutoPixmapStorage storage; 213 SkAutoPixmapStorage storage;
214 storage.alloc(info); 214 storage.alloc(info);
215 215
216 const SkImage::CachingHint chints[] = { 216 const SkImage::CachingHint chints[] = {
217 SkImage::kAllow_CachingHint, // SkImage::kDisallow_CachingHint, 217 SkImage::kAllow_CachingHint, SkImage::kDisallow_CachingHint,
218 }; 218 };
219 const SkFilterQuality qualities[] = { 219 const SkFilterQuality qualities[] = {
220 kNone_SkFilterQuality, kLow_SkFilterQuality, kMedium_SkFilterQuality, kH igh_SkFilterQuality, 220 kNone_SkFilterQuality, kLow_SkFilterQuality, kMedium_SkFilterQuality, kH igh_SkFilterQuality,
221 }; 221 };
222 222
223 for (auto ch : chints) { 223 for (auto ch : chints) {
224 canvas->save(); 224 canvas->save();
225 for (auto q : qualities) { 225 for (auto q : qualities) {
226 if (image->scalePixels(storage, q, ch)) { 226 if (image->scalePixels(storage, q, ch)) {
227 draw_pixmap(canvas, storage); 227 draw_pixmap(canvas, storage);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 SkISize onISize() override { 280 SkISize onISize() override {
281 return SkISize::Make(960, 1200); 281 return SkISize::Make(960, 1200);
282 } 282 }
283 283
284 void onDraw(SkCanvas* canvas) override { 284 void onDraw(SkCanvas* canvas) override {
285 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100); 285 const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
286 286
287 const ImageMakerProc procs[] = { 287 const ImageMakerProc procs[] = {
288 make_raster, make_picture, make_codec, make_gpu, 288 make_codec, make_raster, make_picture, make_codec, make_gpu,
289 }; 289 };
290 for (auto& proc : procs) { 290 for (auto& proc : procs) {
291 SkAutoTUnref<SkImage> image(proc(info, canvas->getGrContext())); 291 SkAutoTUnref<SkImage> image(proc(info, canvas->getGrContext()));
292 if (image) { 292 if (image) {
293 show_scaled_pixels(canvas, image); 293 show_scaled_pixels(canvas, image);
294 } 294 }
295 canvas->translate(0, 120); 295 canvas->translate(0, 120);
296 } 296 }
297 } 297 }
298 298
299 private: 299 private:
300 typedef skiagm::GM INHERITED; 300 typedef skiagm::GM INHERITED;
301 }; 301 };
302 DEF_GM( return new ScalePixelsGM; ) 302 DEF_GM( return new ScalePixelsGM; )
OLDNEW
« no previous file with comments | « no previous file | src/core/SkImageCacherator.h » ('j') | src/core/SkImageCacherator.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698