Support encoding/decoding F16 without a color space

Change encode-srgb-* to exercise this code. The encoders
handle this just fine, so just remove those checks. The
decoders still rely on having a color space, so detect
and fix this inside SkCodec. Eventually I'd like to get
rid of the swizzler, use skcms for all format conversion,
etc... but that's a really big change, and this will let
us land other changes without breaking layout tests.

Bug: skia:8382
Change-Id: I8d85bf44ee3a287ad295515a745ded2ff5051417
Reviewed-on: https://skia-review.googlesource.com/156627
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
Brian Osman 2018-09-28 10:35:22 -04:00 committed by Skia Commit-Bot
parent 805fe3b83d
commit 84f8a61e41
4 changed files with 6 additions and 9 deletions

View File

@ -42,9 +42,6 @@ static void make(SkBitmap* bitmap, SkColorType colorType, SkAlphaType alphaType,
sk_sp<SkData> data = GetResourceAsData(resource);
std::unique_ptr<SkCodec> codec = SkCodec::MakeFromData(data);
if (kRGBA_F16_SkColorType == colorType && !colorSpace) {
colorSpace = SkColorSpace::MakeSRGB();
}
SkImageInfo dstInfo = codec->getInfo().makeColorType(colorType)
.makeAlphaType(alphaType)
.makeColorSpace(colorSpace);

View File

@ -299,8 +299,13 @@ SkCodec::Result SkCodec::handleFrameIndex(const SkImageInfo& info, void* pixels,
? kSuccess : kInvalidConversion;
}
SkCodec::Result SkCodec::getPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
SkCodec::Result SkCodec::getPixels(const SkImageInfo& dstInfo, void* pixels, size_t rowBytes,
const Options* options) {
SkImageInfo info = dstInfo;
if (!info.colorSpace()) {
info = info.makeColorSpace(SkColorSpace::MakeSRGB());
}
if (kUnknown_SkColorType == info.colorType()) {
return kInvalidConversion;
}

View File

@ -110,10 +110,6 @@ bool SkJpegEncoderMgr::setParams(const SkImageInfo& srcInfo, const SkJpegEncoder
numComponents = 1;
break;
case kRGBA_F16_SkColorType:
if (!srcInfo.colorSpace()) {
return false;
}
if (kUnpremul_SkAlphaType != srcInfo.alphaType() ||
SkJpegEncoder::AlphaOption::kIgnore == options.fAlphaOption)
{

View File

@ -107,7 +107,6 @@ bool SkPngEncoderMgr::setHeader(const SkImageInfo& srcInfo, const SkPngEncoder::
switch (srcInfo.colorType()) {
case kRGBA_F16_SkColorType:
case kRGBA_F32_SkColorType:
SkASSERT(srcInfo.colorSpace());
sigBit.red = 16;
sigBit.green = 16;
sigBit.blue = 16;