aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/SkColor4fTest.cpp
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2016-01-22 00:04:30 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-01-22 00:04:30 -0800
commit2a2bdc698460c38ac9e24ba4abdeefec67bcba37 (patch)
treefd2660e993c369874be1966a95ebc673194aabb4 /tests/SkColor4fTest.cpp
parent7765000709dc64eb23be7df47d1f995d1f787115 (diff)
Revert of experiment: float color components (patchset #6 id:100001 of https://codereview.chromium.org/1617813002/ )
Reason for revert: broke some colormatrix tests Original issue's description: > experiment: float color components > > BUG=skia: > GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1617813002 > > Committed: https://skia.googlesource.com/skia/+/353c148d8e8c9031daca34c6f9d6bcc6f08706c7 TBR=fmalita@chromium.org,mtklein@google.com,herb@google.com # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/1623453002
Diffstat (limited to 'tests/SkColor4fTest.cpp')
-rw-r--r--tests/SkColor4fTest.cpp62
1 files changed, 0 insertions, 62 deletions
diff --git a/tests/SkColor4fTest.cpp b/tests/SkColor4fTest.cpp
deleted file mode 100644
index b09b0c479a..0000000000
--- a/tests/SkColor4fTest.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2016 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkColor.h"
-#include "SkShader.h"
-#include "SkColorMatrixFilter.h"
-#include "Test.h"
-#include "SkRandom.h"
-
-DEF_TEST(SkColor4f_FromColor, reporter) {
- const struct {
- SkColor fC;
- SkColor4f fC4;
- } recs[] = {
- { SK_ColorBLACK, { 1, 0, 0, 0 } },
- { SK_ColorWHITE, { 1, 1, 1, 1 } },
- { SK_ColorRED, { 1, 1, 0, 0 } },
- { SK_ColorGREEN, { 1, 0, 1, 0 } },
- { SK_ColorBLUE, { 1, 0, 0, 1 } },
- { 0, { 0, 0, 0, 0 } },
- { 0x55AAFF00, { 1/3.0f, 2/3.0f, 1, 0 } },
- };
-
- for (const auto& r : recs) {
- SkColor4f c4 = SkColor4f::FromColor(r.fC);
- REPORTER_ASSERT(reporter, c4 == r.fC4);
- }
-}
-
-static bool nearly_equal(float a, float b) {
- const float kTolerance = 1.0f / (1 << 20);
- return fabsf(a - b) < kTolerance;
-}
-
-DEF_TEST(SkColor4f_premul, reporter) {
- SkRandom rand;
-
- for (int i = 0; i < 1000000; ++i) {
- // First just test opaque colors, so that the premul should be exact
- SkColor4f c4 {
- 1, rand.nextUScalar1(), rand.nextUScalar1(), rand.nextUScalar1()
- };
- SkPM4f pm4 = c4.premul();
- REPORTER_ASSERT(reporter, pm4.fVec[SK_A_INDEX] == c4.fA);
- REPORTER_ASSERT(reporter, pm4.fVec[SK_R_INDEX] == c4.fA * c4.fR);
- REPORTER_ASSERT(reporter, pm4.fVec[SK_G_INDEX] == c4.fA * c4.fG);
- REPORTER_ASSERT(reporter, pm4.fVec[SK_B_INDEX] == c4.fA * c4.fB);
-
- // We compare with a tolerance, in case our premul multiply is implemented at slightly
- // different precision than the test code.
- c4.fA = rand.nextUScalar1();
- pm4 = c4.premul();
- REPORTER_ASSERT(reporter, pm4.fVec[SK_A_INDEX] == c4.fA);
- REPORTER_ASSERT(reporter, nearly_equal(pm4.fVec[SK_R_INDEX], c4.fA * c4.fR));
- REPORTER_ASSERT(reporter, nearly_equal(pm4.fVec[SK_G_INDEX], c4.fA * c4.fG));
- REPORTER_ASSERT(reporter, nearly_equal(pm4.fVec[SK_B_INDEX], c4.fA * c4.fB));
- }
-}