From cf3f2347c8933596aeba873d4ece597a9339392f Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Thu, 23 Mar 2017 15:32:25 -0400 Subject: Add SkTransferFunctionBehavior flag: Use in codec and encoder This is a step towards removing the non-linear blending flag from SkColorSpace. The flag on SkColorSpace used to control the premul behavior - now it is controlled by this option. BUG=skia: Change-Id: Ia29bd8c2b0596a93c6aa14332dcd9bd39e388a90 Reviewed-on: https://skia-review.googlesource.com/10008 Reviewed-by: Mike Reed Reviewed-by: Leon Scroggins Commit-Queue: Matt Sarett --- include/codec/SkCodec.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'include/codec') diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h index 13730e2a73..11d28ea8f2 100644 --- a/include/codec/SkCodec.h +++ b/include/codec/SkCodec.h @@ -249,9 +249,10 @@ public: , fSubset(nullptr) , fFrameIndex(0) , fHasPriorFrame(false) + , fPremulBehavior(SkTransferFunctionBehavior::kRespect) {} - ZeroInitialized fZeroInitialized; + ZeroInitialized fZeroInitialized; /** * If not NULL, represents a subset of the original image to decode. * Must be within the bounds returned by getInfo(). @@ -269,14 +270,14 @@ public: * subset left and subset width to decode partial scanlines on calls * to getScanlines(). */ - const SkIRect* fSubset; + const SkIRect* fSubset; /** * The frame to decode. * * Only meaningful for multi-frame images. */ - size_t fFrameIndex; + size_t fFrameIndex; /** * If true, the dst already contains the prior frame. @@ -295,7 +296,15 @@ public: * codec needs to first decode the prior frame (which in turn may need * to decode its prior frame). */ - bool fHasPriorFrame; + bool fHasPriorFrame; + + /** + * Indicates whether we should do a linear premultiply or a legacy premultiply. + * + * In the case where the dst SkColorSpace is nullptr, this flag is ignored and + * we will always do a legacy premultiply. + */ + SkTransferFunctionBehavior fPremulBehavior; }; /** @@ -781,7 +790,8 @@ protected: virtual int onOutputScanline(int inputScanline) const; - bool initializeColorXform(const SkImageInfo& dstInfo); + bool initializeColorXform(const SkImageInfo& dstInfo, + SkTransferFunctionBehavior premulBehavior); SkColorSpaceXform* colorXform() const { return fColorXform.get(); } virtual std::vector onGetFrameInfo() { -- cgit v1.2.3