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

Side by Side Diff: bench/PMFloatBench.cpp

Issue 1048593002: Refactor Sk2x<T> + Sk4x<T> into SkNf<N,T> and SkNi<N,T> (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: This is actually faster Created 5 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 | gyp/tests.gypi » ('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 2015 Google Inc. 2 * Copyright 2015 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 "SkPMFloat.h" 9 #include "SkPMFloat.h"
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 DEF_BENCH(return (new PMFloatGetSetBench<false, true>);) 96 DEF_BENCH(return (new PMFloatGetSetBench<false, true>);)
97 DEF_BENCH(return (new PMFloatGetSetBench< true, false>);) 97 DEF_BENCH(return (new PMFloatGetSetBench< true, false>);)
98 DEF_BENCH(return (new PMFloatGetSetBench<false, false>);) 98 DEF_BENCH(return (new PMFloatGetSetBench<false, false>);)
99 99
100 struct PMFloatGradientBench : public Benchmark { 100 struct PMFloatGradientBench : public Benchmark {
101 const char* onGetName() override { return "PMFloat_gradient"; } 101 const char* onGetName() override { return "PMFloat_gradient"; }
102 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; } 102 bool isSuitableFor(Backend backend) override { return backend == kNonRenderi ng_Backend; }
103 103
104 SkPMColor fDevice[100]; 104 SkPMColor fDevice[100];
105 void onDraw(const int loops, SkCanvas*) override { 105 void onDraw(const int loops, SkCanvas*) override {
106 Sk4f c0 = SkPMFloat::FromARGB(255, 255, 0, 0), 106 Sk4s c0 = SkPMFloat::FromARGB(255, 255, 0, 0),
107 c1 = SkPMFloat::FromARGB(255, 0, 0, 255), 107 c1 = SkPMFloat::FromARGB(255, 0, 0, 255),
108 dc = c1 - c0, 108 dc = c1 - c0,
109 fx(0.1f), 109 fx(0.1f),
110 dx(0.002f), 110 dx(0.002f),
111 dcdx(dc*dx), 111 dcdx(dc*dx),
112 dcdx4(dcdx+dcdx+dcdx+dcdx); 112 dcdx4(dcdx+dcdx+dcdx+dcdx);
113 113
114 for (int n = 0; n < loops; n++) { 114 for (int n = 0; n < loops; n++) {
115 Sk4f a = c0 + dc*fx + Sk4f(0.5f), // The +0.5f lets us call trunc() instead of get(). 115 Sk4s a = c0 + dc*fx + Sk4s(0.5f), // The +0.5f lets us call trunc() instead of get().
116 b = a + dcdx, 116 b = a + dcdx,
117 c = b + dcdx, 117 c = b + dcdx,
118 d = c + dcdx; 118 d = c + dcdx;
119 for (size_t i = 0; i < SK_ARRAY_COUNT(fDevice); i += 4) { 119 for (size_t i = 0; i < SK_ARRAY_COUNT(fDevice); i += 4) {
120 fDevice[i+0] = SkPMFloat(a).trunc(); 120 fDevice[i+0] = SkPMFloat(a).trunc();
121 fDevice[i+1] = SkPMFloat(b).trunc(); 121 fDevice[i+1] = SkPMFloat(b).trunc();
122 fDevice[i+2] = SkPMFloat(c).trunc(); 122 fDevice[i+2] = SkPMFloat(c).trunc();
123 fDevice[i+3] = SkPMFloat(d).trunc(); 123 fDevice[i+3] = SkPMFloat(d).trunc();
124 a += dcdx4; 124 a += dcdx4;
125 b += dcdx4; 125 b += dcdx4;
126 c += dcdx4; 126 c += dcdx4;
127 d += dcdx4; 127 d += dcdx4;
128 } 128 }
129 } 129 }
130 } 130 }
131 }; 131 };
132 132
133 DEF_BENCH(return new PMFloatGradientBench;) 133 DEF_BENCH(return new PMFloatGradientBench;)
OLDNEW
« no previous file with comments | « no previous file | gyp/tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698