aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/codec
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2017-06-05 15:53:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-06-05 20:14:57 +0000
commitc6e6a5f45e54006e861275a6d5c165830f403dcd (patch)
tree3d4bc3a0c43d6c2986728a3dffdec43e8547f43f /include/codec
parent348060fa820e1ee7a4fd246afe517a80a9ef311d (diff)
Simplify SkCodecs' call to SkColorSpaceXform::apply
Most SkCodec subclasses did the following to apply their SkColorSpaceXform: dstFormat = select_xform_format(dstInfo.colorType()); srcFormat = select_xform_format(<something that doesn't change>); xformAlphaType = select_xform_alpha(dstInfo.alphaType(), this->getInfo().alphaType()); this->colorXform()->apply(dstFormat, dst, srcFormat, src, width, xformAlphaType); Consolidate the computation of these parameters into SkCodec and add a new method to SkCodec that calls apply() with those parameters. Add a SkColorSpaceXform::ColorFormat to SkCodec. This allows the new method SkCodec::applyColorXform to supply the ColorFormat. TBR=reed@google.com (No change to public API.) Change-Id: I8ea7ba4c0024be827a9f9359796c778744330f6e Reviewed-on: https://skia-review.googlesource.com/18523 Reviewed-by: Leon Scroggins <scroggo@google.com> Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'include/codec')
-rw-r--r--include/codec/SkCodec.h28
1 files changed, 20 insertions, 8 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index d52433e3a3..d498007486 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -10,6 +10,7 @@
#include "../private/SkTemplates.h"
#include "SkColor.h"
+#include "SkColorSpaceXform.h"
#include "SkEncodedImageFormat.h"
#include "SkEncodedInfo.h"
#include "SkImageInfo.h"
@@ -415,10 +416,10 @@ public:
* @return Enum representing success or reason for failure.
*/
Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
- const SkCodec::Options*, SkPMColor* ctable, int* ctableCount);
+ const Options*, SkPMColor* ctable, int* ctableCount);
Result startIncrementalDecode(const SkImageInfo& dstInfo, void* dst, size_t rowBytes,
- const SkCodec::Options* options) {
+ const Options* options) {
return this->startIncrementalDecode(dstInfo, dst, rowBytes, options, nullptr, nullptr);
}
@@ -483,7 +484,7 @@ public:
* decoding the palette.
* @return Enum representing success or reason for failure.
*/
- Result startScanlineDecode(const SkImageInfo& dstInfo, const SkCodec::Options* options,
+ Result startScanlineDecode(const SkImageInfo& dstInfo, const Options* options,
SkPMColor ctable[], int* ctableCount);
/**
@@ -678,12 +679,15 @@ public:
}
protected:
+ using XformFormat = SkColorSpaceXform::ColorFormat;
+
/**
* Takes ownership of SkStream*
*/
SkCodec(int width,
int height,
const SkEncodedInfo&,
+ XformFormat srcFormat,
SkStream*,
sk_sp<SkColorSpace>,
Origin = kTopLeft_Origin);
@@ -694,6 +698,7 @@ protected:
*/
SkCodec(const SkEncodedInfo&,
const SkImageInfo&,
+ XformFormat srcFormat,
SkStream*,
Origin = kTopLeft_Origin);
@@ -805,7 +810,7 @@ protected:
const SkImageInfo& dstInfo() const { return fDstInfo; }
- const SkCodec::Options& options() const { return fOptions; }
+ const Options& options() const { return fOptions; }
/**
* Returns the number of scanlines that have been decoded so far.
@@ -819,7 +824,11 @@ protected:
bool initializeColorXform(const SkImageInfo& dstInfo,
SkTransferFunctionBehavior premulBehavior);
+ void applyColorXform(void* dst, const void* src, int count, SkAlphaType) const;
+ void applyColorXform(void* dst, const void* src, int count) const;
+
SkColorSpaceXform* colorXform() const { return fColorXform.get(); }
+ bool xformOnDecode() const { return fXformOnDecode; }
virtual int onGetFrameCount() {
return 1;
@@ -838,13 +847,16 @@ protected:
private:
const SkEncodedInfo fEncodedInfo;
const SkImageInfo fSrcInfo;
+ const XformFormat fSrcXformFormat;
std::unique_ptr<SkStream> fStream;
bool fNeedsRewind;
const Origin fOrigin;
SkImageInfo fDstInfo;
- SkCodec::Options fOptions;
+ Options fOptions;
+ XformFormat fDstXformFormat; // Based on fDstInfo.
std::unique_ptr<SkColorSpaceXform> fColorXform;
+ bool fXformOnDecode;
// Only meaningful during scanline decodes.
int fCurrScanline;
@@ -868,13 +880,13 @@ private:
}
// Methods for scanline decoding.
- virtual SkCodec::Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
- const SkCodec::Options& /*options*/, SkPMColor* /*ctable*/, int* /*ctableCount*/) {
+ virtual Result onStartScanlineDecode(const SkImageInfo& /*dstInfo*/,
+ const Options& /*options*/, SkPMColor* /*ctable*/, int* /*ctableCount*/) {
return kUnimplemented;
}
virtual Result onStartIncrementalDecode(const SkImageInfo& /*dstInfo*/, void*, size_t,
- const SkCodec::Options&, SkPMColor*, int*) {
+ const Options&, SkPMColor*, int*) {
return kUnimplemented;
}