Reland "Stop conflating F16 with linear gamma"
This reverts commit5f7b5e3624
. Reason for revert: Codec CL has re-landed. Original change's description: > Revert "Stop conflating F16 with linear gamma" > > This reverts commitd1589c7213
. > > Reason for revert: Depends on skcms CL that's been reverted. > > Original change's description: > > Stop conflating F16 with linear gamma > > > > Note to self: I debugged this, realized that the codecs > > need to handle A2B -> XYZ, then realized that I just need > > to wait for https://skia-review.googlesource.com/c/skia/+/136062 > > > > Bug: skia: > > Change-Id: I594c22076feb3700b8a40c471a541fef5ff4e13e > > Reviewed-on: https://skia-review.googlesource.com/137587 > > Commit-Queue: Brian Osman <brianosman@google.com> > > Reviewed-by: Mike Klein <mtklein@google.com> > > TBR=mtklein@google.com,brianosman@google.com > > Change-Id: I6dca583697c8efd2563d30cb7ab9ef505b6903ae > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia: > Reviewed-on: https://skia-review.googlesource.com/148860 > Reviewed-by: Brian Osman <brianosman@google.com> > Commit-Queue: Brian Osman <brianosman@google.com> TBR=mtklein@google.com,brianosman@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Bug: skia: Change-Id: Iee66531049843758e7ed4130b99d8df6a553d805 Reviewed-on: https://skia-review.googlesource.com/149700 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
ffe1c1cad0
commit
6b622963a0
@ -33,10 +33,9 @@ protected:
|
||||
const char* onGetName() override { return fName.c_str(); }
|
||||
|
||||
void onDelayedSetup() override {
|
||||
SkImageInfo info = fHalfFoat ? SkImageInfo::Make(fW, fH, kRGBA_F16_SkColorType,
|
||||
kPremul_SkAlphaType,
|
||||
SkColorSpace::MakeSRGBLinear())
|
||||
: SkImageInfo::MakeS32(fW, fH, kPremul_SkAlphaType);
|
||||
SkColorType ct = fHalfFoat ? kRGBA_F16_SkColorType : kN32_SkColorType;
|
||||
SkImageInfo info = SkImageInfo::Make(fW, fH, ct, kPremul_SkAlphaType,
|
||||
SkColorSpace::MakeSRGB());
|
||||
fBitmap.allocPixels(info);
|
||||
fBitmap.eraseColor(SK_ColorWHITE); // so we don't read uninitialized memory
|
||||
}
|
||||
|
@ -145,14 +145,6 @@ static inline void alpha8_to_gray8(SkBitmap* bitmap) {
|
||||
}
|
||||
|
||||
Error BRDSrc::draw(SkCanvas* canvas) const {
|
||||
if (canvas->imageInfo().colorSpace() &&
|
||||
kRGBA_F16_SkColorType != canvas->imageInfo().colorType()) {
|
||||
// SkAndroidCodec uses legacy premultiplication and blending. Therefore, we only
|
||||
// run these tests on legacy canvases.
|
||||
// We allow an exception for F16, since Android uses F16.
|
||||
return Error::Nonfatal("Skip testing to color correct canvas.");
|
||||
}
|
||||
|
||||
SkColorType colorType = canvas->imageInfo().colorType();
|
||||
if (kRGB_565_SkColorType == colorType &&
|
||||
CodecSrc::kGetFromCanvas_DstColorType != fDstColorType) {
|
||||
@ -401,11 +393,6 @@ static bool get_decode_info(SkImageInfo* decodeInfo, SkColorType canvasColorType
|
||||
return false;
|
||||
}
|
||||
|
||||
if (kRGBA_F16_SkColorType == canvasColorType) {
|
||||
sk_sp<SkColorSpace> linearSpace = decodeInfo->colorSpace()->makeLinearGamma();
|
||||
*decodeInfo = decodeInfo->makeColorSpace(std::move(linearSpace));
|
||||
}
|
||||
|
||||
*decodeInfo = decodeInfo->makeColorType(canvasColorType);
|
||||
break;
|
||||
}
|
||||
@ -431,11 +418,7 @@ static void draw_to_canvas(SkCanvas* canvas, const SkImageInfo& info, void* pixe
|
||||
// "pretend" that the color space is standard sRGB to avoid triggering color conversion
|
||||
// at draw time.
|
||||
static void set_bitmap_color_space(SkImageInfo* info) {
|
||||
if (kRGBA_F16_SkColorType == info->colorType()) {
|
||||
*info = info->makeColorSpace(SkColorSpace::MakeSRGBLinear());
|
||||
} else {
|
||||
*info = info->makeColorSpace(SkColorSpace::MakeSRGB());
|
||||
}
|
||||
*info = info->makeColorSpace(SkColorSpace::MakeSRGB());
|
||||
}
|
||||
|
||||
Error CodecSrc::draw(SkCanvas* canvas) const {
|
||||
@ -824,14 +807,6 @@ bool AndroidCodecSrc::veto(SinkFlags flags) const {
|
||||
}
|
||||
|
||||
Error AndroidCodecSrc::draw(SkCanvas* canvas) const {
|
||||
if (canvas->imageInfo().colorSpace() &&
|
||||
kRGBA_F16_SkColorType != canvas->imageInfo().colorType()) {
|
||||
// SkAndroidCodec uses legacy premultiplication and blending. Therefore, we only
|
||||
// run these tests on legacy canvases.
|
||||
// We allow an exception for F16, since Android uses F16.
|
||||
return Error::Nonfatal("Skip testing to color correct canvas.");
|
||||
}
|
||||
|
||||
sk_sp<SkData> encoded(SkData::MakeFromFileName(fPath.c_str()));
|
||||
if (!encoded) {
|
||||
return SkStringPrintf("Couldn't read %s.", fPath.c_str());
|
||||
@ -1090,9 +1065,6 @@ Error ColorCodecSrc::draw(SkCanvas* canvas) const {
|
||||
if (kUnpremul_SkAlphaType == decodeInfo.alphaType()) {
|
||||
decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType);
|
||||
}
|
||||
if (kRGBA_F16_SkColorType == fColorType) {
|
||||
decodeInfo = decodeInfo.makeColorSpace(decodeInfo.colorSpace()->makeLinearGamma());
|
||||
}
|
||||
|
||||
SkImageInfo bitmapInfo = decodeInfo;
|
||||
set_bitmap_color_space(&bitmapInfo);
|
||||
|
@ -23,18 +23,6 @@ namespace skiagm {
|
||||
static const int imageWidth = 128;
|
||||
static const int imageHeight = 128;
|
||||
|
||||
sk_sp<SkColorSpace> fix_for_colortype(sk_sp<SkColorSpace> colorSpace, SkColorType colorType) {
|
||||
if (kRGBA_F16_SkColorType == colorType) {
|
||||
if (!colorSpace) {
|
||||
return SkColorSpace::MakeSRGBLinear();
|
||||
}
|
||||
|
||||
return colorSpace->makeLinearGamma();
|
||||
}
|
||||
|
||||
return colorSpace;
|
||||
}
|
||||
|
||||
static void make(SkBitmap* bitmap, SkColorType colorType, SkAlphaType alphaType,
|
||||
sk_sp<SkColorSpace> colorSpace) {
|
||||
const char* resource;
|
||||
@ -55,9 +43,12 @@ 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(fix_for_colortype(colorSpace, colorType));
|
||||
.makeColorSpace(colorSpace);
|
||||
bitmap->allocPixels(dstInfo);
|
||||
codec->getPixels(dstInfo, bitmap->getPixels(), bitmap->rowBytes());
|
||||
}
|
||||
|
@ -40,14 +40,6 @@ static void clamp_if_necessary(const SkImageInfo& info, void* pixels) {
|
||||
}
|
||||
}
|
||||
|
||||
sk_sp<SkColorSpace> fix_for_colortype(SkColorSpace* colorSpace, SkColorType colorType) {
|
||||
if (kRGBA_F16_SkColorType == colorType) {
|
||||
return colorSpace->makeLinearGamma();
|
||||
}
|
||||
|
||||
return sk_ref_sp(colorSpace);
|
||||
}
|
||||
|
||||
static const int kWidth = 64;
|
||||
static const int kHeight = 64;
|
||||
|
||||
@ -58,8 +50,7 @@ static sk_sp<SkImage> make_raster_image(SkColorType colorType) {
|
||||
SkBitmap bitmap;
|
||||
SkImageInfo info = codec->getInfo().makeWH(kWidth, kHeight)
|
||||
.makeColorType(colorType)
|
||||
.makeAlphaType(kPremul_SkAlphaType)
|
||||
.makeColorSpace(fix_for_colortype(codec->getInfo().colorSpace(), colorType));
|
||||
.makeAlphaType(kPremul_SkAlphaType);
|
||||
bitmap.allocPixels(info);
|
||||
codec->getPixels(info, bitmap.getPixels(), bitmap.rowBytes());
|
||||
bitmap.setImmutable();
|
||||
@ -132,7 +123,6 @@ static void draw_image(SkCanvas* canvas, SkImage* image, SkColorType dstColorTyp
|
||||
SkImage::CachingHint hint) {
|
||||
size_t rowBytes = image->width() * SkColorTypeBytesPerPixel(dstColorType);
|
||||
sk_sp<SkData> data = SkData::MakeUninitialized(rowBytes * image->height());
|
||||
dstColorSpace = fix_for_colortype(dstColorSpace.get(), dstColorType);
|
||||
SkImageInfo dstInfo = SkImageInfo::Make(image->width(), image->height(), dstColorType,
|
||||
dstAlphaType, dstColorSpace);
|
||||
if (!image->readPixels(dstInfo, data->writable_data(), rowBytes, 0, 0, hint)) {
|
||||
@ -154,7 +144,7 @@ static void draw_image(SkCanvas* canvas, SkImage* image, SkColorType dstColorTyp
|
||||
clamp_if_necessary(dstInfo, data->writable_data());
|
||||
|
||||
// Now that we have called readPixels(), dump the raw pixels into an srgb image.
|
||||
sk_sp<SkColorSpace> srgb = fix_for_colortype(sk_srgb_singleton(), dstColorType);
|
||||
sk_sp<SkColorSpace> srgb = SkColorSpace::MakeSRGB();
|
||||
sk_sp<SkImage> raw = SkImage::MakeRasterData(dstInfo.makeColorSpace(srgb), data, rowBytes);
|
||||
canvas->drawImage(raw.get(), 0.0f, 0.0f, nullptr);
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ static void setup_src_bitmaps(SkBitmap* srcOpaque, SkBitmap* srcPremul,
|
||||
SkColorType ct) {
|
||||
sk_sp<SkColorSpace> colorSpace = nullptr;
|
||||
if (kRGBA_F16_SkColorType == ct) {
|
||||
colorSpace = SkColorSpace::MakeSRGBLinear();
|
||||
colorSpace = SkColorSpace::MakeSRGB();
|
||||
}
|
||||
|
||||
srcOpaque->allocPixels(SkImageInfo::Make(W, H, ct, kOpaque_SkAlphaType, colorSpace));
|
||||
|
@ -25,7 +25,7 @@ DEF_TEST(Codec_recommendedF16, r) {
|
||||
// such a PNG.
|
||||
SkBitmap bm;
|
||||
bm.allocPixels(SkImageInfo::Make(10, 10, kRGBA_F16_SkColorType,
|
||||
kPremul_SkAlphaType, SkColorSpace::MakeSRGBLinear()));
|
||||
kPremul_SkAlphaType, SkColorSpace::MakeSRGB()));
|
||||
// What is drawn is not important.
|
||||
bm.eraseColor(SK_ColorBLUE);
|
||||
|
||||
|
@ -289,10 +289,8 @@ public:
|
||||
break;
|
||||
case 3:
|
||||
// The color type and config need to be changed together.
|
||||
// The original SRGB color space no longer makes sense for F16
|
||||
fColorType = kRGBA_F16_SkColorType;
|
||||
fConfig = kRGBA_half_GrPixelConfig;
|
||||
fColorSpace = SkColorSpace::MakeSRGBLinear();
|
||||
break;
|
||||
case 4:
|
||||
// This just needs to be a colorSpace different from that returned by MakeSRGB().
|
||||
|
@ -678,14 +678,6 @@ DEF_TEST(ReadPixels_ValidConversion, reporter) {
|
||||
for (SkColorType srcCT : kColorTypes) {
|
||||
for (SkAlphaType srcAT: kAlphaTypes) {
|
||||
for (sk_sp<SkColorSpace> srcCS : kColorSpaces) {
|
||||
if (kRGBA_F16_SkColorType == dstCT && dstCS) {
|
||||
dstCS = dstCS->makeLinearGamma();
|
||||
}
|
||||
|
||||
if (kRGBA_F16_SkColorType == srcCT && srcCS) {
|
||||
srcCS = srcCS->makeLinearGamma();
|
||||
}
|
||||
|
||||
test_conversion(reporter,
|
||||
SkImageInfo::Make(kNumPixels, 1, dstCT, dstAT, dstCS),
|
||||
SkImageInfo::Make(kNumPixels, 1, srcCT, srcAT, srcCS));
|
||||
|
Loading…
Reference in New Issue
Block a user