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

Side by Side Diff: tests/SkNxTest.cpp

Issue 1202013002: Update some Sk4px APIs. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fix none Created 5 years, 6 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 | « src/opts/SkNx_sse.h ('k') | 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 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 "Sk4px.h" 8 #include "Sk4px.h"
9 #include "SkNx.h" 9 #include "SkNx.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 } 168 }
169 } 169 }
170 170
171 DEF_TEST(Sk4px_muldiv255round, r) { 171 DEF_TEST(Sk4px_muldiv255round, r) {
172 for (int a = 0; a < (1<<8); a++) { 172 for (int a = 0; a < (1<<8); a++) {
173 for (int b = 0; b < (1<<8); b++) { 173 for (int b = 0; b < (1<<8); b++) {
174 int exact = (a*b+127)/255; 174 int exact = (a*b+127)/255;
175 175
176 // Duplicate a and b 16x each. 176 // Duplicate a and b 16x each.
177 Sk4px av((SkAlpha)a), 177 auto av = Sk4px::DupAlpha(a),
178 bv((SkAlpha)b); 178 bv = Sk4px::DupAlpha(b);
179 179
180 // This way should always be exactly correct. 180 // This way should always be exactly correct.
181 int correct = av.mulWiden(bv).div255RoundNarrow().kth<0>(); 181 int correct = (av * bv).div255().kth<0>();
182 REPORTER_ASSERT(r, correct == exact); 182 REPORTER_ASSERT(r, correct == exact);
183 183
184 // We're a bit more flexible on this method: correct for 0 or 255, other wise off by <=1. 184 // We're a bit more flexible on this method: correct for 0 or 255, other wise off by <=1.
185 int fast = av.fastMulDiv255Round(bv).kth<0>(); 185 int fast = av.approxMulDiv255(bv).kth<0>();
186 REPORTER_ASSERT(r, fast-exact >= -1 && fast-exact <= 1); 186 REPORTER_ASSERT(r, fast-exact >= -1 && fast-exact <= 1);
187 if (a == 0 || a == 255 || b == 0 || b == 255) { 187 if (a == 0 || a == 255 || b == 0 || b == 255) {
188 REPORTER_ASSERT(r, fast == exact); 188 REPORTER_ASSERT(r, fast == exact);
189 } 189 }
190 } 190 }
191 } 191 }
192 } 192 }
OLDNEW
« no previous file with comments | « src/opts/SkNx_sse.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698