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

Unified Diff: tests/PMFloatTest.cpp

Issue 954323002: add auto SkPMFloat <-> Sk4f conversion (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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
« no previous file with comments | « src/core/SkPMFloat.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 94cd663a5331d5f1a4a8ee3644329491e2647291..f722e80839ab2a20e9cca61b682a4a5131b6d160 100644
--- a/tests/PMFloatTest.cpp
+++ b/tests/PMFloatTest.cpp
@@ -2,6 +2,7 @@
#include "Test.h"
DEF_TEST(SkPMFloat, r) {
+ // Test SkPMColor <-> SkPMFloat
SkPMColor c = SkPreMultiplyColor(0xFFCC9933);
SkPMFloat pmf;
@@ -13,6 +14,7 @@ DEF_TEST(SkPMFloat, r) {
REPORTER_ASSERT(r, c == pmf.get());
+ // Test clamping.
SkPMFloat unclamped;
unclamped.setA(+2.0f);
unclamped.setR(+0.2f);
@@ -26,4 +28,13 @@ DEF_TEST(SkPMFloat, r) {
REPORTER_ASSERT(r, SkScalarNearlyEqual(0.2f, clamped.r()));
REPORTER_ASSERT(r, SkScalarNearlyEqual(0.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));
+
+ 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()));
}
« no previous file with comments | « src/core/SkPMFloat.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698