Add color space xform support to SkJpegCodec (includes F16!)
Also changes SkColorXform to support:
RGBA->RGBA
RGBA->BGRA
Instead of:
RGBA->SkPMColor
TBR=reed@google.com
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2174493002
CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot
Committed: https://skia.googlesource.com/skia/+/73d55332e2846dd05e9efdaa2f017bcc3872884b
Review-Url: https://codereview.chromium.org/2174493002
diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h
index 7aa275c..7eb5100 100644
--- a/src/codec/SkJpegCodec.h
+++ b/src/codec/SkJpegCodec.h
@@ -10,6 +10,7 @@
#include "SkCodec.h"
#include "SkColorSpace.h"
+#include "SkColorSpaceXform.h"
#include "SkImageInfo.h"
#include "SkSwizzler.h"
#include "SkStream.h"
@@ -99,34 +100,46 @@
/*
* Checks if the conversion between the input image and the requested output
- * image has been implemented
- * Sets the output color space
+ * image has been implemented.
+ *
+ * Sets the output color space.
*/
- bool setOutputColorSpace(const SkImageInfo& dst);
+ bool setOutputColorSpace(const SkImageInfo& dst, bool needsColorXform);
- // scanline decoding
void initializeSwizzler(const SkImageInfo& dstInfo, const Options& options);
+ bool initializeColorXform(const SkImageInfo& dstInfo, bool needsColorXform);
+ void allocateStorage(const SkImageInfo& dstInfo);
+ int readRows(const SkImageInfo& dstInfo, void* dst, size_t rowBytes, int count);
+
+ /*
+ * Scanline decoding.
+ */
SkSampler* getSampler(bool createIfNecessary) override;
Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& options,
SkPMColor ctable[], int* ctableCount) override;
int onGetScanlines(void* dst, int count, size_t rowBytes) override;
bool onSkipScanlines(int count) override;
- SkAutoTDelete<JpegDecoderMgr> fDecoderMgr;
+ SkAutoTDelete<JpegDecoderMgr> fDecoderMgr;
+
// We will save the state of the decompress struct after reading the header.
// This allows us to safely call onGetScaledDimensions() at any time.
- const int fReadyState;
+ const int fReadyState;
- // scanline decoding
- SkAutoTMalloc<uint8_t> fStorage; // Only used if sampling is needed
- uint8_t* fSrcRow; // Only used if sampling is needed
+
+ SkAutoTMalloc<uint8_t> fStorage;
+ uint8_t* fSwizzleSrcRow;
+ uint32_t* fColorXformSrcRow;
+
// libjpeg-turbo provides some subsetting. In the case that libjpeg-turbo
// cannot take the exact the subset that we need, we will use the swizzler
// to further subset the output from libjpeg-turbo.
- SkIRect fSwizzlerSubset;
- SkAutoTDelete<SkSwizzler> fSwizzler;
+ SkIRect fSwizzlerSubset;
+
+ SkAutoTDelete<SkSwizzler> fSwizzler;
+ std::unique_ptr<SkColorSpaceXform> fColorXform;
- sk_sp<SkData> fICCData;
+ sk_sp<SkData> fICCData;
typedef SkCodec INHERITED;
};