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

Side by Side Diff: bench/PMFloatBench.cpp

Issue 1032243002: SkPMFloat::trunc() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove isValid assert in _none trunc() Created 5 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 | « HASHTAGS ('k') | src/core/SkPMFloat.h » ('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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 Sk4f 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, // TODO: add 0.5f, here call trunc() instead o f get(). 115 Sk4f a = c0 + dc*fx + Sk4f(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).get(); 120 fDevice[i+0] = SkPMFloat(a).trunc();
121 fDevice[i+1] = SkPMFloat(b).get(); 121 fDevice[i+1] = SkPMFloat(b).trunc();
122 fDevice[i+2] = SkPMFloat(c).get(); 122 fDevice[i+2] = SkPMFloat(c).trunc();
123 fDevice[i+3] = SkPMFloat(d).get(); 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 | « HASHTAGS ('k') | src/core/SkPMFloat.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698