aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gn/core.gni2
-rw-r--r--gn/tests.gni1
-rw-r--r--src/core/SkColorSpace_New.cpp130
-rw-r--r--src/core/SkColorSpace_New.h78
-rw-r--r--tests/SkColorSpace_NewTest.cpp93
5 files changed, 0 insertions, 304 deletions
diff --git a/gn/core.gni b/gn/core.gni
index 5af4f6abac..c02eec6943 100644
--- a/gn/core.gni
+++ b/gn/core.gni
@@ -78,8 +78,6 @@ skia_core_sources = [
"$_src/core/SkColorSpace.cpp",
"$_src/core/SkColorSpace_A2B.cpp",
"$_src/core/SkColorSpace_A2B.h",
- "$_src/core/SkColorSpace_New.cpp",
- "$_src/core/SkColorSpace_New.h",
"$_src/core/SkColorSpace_XYZ.cpp",
"$_src/core/SkColorSpace_XYZ.h",
"$_src/core/SkColorSpace_ICC.cpp",
diff --git a/gn/tests.gni b/gn/tests.gni
index ebf83bbd63..68f4f829fa 100644
--- a/gn/tests.gni
+++ b/gn/tests.gni
@@ -217,7 +217,6 @@ tests_sources = [
"$_tests/skbug6389.cpp",
"$_tests/skbug6653.cpp",
"$_tests/SkColor4fTest.cpp",
- "$_tests/SkColorSpace_NewTest.cpp",
"$_tests/SkDOMTest.cpp",
"$_tests/SkFixed15Test.cpp",
"$_tests/SkGaussFilterTest.cpp",
diff --git a/src/core/SkColorSpace_New.cpp b/src/core/SkColorSpace_New.cpp
deleted file mode 100644
index 5db388d07a..0000000000
--- a/src/core/SkColorSpace_New.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkColorSpace_New.h"
-#include "SkOpts.h"
-#include "SkRasterPipeline.h"
-
-// ~~~~~~~~~~~~~~~~~~~~~~~ SkColorSpace_New::TransferFn ~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
-
-namespace {
-
- struct LinearTransferFn : public SkColorSpace_New::TransferFn {
- SkColorSpaceTransferFn parameterize() const override {
- return { 1,1, 0,0,0,0,0 };
- }
-
- void linearizeDst(SkRasterPipeline*) const override {}
- void linearizeSrc(SkRasterPipeline*) const override {}
- void encodeSrc(SkRasterPipeline*) const override {}
- };
-
- struct SRGBTransferFn : public SkColorSpace_New::TransferFn {
- SkColorSpaceTransferFn parameterize() const override {
- return { 2.4f, 1/1.055f, 0.055f/1.055f, 1/12.92f, 0.04045f, 0, 0 };
- }
-
- void linearizeDst(SkRasterPipeline* p) const override {
- p->append(SkRasterPipeline::from_srgb_dst);
- }
- void linearizeSrc(SkRasterPipeline* p) const override {
- p->append(SkRasterPipeline::from_srgb);
- }
- void encodeSrc(SkRasterPipeline* p) const override {
- p->append(SkRasterPipeline::to_srgb);
- }
- };
-
- struct GammaTransferFn : public SkColorSpace_New::TransferFn {
- float fGamma;
- float fInv;
-
- explicit GammaTransferFn(float gamma) : fGamma(gamma), fInv(1.0f/gamma) {}
-
- SkColorSpaceTransferFn parameterize() const override {
- return { fGamma, 1, 0,0,0,0,0 };
- }
-
- void linearizeDst(SkRasterPipeline* p) const override {
- p->append(SkRasterPipeline::gamma_dst, &fGamma);
- }
- void linearizeSrc(SkRasterPipeline* p) const override {
- p->append(SkRasterPipeline::gamma, &fGamma);
- }
- void encodeSrc(SkRasterPipeline* p) const override {
- p->append(SkRasterPipeline::gamma, &fInv);
- }
- };
-
-}
-
-sk_sp<SkColorSpace_New::TransferFn> SkColorSpace_New::TransferFn::MakeLinear() {
- return sk_make_sp<LinearTransferFn>();
-}
-sk_sp<SkColorSpace_New::TransferFn> SkColorSpace_New::TransferFn::MakeSRGB() {
- return sk_make_sp<SRGBTransferFn>();
-}
-sk_sp<SkColorSpace_New::TransferFn> SkColorSpace_New::TransferFn::MakeGamma(float gamma) {
- if (gamma == 1) {
- return MakeLinear();
- }
- return sk_make_sp<GammaTransferFn>(gamma);
-}
-
-bool SkColorSpace_New::TransferFn::equals(const SkColorSpace_New::TransferFn& other) const {
- SkColorSpaceTransferFn a = this->parameterize(),
- b = other.parameterize();
- return 0 == memcmp(&a,&b, sizeof(SkColorSpaceTransferFn));
-}
-
-void SkColorSpace_New::TransferFn::updateICCProfile(ICCProfile*) const {
- // TODO
-}
-
-// ~~~~~~~~~~~~~~~~~~~~~~~ SkColorSpace_New ~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
-
-SkColorSpace_New::SkColorSpace_New(sk_sp<TransferFn> transferFn,
- SkMatrix44 toXYZD50,
- Blending blending)
- : fTransferFn(std::move(transferFn))
- , fFromXYZD50(SkMatrix44::kUninitialized_Constructor)
- , fToXYZD50(toXYZD50)
- , fToXYZD50Hash(SkOpts::hash_fn(&toXYZD50, 16*sizeof(SkMScalar), 0))
- , fBlending(blending)
-{
- // It's pretty subtle what do to if the to-XYZ matrix is not invertible.
- // That means the same point in XYZ is mapped to from more than one point in RGB,
- // or put another way, we threw information away when mapping RGB -> XYZ.
- //
- // We'd probably like to set fToXYZD50 as one of the family of matrices that
- // will correctly roundtrip XYZ -> RGB -> XYZ. Choosing which is an open problem.
- SkAssertResult(fToXYZD50.invert(&fFromXYZD50));
-}
-
-sk_sp<SkColorSpace> SkColorSpace_New::makeLinearGamma() const {
- return sk_make_sp<SkColorSpace_New>(TransferFn::MakeLinear(), fToXYZD50, fBlending);
-}
-sk_sp<SkColorSpace> SkColorSpace_New::makeSRGBGamma() const {
- return sk_make_sp<SkColorSpace_New>(TransferFn::MakeSRGB(), fToXYZD50, fBlending);
-}
-
-SkGammaNamed SkColorSpace_New::onGammaNamed() const {
- return kNonStandard_SkGammaNamed; // TODO
-}
-
-bool SkColorSpace_New::onGammaCloseToSRGB() const {
- return fTransferFn->equals(*TransferFn::MakeSRGB()); // TODO: more efficient?
-}
-
-bool SkColorSpace_New::onGammaIsLinear() const {
- return fTransferFn->equals(*TransferFn::MakeLinear()); // TODO: more efficient?
-}
-
-bool SkColorSpace_New::onIsNumericalTransferFn(SkColorSpaceTransferFn* fn) const {
- *fn = fTransferFn->parameterize();
- return true;
-}
diff --git a/src/core/SkColorSpace_New.h b/src/core/SkColorSpace_New.h
deleted file mode 100644
index 6f26c3bf4b..0000000000
--- a/src/core/SkColorSpace_New.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkColorSpace_New_DEFINED
-#define SkColorSpace_New_DEFINED
-
-#include "SkColorSpace.h"
-#include "SkImageInfo.h"
-#include "SkRefCnt.h"
-
-class SkRasterPipeline;
-
-class SkColorSpace_New final : public SkColorSpace {
-public:
- class ICCProfile; // TODO: == SkICC?
-
- struct TransferFn : public SkRefCnt {
- virtual ~TransferFn() = default;
-
- // TODO: one day maybe we'd like to not need this call,
- // instead using the more active methods below instead.
- virtual SkColorSpaceTransferFn parameterize() const = 0;
-
- // Append stages to use this transfer function with SkRasterPipeline-based rendering.
- virtual void linearizeDst(SkRasterPipeline*) const = 0;
- virtual void linearizeSrc(SkRasterPipeline*) const = 0;
- virtual void encodeSrc(SkRasterPipeline*) const = 0;
-
- // TODO: Ganesh hooks.
-
- // May return false even when this is equivalent to TransferFn,
- // but must always be equivalent when this returns true. (No false positives.)
- // Implemented by default with parameterize().
- virtual bool equals(const TransferFn&) const;
-
- // TODO: ???
- // Implemented by default with parameterize().
- virtual void updateICCProfile(ICCProfile*) const;
-
- static sk_sp<TransferFn> MakeLinear();
- static sk_sp<TransferFn> MakeSRGB();
- static sk_sp<TransferFn> MakeGamma(float);
- };
-
- enum class Blending { Linear, AsEncoded };
-
- SkColorSpace_New(sk_sp<TransferFn>, SkMatrix44 toXYZD50, Blending);
-
- const SkMatrix44& toXYZD50() const { return fToXYZD50; }
- const SkMatrix44& fromXYZD50() const { return fFromXYZD50; }
- const TransferFn& transferFn() const { return *fTransferFn; }
- Blending blending() const { return fBlending; }
-
- // Transfer-function-related overrides.
- sk_sp<SkColorSpace> makeLinearGamma() const override;
- sk_sp<SkColorSpace> makeSRGBGamma() const override;
- SkGammaNamed onGammaNamed() const override;
- bool onGammaCloseToSRGB() const override;
- bool onGammaIsLinear() const override;
- bool onIsNumericalTransferFn(SkColorSpaceTransferFn*) const override;
-
- // Gamut-related overrides.
- const SkMatrix44* onFromXYZD50() const override { return &fFromXYZD50; }
- const SkMatrix44* onToXYZD50() const override { return &fToXYZD50; }
- uint32_t onToXYZD50Hash() const override { return fToXYZD50Hash; }
-
-private:
- sk_sp<TransferFn> fTransferFn;
- SkMatrix44 fFromXYZD50;
- SkMatrix44 fToXYZD50;
- uint32_t fToXYZD50Hash;
- Blending fBlending;
-};
-#endif//SkColorSpace_New_DEFINED
diff --git a/tests/SkColorSpace_NewTest.cpp b/tests/SkColorSpace_NewTest.cpp
deleted file mode 100644
index 31a5da6c50..0000000000
--- a/tests/SkColorSpace_NewTest.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "../src/jumper/SkJumper.h"
-#include "SkColorSpace_New.h"
-#include "SkRasterPipeline.h"
-#include "Test.h"
-#include <initializer_list>
-
-DEF_TEST(SkColorSpace_New_TransferFnBasics, r) {
- auto gamut = SkMatrix44::I();
- auto blending = SkColorSpace_New::Blending::AsEncoded;
-
- SkColorSpace_New linearA{SkColorSpace_New::TransferFn::MakeLinear(), gamut, blending},
- linearB{SkColorSpace_New::TransferFn::MakeGamma(1), gamut, blending},
- srgb{SkColorSpace_New::TransferFn::MakeSRGB(), gamut, blending},
- gamma{SkColorSpace_New::TransferFn::MakeGamma(2.2f), gamut, blending};
-
- REPORTER_ASSERT(r, linearA.gammaIsLinear());
- REPORTER_ASSERT(r, linearB.gammaIsLinear());
- REPORTER_ASSERT(r, ! srgb.gammaIsLinear());
- REPORTER_ASSERT(r, ! gamma.gammaIsLinear());
-
- REPORTER_ASSERT(r, !linearA.gammaCloseToSRGB());
- REPORTER_ASSERT(r, !linearB.gammaCloseToSRGB());
- REPORTER_ASSERT(r, srgb.gammaCloseToSRGB());
- REPORTER_ASSERT(r, ! gamma.gammaCloseToSRGB());
-
- REPORTER_ASSERT(r, linearA.transferFn().equals(linearB.transferFn()));
- REPORTER_ASSERT(r, !linearA.transferFn().equals( srgb.transferFn()));
- REPORTER_ASSERT(r, !linearA.transferFn().equals( gamma.transferFn()));
- REPORTER_ASSERT(r, !linearB.transferFn().equals( srgb.transferFn()));
- REPORTER_ASSERT(r, !linearB.transferFn().equals( gamma.transferFn()));
- REPORTER_ASSERT(r, ! srgb.transferFn().equals( gamma.transferFn()));
-}
-
-DEF_TEST(SkColorSpace_New_TransferFnStages, r) {
- // We'll create a little SkRasterPipelineBlitter-like scenario,
- // blending the same src color over the same dst color, but with
- // three different transfer functions, for simplicity the same for src and dst.
- SkColor src = 0x7f7f0000;
-
- SkColor dsts[3];
- for (SkColor& dst : dsts) {
- dst = 0xff007f00;
- }
-
- auto gamut = SkMatrix44::I();
- auto blending = SkColorSpace_New::Blending::Linear;
- SkColorSpace_New linear{SkColorSpace_New::TransferFn::MakeLinear(), gamut, blending},
- srgb{SkColorSpace_New::TransferFn::MakeSRGB(), gamut, blending},
- gamma{SkColorSpace_New::TransferFn::MakeGamma(3), gamut, blending};
- SkColor* dst = dsts;
- for (const SkColorSpace_New* cs : {&linear, &srgb, &gamma}) {
- SkJumper_MemoryCtx src_ctx = { &src, 0 },
- dst_ctx = { dst++, 0 };
-
- SkRasterPipeline_<256> p;
-
- p.append(SkRasterPipeline::load_8888, &src_ctx);
- cs->transferFn().linearizeSrc(&p);
- p.append(SkRasterPipeline::premul);
-
- p.append(SkRasterPipeline::load_8888_dst, &dst_ctx);
- cs->transferFn().linearizeDst(&p);
- p.append(SkRasterPipeline::premul_dst);
-
- p.append(SkRasterPipeline::srcover);
- p.append(SkRasterPipeline::unpremul);
- cs->transferFn().encodeSrc(&p);
- p.append(SkRasterPipeline::store_8888, &dst_ctx);
- p.run(0,0,1,1);
- }
-
- // Double check the uninteresting channels: alpha's opaque, no blue.
- REPORTER_ASSERT(r, SkColorGetA(dsts[0]) == 0xff && SkColorGetB(dsts[0]) == 0x00);
- REPORTER_ASSERT(r, SkColorGetA(dsts[1]) == 0xff && SkColorGetB(dsts[1]) == 0x00);
- REPORTER_ASSERT(r, SkColorGetA(dsts[2]) == 0xff && SkColorGetB(dsts[2]) == 0x00);
-
- // Because we're doing linear blending, a more-exponential transfer function will
- // brighten the encoded values more when linearizing. So we expect to see that
- // linear is darker than sRGB, and sRGB in turn is darker than gamma 3.
- REPORTER_ASSERT(r, SkColorGetR(dsts[0]) < SkColorGetR(dsts[1]));
- REPORTER_ASSERT(r, SkColorGetR(dsts[1]) < SkColorGetR(dsts[2]));
-
- REPORTER_ASSERT(r, SkColorGetG(dsts[0]) < SkColorGetG(dsts[1]));
- REPORTER_ASSERT(r, SkColorGetG(dsts[1]) < SkColorGetG(dsts[2]));
-
-}