Reland "Switch SkCodec to use skcms plus fixes""
This reverts commit 83988edfd3256dc822b961362aad7fbc3e0cdabc.
The CTS failure was actually due to another CL.
TBR=brianosman@google.com
TBR=djsollen@google.com
Bug: skia:6839
Bug: skia:8052
Bug: skia:8278
Change-Id: Id9f152ec2c66467d90f49df223cb9b7c168ac2ac
Reviewed-on: https://skia-review.googlesource.com/149483
Reviewed-by: Leon Scroggins <scroggo@google.com>
Commit-Queue: Leon Scroggins <scroggo@google.com>
diff --git a/src/codec/SkBmpStandardCodec.cpp b/src/codec/SkBmpStandardCodec.cpp
index 153d081..dd71535 100644
--- a/src/codec/SkBmpStandardCodec.cpp
+++ b/src/codec/SkBmpStandardCodec.cpp
@@ -14,12 +14,12 @@
* Creates an instance of the decoder
* Called only by NewFromStream
*/
-SkBmpStandardCodec::SkBmpStandardCodec(int width, int height, const SkEncodedInfo& info,
- std::unique_ptr<SkStream> stream, uint16_t bitsPerPixel,
- uint32_t numColors, uint32_t bytesPerColor, uint32_t offset,
+SkBmpStandardCodec::SkBmpStandardCodec(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream,
+ uint16_t bitsPerPixel, uint32_t numColors,
+ uint32_t bytesPerColor, uint32_t offset,
SkCodec::SkScanlineOrder rowOrder,
bool isOpaque, bool inIco)
- : INHERITED(width, height, info, std::move(stream), bitsPerPixel, rowOrder)
+ : INHERITED(std::move(info), std::move(stream), bitsPerPixel, rowOrder)
, fColorTable(nullptr)
, fNumColors(numColors)
, fBytesPerColor(bytesPerColor)
@@ -146,20 +146,33 @@
return true;
}
+static SkEncodedInfo make_info(SkEncodedInfo::Color color,
+ SkEncodedInfo::Alpha alpha, int bitsPerPixel) {
+ // This is just used for the swizzler, which does not need the width or height.
+ return SkEncodedInfo::Make(0, 0, color, alpha, bitsPerPixel);
+}
+
+SkEncodedInfo SkBmpStandardCodec::swizzlerInfo() const {
+ const auto& info = this->getEncodedInfo();
+ if (fInIco) {
+ if (this->bitsPerPixel() <= 8) {
+ return make_info(SkEncodedInfo::kPalette_Color,
+ info.alpha(), this->bitsPerPixel());
+ }
+ if (this->bitsPerPixel() == 24) {
+ return make_info(SkEncodedInfo::kBGR_Color,
+ SkEncodedInfo::kOpaque_Alpha, 8);
+ }
+ }
+
+ return make_info(info.color(), info.alpha(), info.bitsPerComponent());
+}
+
void SkBmpStandardCodec::initializeSwizzler(const SkImageInfo& dstInfo, const Options& opts) {
// In the case of bmp-in-icos, we will report BGRA to the client,
// since we may be required to apply an alpha mask after the decode.
// However, the swizzler needs to know the actual format of the bmp.
- SkEncodedInfo encodedInfo = this->getEncodedInfo();
- if (fInIco) {
- if (this->bitsPerPixel() <= 8) {
- encodedInfo = SkEncodedInfo::Make(SkEncodedInfo::kPalette_Color,
- encodedInfo.alpha(), this->bitsPerPixel());
- } else if (this->bitsPerPixel() == 24) {
- encodedInfo = SkEncodedInfo::Make(SkEncodedInfo::kBGR_Color,
- SkEncodedInfo::kOpaque_Alpha, 8);
- }
- }
+ SkEncodedInfo encodedInfo = this->swizzlerInfo();
// Get a pointer to the color table if it exists
const SkPMColor* colorPtr = get_color_ptr(fColorTable.get());