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 <reed@google.com>
Commit-Queue: Florin Malita <fmalita@chromium.org>
This commit is contained in:
Florin Malita 2017-07-06 15:12:12 -04:00 committed by Skia Commit-Bot
parent 71479b7922
commit 24a2ecfa25
2 changed files with 10 additions and 9 deletions

View File

@ -14,22 +14,23 @@
#include "SkImage_Base.h"
#include "SkImageFilter.h"
#include "SkImagePriv.h"
#include "SkMakeUnique.h"
#include "SkShaderBase.h"
SkColorSpaceXformer::SkColorSpaceXformer(sk_sp<SkColorSpace> dst,
std::unique_ptr<SkColorSpaceXform> fromSRGB)
: fDst(std::move(dst))
, fFromSRGB(std::move(fromSRGB)) {}
SkColorSpaceXformer::~SkColorSpaceXformer() {}
std::unique_ptr<SkColorSpaceXformer> SkColorSpaceXformer::Make(sk_sp<SkColorSpace> dst) {
std::unique_ptr<SkColorSpaceXform> fromSRGB = SkColorSpaceXform_Base::New(
SkColorSpace::MakeSRGB().get(), dst.get(), SkTransferFunctionBehavior::kIgnore);
if (!fromSRGB) {
return nullptr;
}
auto xformer = std::unique_ptr<SkColorSpaceXformer>(new SkColorSpaceXformer());
xformer->fDst = std::move(dst);
xformer->fFromSRGB = std::move(fromSRGB);
return xformer;
return fromSRGB
? std::unique_ptr<SkColorSpaceXformer>(new SkColorSpaceXformer(std::move(dst),
std::move(fromSRGB)))
: nullptr;
}
sk_sp<SkImage> SkColorSpaceXformer::apply(const SkImage* src) {

View File

@ -39,7 +39,7 @@ public:
sk_sp<SkColorSpace> dst() const { return fDst; }
private:
SkColorSpaceXformer() = default;
SkColorSpaceXformer(sk_sp<SkColorSpace> dst, std::unique_ptr<SkColorSpaceXform> fromSRGB);
sk_sp<SkColorSpace> fDst;
std::unique_ptr<SkColorSpaceXform> fFromSRGB;