diff options
author | mtklein <mtklein@chromium.org> | 2015-02-23 10:04:34 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-23 10:04:34 -0800 |
commit | a2f4be76a9d453f1fdfd55b0cec6a683f23ffe0f (patch) | |
tree | 13f48c73eb97b4d554293afb87f1f75860287379 /tests | |
parent | 9c007f23c17245a242bffe0f6e88719291b8142f (diff) |
Sketch SkPMFloat
BUG=skia:
Committed: https://skia.googlesource.com/skia/+/50d2b3114b3e59dc84811881591bf25b2c1ecb9f
CQ_EXTRA_TRYBOTS=client.skia.compile:Build-Ubuntu13.10-GCC4.8-Arm7-Release-Android_Neon-Trybot
http://build.chromium.org/p/client.skia.compile/builders/Build-Ubuntu13.10-GCC4.8-Arm7-Release-Android_Neon/builds/2120/steps/build%20most/logs/stdio
Review URL: https://codereview.chromium.org/936633002
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PMFloatTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/PMFloatTest.cpp b/tests/PMFloatTest.cpp new file mode 100644 index 0000000000..94cd663a53 --- /dev/null +++ b/tests/PMFloatTest.cpp @@ -0,0 +1,29 @@ +#include "SkPMFloat.h" +#include "Test.h" + +DEF_TEST(SkPMFloat, r) { + SkPMColor c = SkPreMultiplyColor(0xFFCC9933); + + 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, c == pmf.get()); + + SkPMFloat unclamped; + unclamped.setA(+2.0f); + unclamped.setR(+0.2f); + unclamped.setG(-0.2f); + unclamped.setB(-5.0f); + + 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())); +} |