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

Side by Side Diff: bench/MergeBench.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 | « bench/ImageBench.cpp ('k') | bench/PDFBench.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 2013 Google Inc. 2 * Copyright 2013 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 "Benchmark.h" 8 #include "Benchmark.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkImageSource.h" 10 #include "SkImageSource.h"
(...skipping 27 matching lines...) Expand all
38 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L ARGE); 38 SkRect::MakeWH(FILTER_WIDTH_LARGE, FILTER_HEIGHT_L ARGE);
39 SkPaint paint; 39 SkPaint paint;
40 paint.setImageFilter(mergeBitmaps())->unref(); 40 paint.setImageFilter(mergeBitmaps())->unref();
41 for (int i = 0; i < loops; i++) { 41 for (int i = 0; i < loops; i++) {
42 canvas->drawRect(r, paint); 42 canvas->drawRect(r, paint);
43 } 43 }
44 } 44 }
45 45
46 private: 46 private:
47 SkImageFilter* mergeBitmaps() { 47 SkImageFilter* mergeBitmaps() {
48 SkAutoTUnref<SkImageFilter> first(SkImageSource::Create(fCheckerboard)); 48 SkAutoTUnref<SkImageFilter> first(SkImageSource::Create(fCheckerboard.ge t()));
49 SkAutoTUnref<SkImageFilter> second(SkImageSource::Create(fImage)); 49 SkAutoTUnref<SkImageFilter> second(SkImageSource::Create(fImage.get()));
50 return SkMergeImageFilter::Create(first, second); 50 return SkMergeImageFilter::Create(first, second);
51 } 51 }
52 52
53 void make_bitmap() { 53 void make_bitmap() {
54 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(80, 80)); 54 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(80, 80));
55 surface->getCanvas()->clear(0x00000000); 55 surface->getCanvas()->clear(0x00000000);
56 SkPaint paint; 56 SkPaint paint;
57 paint.setAntiAlias(true); 57 paint.setAntiAlias(true);
58 paint.setColor(0xFF884422); 58 paint.setColor(0xFF884422);
59 paint.setTextSize(SkIntToScalar(96)); 59 paint.setTextSize(SkIntToScalar(96));
60 const char* str = "g"; 60 const char* str = "g";
61 surface->getCanvas()->drawText(str, strlen(str), 15, 55, paint); 61 surface->getCanvas()->drawText(str, strlen(str), 15, 55, paint);
62 fImage.reset(surface->newImageSnapshot()); 62 fImage = surface->makeImageSnapshot();
63 } 63 }
64 64
65 void make_checkerboard() { 65 void make_checkerboard() {
66 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(80, 80)); 66 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterN32Premul(80, 80));
67 SkCanvas* canvas = surface->getCanvas(); 67 SkCanvas* canvas = surface->getCanvas();
68 canvas->clear(0x00000000); 68 canvas->clear(0x00000000);
69 SkPaint darkPaint; 69 SkPaint darkPaint;
70 darkPaint.setColor(0xFF804020); 70 darkPaint.setColor(0xFF804020);
71 SkPaint lightPaint; 71 SkPaint lightPaint;
72 lightPaint.setColor(0xFF244484); 72 lightPaint.setColor(0xFF244484);
73 for (int y = 0; y < 80; y += 16) { 73 for (int y = 0; y < 80; y += 16) {
74 for (int x = 0; x < 80; x += 16) { 74 for (int x = 0; x < 80; x += 16) {
75 canvas->save(); 75 canvas->save();
76 canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); 76 canvas->translate(SkIntToScalar(x), SkIntToScalar(y));
77 canvas->drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint); 77 canvas->drawRect(SkRect::MakeXYWH(0, 0, 8, 8), darkPaint);
78 canvas->drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint); 78 canvas->drawRect(SkRect::MakeXYWH(8, 0, 8, 8), lightPaint);
79 canvas->drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint); 79 canvas->drawRect(SkRect::MakeXYWH(0, 8, 8, 8), lightPaint);
80 canvas->drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint); 80 canvas->drawRect(SkRect::MakeXYWH(8, 8, 8, 8), darkPaint);
81 canvas->restore(); 81 canvas->restore();
82 } 82 }
83 } 83 }
84 84
85 fCheckerboard.reset(surface->newImageSnapshot()); 85 fCheckerboard = surface->makeImageSnapshot();
86 } 86 }
87 87
88 bool fIsSmall; 88 bool fIsSmall;
89 bool fInitialized; 89 bool fInitialized;
90 SkAutoTUnref<SkImage> fImage, fCheckerboard; 90 sk_sp<SkImage> fImage, fCheckerboard;
91 91
92 typedef Benchmark INHERITED; 92 typedef Benchmark INHERITED;
93 }; 93 };
94 94
95 /////////////////////////////////////////////////////////////////////////////// 95 ///////////////////////////////////////////////////////////////////////////////
96 96
97 DEF_BENCH( return new MergeBench(true); ) 97 DEF_BENCH( return new MergeBench(true); )
98 DEF_BENCH( return new MergeBench(false); ) 98 DEF_BENCH( return new MergeBench(false); )
OLDNEW
« no previous file with comments | « bench/ImageBench.cpp ('k') | bench/PDFBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698