Revert "Revert "Disable F16-nullptr sources""
This relands the original change with a modification. We should
not check for non-null pixels because this breaks the Android
hw bitmap use case.
Bug: b/62482405
Change-Id: I081412bb46754d33b69e02e5754f04a082e081ae
Reviewed-on: https://skia-review.googlesource.com/19494
Commit-Queue: Matt Sarett <msarett@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 6fc3296..fcdfce2 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -303,25 +303,25 @@
return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes(), pmap.ctable());
}
-sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, SkCopyPixelsMode cpm) {
- bool hasColorTable = false;
- if (kIndex_8_SkColorType == bm.colorType()) {
- hasColorTable = bm.getColorTable() != nullptr;
+sk_sp<SkImage> SkMakeImageFromRasterBitmapPriv(const SkBitmap& bm, SkCopyPixelsMode cpm) {
+ if (kAlways_SkCopyPixelsMode == cpm || (!bm.isImmutable() && kNever_SkCopyPixelsMode != cpm)) {
+ SkPixmap pmap;
+ if (bm.peekPixels(&pmap)) {
+ return SkImage::MakeRasterCopy(pmap);
+ } else {
+ return sk_sp<SkImage>();
+ }
}
- if (!SkImage_Raster::ValidArgs(bm.info(), bm.rowBytes(), hasColorTable, nullptr)) {
+ return sk_make_sp<SkImage_Raster>(bm, kNever_SkCopyPixelsMode == cpm);
+}
+
+sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, SkCopyPixelsMode cpm) {
+ if (!SkImageInfoIsValidAllowNumericalCS(bm.info()) || bm.rowBytes() < bm.info().minRowBytes()) {
return nullptr;
}
- if (kAlways_SkCopyPixelsMode == cpm || (!bm.isImmutable() && kNever_SkCopyPixelsMode != cpm)) {
- SkPixmap pmap;
- if (bm.getPixels() && bm.peekPixels(&pmap)) {
- return SkImage::MakeRasterCopy(pmap);
- }
- } else {
- return sk_make_sp<SkImage_Raster>(bm, kNever_SkCopyPixelsMode == cpm);
- }
- return sk_sp<SkImage>();
+ return SkMakeImageFromRasterBitmapPriv(bm, cpm);
}
sk_sp<SkImage> SkMakeImageInColorSpace(const SkBitmap& bm, sk_sp<SkColorSpace> dstCS, uint32_t id) {
@@ -339,7 +339,7 @@
// For the Android use case, this is very likely to be true.
if (SkColorSpace::Equals(srcCS.get(), dstCS.get())) {
SkASSERT(0 == id || bm.getGenerationID() == id);
- return SkMakeImageFromRasterBitmap(bm, kNever_SkCopyPixelsMode);
+ return SkMakeImageFromRasterBitmapPriv(bm, kNever_SkCopyPixelsMode);
}
return SkImage::MakeFromGenerator(SkColorSpaceXformImageGenerator::Make(
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 992e4c9..0fa8b65 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -175,7 +175,7 @@
bool SkSurface_Gpu::Valid(const SkImageInfo& info) {
switch (info.colorType()) {
case kRGBA_F16_SkColorType:
- return !info.colorSpace() || info.colorSpace()->gammaIsLinear();
+ return info.colorSpace() && info.colorSpace()->gammaIsLinear();
case kRGBA_8888_SkColorType:
case kBGRA_8888_SkColorType:
return !info.colorSpace() || info.colorSpace()->gammaCloseToSRGB();
@@ -187,7 +187,7 @@
bool SkSurface_Gpu::Valid(GrContext* context, GrPixelConfig config, SkColorSpace* colorSpace) {
switch (config) {
case kRGBA_half_GrPixelConfig:
- return !colorSpace || colorSpace->gammaIsLinear();
+ return colorSpace && colorSpace->gammaIsLinear();
case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig:
return context->caps()->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB();
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index 1ee3d7e..688e234 100644
--- a/src/image/SkSurface_Raster.cpp
+++ b/src/image/SkSurface_Raster.cpp
@@ -63,7 +63,7 @@
shift = 2;
break;
case kRGBA_F16_SkColorType:
- if (info.colorSpace() && !info.colorSpace()->gammaIsLinear()) {
+ if (!info.colorSpace() || !info.colorSpace()->gammaIsLinear()) {
return false;
}
shift = 3;
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index b8092e4..1dd68ff 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -837,7 +837,7 @@
{ kN32_SkColorType, srgbColorSpace, true, "N32-srgb" },
{ kN32_SkColorType, adobeColorSpace, true, "N32-adobe" },
{ kN32_SkColorType, oddColorSpace, false, "N32-odd" },
- { kRGBA_F16_SkColorType, nullptr, true, "F16-nullptr" },
+ { kRGBA_F16_SkColorType, nullptr, false, "F16-nullptr" },
{ kRGBA_F16_SkColorType, linearColorSpace, true, "F16-linear" },
{ kRGBA_F16_SkColorType, srgbColorSpace, false, "F16-srgb" },
{ kRGBA_F16_SkColorType, adobeColorSpace, false, "F16-adobe" },