Skip to content

Commit

Permalink
Added support for conversion to bgr10_xr.
Browse files Browse the repository at this point in the history
I'm not sure why my previous attempts didn't run into this in the past, but I've added a test to make sure it works.

Change-Id: I765e3a01861b903e032407571f5ef1114ad2cec3
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/647196
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
  • Loading branch information
gaaclarke authored and SkCQ committed Feb 21, 2023
1 parent 4cf8c75 commit 7c14b6c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/codec/SkCodec.cpp
Expand Up @@ -243,6 +243,7 @@ bool SkCodec::conversionSupported(const SkImageInfo& dst, bool srcIsOpaque, bool
case kBGRA_8888_SkColorType:
case kRGBA_F16_SkColorType:
return true;
case kBGR_101010x_XR_SkColorType:
case kRGB_565_SkColorType:
return srcIsOpaque;
case kGray_8_SkColorType:
Expand Down
17 changes: 17 additions & 0 deletions tests/CodecTest.cpp
Expand Up @@ -1940,3 +1940,20 @@ DEF_TEST(Codec_noConversion, r) {
REPORTER_ASSERT(r, bm.getColor(0, 0) == rec.color);
}
}

DEF_TEST(Codec_kBGR_101010x_XR_SkColorType_supported, r) {
SkBitmap srcBm;
SkImageInfo srcInfo = SkImageInfo()
.makeWH(100, 100)
.makeColorSpace(SkColorSpace::MakeSRGB())
.makeColorType(kBGRA_8888_SkColorType)
.makeAlphaType(kOpaque_SkAlphaType);
SkImageInfo dstInfo = srcInfo.makeColorType(kBGR_101010x_XR_SkColorType);
srcBm.allocPixels(srcInfo);
auto data = SkEncodeBitmap(srcBm, SkEncodedImageFormat::kPNG, 100);
std::unique_ptr<SkCodec> codec(SkCodec::MakeFromData(data));
SkBitmap dstBm;
dstBm.allocPixels(dstInfo);
bool success = codec->getPixels(dstInfo, dstBm.getPixels(), dstBm.rowBytes());
REPORTER_ASSERT(r, SkCodec::kSuccess == success);
}

0 comments on commit 7c14b6c

Please sign in to comment.