Fix decoding RAW images to 565
Bug: skia:8473
Follow-on to 96765960dc
.
In SkRawCodec, call select_xform_format (in SkCodec.cpp, now shared
via SkCodecPriv.h) to determine the destination skcms_PixelFormat
for the color transform. This switches kRGB_565_SkColorType decodes
from skcms_PixelFormat_RGB_565 to skcms_PixelFormat_BGR_565, which
fixes some broken images in Gold.
Change-Id: I38eebc06610c7ec8898453ae7a9df7e1ed04efa6
Reviewed-on: https://skia-review.googlesource.com/c/175992
Commit-Queue: Leon Scroggins <scroggo@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
Auto-Submit: Leon Scroggins <scroggo@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
ca91e1f6c5
commit
179559fe35
@ -585,8 +585,8 @@ void SkCodec::fillIncompleteImage(const SkImageInfo& info, void* dst, size_t row
|
||||
SkSampler::Fill(fillInfo, fillDst, rowBytes, kNo_ZeroInitialized);
|
||||
}
|
||||
|
||||
static inline bool select_xform_format(SkColorType colorType, bool forColorTable,
|
||||
skcms_PixelFormat* outFormat) {
|
||||
bool sk_select_xform_format(SkColorType colorType, bool forColorTable,
|
||||
skcms_PixelFormat* outFormat) {
|
||||
SkASSERT(outFormat);
|
||||
|
||||
switch (colorType) {
|
||||
@ -646,8 +646,8 @@ bool SkCodec::initializeColorXform(const SkImageInfo& dstInfo, SkEncodedInfo::Al
|
||||
fXformTime = SkEncodedInfo::kPalette_Color != fEncodedInfo.color()
|
||||
|| kRGBA_F16_SkColorType == dstInfo.colorType()
|
||||
? kDecodeRow_XformTime : kPalette_XformTime;
|
||||
if (!select_xform_format(dstInfo.colorType(), fXformTime == kPalette_XformTime,
|
||||
&fDstXformFormat)) {
|
||||
if (!sk_select_xform_format(dstInfo.colorType(), fXformTime == kPalette_XformTime,
|
||||
&fDstXformFormat)) {
|
||||
return false;
|
||||
}
|
||||
if (encodedAlpha == SkEncodedInfo::kUnpremul_Alpha
|
||||
|
@ -21,6 +21,10 @@
|
||||
#define SkCodecPrintf(...)
|
||||
#endif
|
||||
|
||||
// Defined in SkCodec.cpp
|
||||
bool sk_select_xform_format(SkColorType colorType, bool forColorTable,
|
||||
skcms_PixelFormat* outFormat);
|
||||
|
||||
// FIXME: Consider sharing with dm, nanbench, and tools.
|
||||
static inline float get_scale_from_sample_size(int sampleSize) {
|
||||
return 1.0f / ((float) sampleSize);
|
||||
|
@ -727,21 +727,8 @@ SkCodec::Result SkRawCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
||||
|
||||
constexpr auto srcFormat = skcms_PixelFormat_RGB_888;
|
||||
skcms_PixelFormat dstFormat;
|
||||
switch (dstInfo.colorType()) {
|
||||
case kRGBA_8888_SkColorType:
|
||||
dstFormat = skcms_PixelFormat_RGBA_8888;
|
||||
break;
|
||||
case kBGRA_8888_SkColorType:
|
||||
dstFormat = skcms_PixelFormat_BGRA_8888;
|
||||
break;
|
||||
case kRGBA_F16_SkColorType:
|
||||
dstFormat = skcms_PixelFormat_RGBA_hhhh;
|
||||
break;
|
||||
case kRGB_565_SkColorType:
|
||||
dstFormat = skcms_PixelFormat_RGB_565;
|
||||
break;
|
||||
default:
|
||||
return kInvalidConversion;
|
||||
if (!sk_select_xform_format(dstInfo.colorType(), false, &dstFormat)) {
|
||||
return kInvalidConversion;
|
||||
}
|
||||
|
||||
const skcms_ICCProfile* const srcProfile = this->getEncodedInfo().profile();
|
||||
@ -752,7 +739,6 @@ SkCodec::Result SkRawCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
|
||||
dstProfile = &dstProfileStorage;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < height; ++i) {
|
||||
buffer.fArea = dng_rect(i, 0, i + 1, width);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user