From 24a2ecfa256042efd57fd97b23dbce5a49b92a94 Mon Sep 17 00:00:00 2001 From: Florin Malita Date: Thu, 6 Jul 2017 15:12:12 -0400 Subject: [PATCH] Minor SkColorSpaceXformer cleanup Instead of plugging private fields from the factory, pass to ctor. Change-Id: Iea186e394182bddb6a569de1a05f2e40d6815c80 Reviewed-on: https://skia-review.googlesource.com/21734 Reviewed-by: Mike Reed Commit-Queue: Florin Malita --- src/core/SkColorSpaceXformer.cpp | 17 +++++++++-------- src/core/SkColorSpaceXformer.h | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/core/SkColorSpaceXformer.cpp b/src/core/SkColorSpaceXformer.cpp index 301a7f1e79..71715add87 100644 --- a/src/core/SkColorSpaceXformer.cpp +++ b/src/core/SkColorSpaceXformer.cpp @@ -14,22 +14,23 @@ #include "SkImage_Base.h" #include "SkImageFilter.h" #include "SkImagePriv.h" -#include "SkMakeUnique.h" #include "SkShaderBase.h" +SkColorSpaceXformer::SkColorSpaceXformer(sk_sp dst, + std::unique_ptr fromSRGB) + : fDst(std::move(dst)) + , fFromSRGB(std::move(fromSRGB)) {} + SkColorSpaceXformer::~SkColorSpaceXformer() {} std::unique_ptr SkColorSpaceXformer::Make(sk_sp dst) { std::unique_ptr fromSRGB = SkColorSpaceXform_Base::New( SkColorSpace::MakeSRGB().get(), dst.get(), SkTransferFunctionBehavior::kIgnore); - if (!fromSRGB) { - return nullptr; - } - auto xformer = std::unique_ptr(new SkColorSpaceXformer()); - xformer->fDst = std::move(dst); - xformer->fFromSRGB = std::move(fromSRGB); - return xformer; + return fromSRGB + ? std::unique_ptr(new SkColorSpaceXformer(std::move(dst), + std::move(fromSRGB))) + : nullptr; } sk_sp SkColorSpaceXformer::apply(const SkImage* src) { diff --git a/src/core/SkColorSpaceXformer.h b/src/core/SkColorSpaceXformer.h index 75db04022f..fce8d03e43 100644 --- a/src/core/SkColorSpaceXformer.h +++ b/src/core/SkColorSpaceXformer.h @@ -39,7 +39,7 @@ public: sk_sp dst() const { return fDst; } private: - SkColorSpaceXformer() = default; + SkColorSpaceXformer(sk_sp dst, std::unique_ptr fromSRGB); sk_sp fDst; std::unique_ptr fFromSRGB;