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

Side by Side Diff: bench/XfermodeBench.cpp

Issue 1868333002: Add some benches for SkArithmeticMode. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Speculative win32 fix Created 4 years, 8 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 | « no previous file | no next file » | 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 "SkArithmeticMode.h"
9 #include "SkCanvas.h" 10 #include "SkCanvas.h"
10 #include "SkPaint.h" 11 #include "SkPaint.h"
11 #include "SkRandom.h" 12 #include "SkRandom.h"
12 #include "SkString.h" 13 #include "SkString.h"
13 #include "SkXfermode.h" 14 #include "SkXfermode.h"
14 15
15 // Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode. 16 // Benchmark that draws non-AA rects or AA text with an SkXfermode::Mode.
16 class XfermodeBench : public Benchmark { 17 class XfermodeBench : public Benchmark {
17 public: 18 public:
18 XfermodeBench(SkXfermode::Mode mode, bool aa) { 19 XfermodeBench(SkXfermode::Mode mode, bool aa) {
19 fXfermode = SkXfermode::Make(mode); 20 fXfermode = SkXfermode::Make(mode);
20 fAA = aa; 21 fAA = aa;
21 SkASSERT(fXfermode.get() || SkXfermode::kSrcOver_Mode == mode); 22 SkASSERT(fXfermode.get() || SkXfermode::kSrcOver_Mode == mode);
22 fName.printf("Xfermode_%s%s", SkXfermode::ModeName(mode), aa ? "_aa" : " "); 23 fName.printf("Xfermode_%s%s", SkXfermode::ModeName(mode), aa ? "_aa" : " ");
23 } 24 }
24 25
25 XfermodeBench(SkXfermode* xferMode, const char* name, bool aa) { 26 XfermodeBench(sk_sp<SkXfermode> xferMode, const char* name, bool aa) {
26 SkASSERT(xferMode); 27 fXfermode = xferMode;
27 fXfermode.reset(xferMode);
28 fAA = aa; 28 fAA = aa;
29 fName.printf("Xfermode_%s%s", name, aa ? "_aa" : ""); 29 fName.printf("Xfermode_%s%s", name, aa ? "_aa" : "");
30 } 30 }
31 31
32 protected: 32 protected:
33 const char* onGetName() override { return fName.c_str(); } 33 const char* onGetName() override { return fName.c_str(); }
34 34
35 void onDraw(int loops, SkCanvas* canvas) override { 35 void onDraw(int loops, SkCanvas* canvas) override {
36 const char* text = "Hamburgefons"; 36 const char* text = "Hamburgefons";
37 size_t len = strlen(text); 37 size_t len = strlen(text);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 BENCH(SkXfermode::kSoftLight_Mode) 128 BENCH(SkXfermode::kSoftLight_Mode)
129 BENCH(SkXfermode::kDifference_Mode) 129 BENCH(SkXfermode::kDifference_Mode)
130 BENCH(SkXfermode::kExclusion_Mode) 130 BENCH(SkXfermode::kExclusion_Mode)
131 BENCH(SkXfermode::kMultiply_Mode) 131 BENCH(SkXfermode::kMultiply_Mode)
132 132
133 BENCH(SkXfermode::kHue_Mode) 133 BENCH(SkXfermode::kHue_Mode)
134 BENCH(SkXfermode::kSaturation_Mode) 134 BENCH(SkXfermode::kSaturation_Mode)
135 BENCH(SkXfermode::kColor_Mode) 135 BENCH(SkXfermode::kColor_Mode)
136 BENCH(SkXfermode::kLuminosity_Mode) 136 BENCH(SkXfermode::kLuminosity_Mode)
137 137
138 DEF_BENCH( return new XfermodeBench(SkArithmeticMode::Make(0.2f, -0.3f, 1.5f, -0 .7f, false), \
139 "arithmetic", false); )
140 DEF_BENCH( return new XfermodeBench(SkArithmeticMode::Make(0.2f, -0.3f, 1.5f, -0 .7f, true), \
141 "arithmetic_enforce_pm", false); )
142 DEF_BENCH( return new XfermodeBench(SkArithmeticMode::Make(0.2f, -0.3f, 1.5f, -0 .7f, false), \
143 "arithmetic", true); )
144 DEF_BENCH( return new XfermodeBench(SkArithmeticMode::Make(0.2f, -0.3f, 1.5f, -0 .7f, true), \
145 "arithmetic_enforce_pm", true); )
146
138 DEF_BENCH(return new XferCreateBench;) 147 DEF_BENCH(return new XferCreateBench;)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698