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

Side by Side Diff: tests/PMFloatTest.cpp

Issue 1035583002: Update 4-at-a-time APIs. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: (C) 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 | « src/opts/SkPMFloat_none.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 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
1 #include "SkPMFloat.h" 8 #include "SkPMFloat.h"
2 #include "Test.h" 9 #include "Test.h"
3 10
4 DEF_TEST(SkPMFloat, r) { 11 DEF_TEST(SkPMFloat, r) {
5 // Test SkPMColor <-> SkPMFloat 12 // Test SkPMColor <-> SkPMFloat
6 SkPMColor c = SkPreMultiplyColor(0xFFCC9933); 13 SkPMColor c = SkPreMultiplyColor(0xFFCC9933);
7 SkPMFloat pmf(c); 14 SkPMFloat pmf(c);
8 REPORTER_ASSERT(r, SkScalarNearlyEqual(255.0f, pmf.a())); 15 REPORTER_ASSERT(r, SkScalarNearlyEqual(255.0f, pmf.a()));
9 REPORTER_ASSERT(r, SkScalarNearlyEqual(204.0f, pmf.r())); 16 REPORTER_ASSERT(r, SkScalarNearlyEqual(204.0f, pmf.r()));
10 REPORTER_ASSERT(r, SkScalarNearlyEqual(153.0f, pmf.g())); 17 REPORTER_ASSERT(r, SkScalarNearlyEqual(153.0f, pmf.g()));
(...skipping 15 matching lines...) Expand all
26 Sk4f fs = clamped; 33 Sk4f fs = clamped;
27 SkPMFloat scaled = fs * Sk4f(0.25f); 34 SkPMFloat scaled = fs * Sk4f(0.25f);
28 REPORTER_ASSERT(r, SkScalarNearlyEqual(63.75f, scaled.a())); 35 REPORTER_ASSERT(r, SkScalarNearlyEqual(63.75f, scaled.a()));
29 REPORTER_ASSERT(r, SkScalarNearlyEqual(38.25f, scaled.r())); 36 REPORTER_ASSERT(r, SkScalarNearlyEqual(38.25f, scaled.r()));
30 REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.25f, scaled.g())); 37 REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.25f, scaled.g()));
31 REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.00f, scaled.b())); 38 REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.00f, scaled.b()));
32 39
33 // Test 4-at-a-time conversions. 40 // Test 4-at-a-time conversions.
34 SkPMColor colors[4] = { 0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF }; 41 SkPMColor colors[4] = { 0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFF0000FF };
35 SkPMFloat floats[4]; 42 SkPMFloat floats[4];
36 SkPMFloat::From4PMColors(floats, colors); 43 SkPMFloat::From4PMColors(colors, floats+0, floats+1, floats+2, floats+3);
37 44
38 SkPMColor back[4]; 45 SkPMColor back[4];
39 SkPMFloat::To4PMColors(back, floats); 46 SkPMFloat::To4PMColors(floats[0], floats[1], floats[2], floats[3], back);
40 for (int i = 0; i < 4; i++) { 47 for (int i = 0; i < 4; i++) {
41 REPORTER_ASSERT(r, back[i] == colors[i]); 48 REPORTER_ASSERT(r, back[i] == colors[i]);
42 } 49 }
43 50
44 SkPMFloat::ClampTo4PMColors(back, floats); 51 SkPMFloat::ClampTo4PMColors(floats[0], floats[1], floats[2], floats[3], back );
45 for (int i = 0; i < 4; i++) { 52 for (int i = 0; i < 4; i++) {
46 REPORTER_ASSERT(r, back[i] == colors[i]); 53 REPORTER_ASSERT(r, back[i] == colors[i]);
47 } 54 }
48 } 55 }
OLDNEW
« no previous file with comments | « src/opts/SkPMFloat_none.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698