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

Unified Diff: tests/PMFloatTest.cpp

Issue 973603002: Make SkPMFloats store floats in [0,255] instead of [0,1]. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: restore comment Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« src/opts/SkPMFloat_SSE2.h ('K') | « src/opts/SkPMFloat_none.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PMFloatTest.cpp
diff --git a/tests/PMFloatTest.cpp b/tests/PMFloatTest.cpp
index f722e80839ab2a20e9cca61b682a4a5131b6d160..fceeb47fa127538cbcff0f4521b4ed5f65713974 100644
--- a/tests/PMFloatTest.cpp
+++ b/tests/PMFloatTest.cpp
@@ -7,34 +7,34 @@ DEF_TEST(SkPMFloat, r) {
SkPMFloat pmf;
pmf.set(c);
- REPORTER_ASSERT(r, SkScalarNearlyEqual(1.0f, pmf.a()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.8f, pmf.r()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.6f, pmf.g()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.2f, pmf.b()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual(255.0f, pmf.a()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual(204.0f, pmf.r()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual(153.0f, pmf.g()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual( 51.0f, pmf.b()));
REPORTER_ASSERT(r, c == pmf.get());
// Test clamping.
SkPMFloat unclamped;
- unclamped.setA(+2.0f);
- unclamped.setR(+0.2f);
- unclamped.setG(-0.2f);
- unclamped.setB(-5.0f);
+ unclamped.setA(+510.0f);
+ unclamped.setR(+153.0f);
+ unclamped.setG( +1.0f);
+ unclamped.setB( -0.2f);
SkPMFloat clamped;
clamped.set(unclamped.clamped());
- REPORTER_ASSERT(r, SkScalarNearlyEqual(1.0f, clamped.a()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.2f, clamped.r()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.0f, clamped.g()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.0f, clamped.b()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual(255.0f, clamped.a()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual(153.0f, clamped.r()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual( 1.0f, clamped.g()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.0f, clamped.b()));
// Test SkPMFloat <-> Sk4f conversion.
Sk4f fs = clamped;
- SkPMFloat scaled = fs.multiply(Sk4f(4,4,4,4));
+ SkPMFloat scaled = fs.multiply(0.25f);
- REPORTER_ASSERT(r, SkScalarNearlyEqual(4.0f, scaled.a()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.8f, scaled.r()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.0f, scaled.g()));
- REPORTER_ASSERT(r, SkScalarNearlyEqual(0.0f, scaled.b()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual(63.75f, scaled.a()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual(38.25f, scaled.r()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.25f, scaled.g()));
+ REPORTER_ASSERT(r, SkScalarNearlyEqual( 0.00f, scaled.b()));
}
« src/opts/SkPMFloat_SSE2.h ('K') | « src/opts/SkPMFloat_none.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698