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>
This commit is contained in:
Matt Sarett 2017-06-12 13:46:11 -04:00 committed by Skia Commit-Bot
parent 5e819cac11
commit b6759dd16e
4 changed files with 19 additions and 19 deletions

View File

@ -303,25 +303,25 @@ sk_sp<SkImage> SkImage::MakeFromRaster(const SkPixmap& pmap, RasterReleaseProc p
return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes(), pmap.ctable()); return sk_make_sp<SkImage_Raster>(pmap.info(), std::move(data), pmap.rowBytes(), pmap.ctable());
} }
sk_sp<SkImage> SkMakeImageFromRasterBitmap(const SkBitmap& bm, SkCopyPixelsMode cpm) { sk_sp<SkImage> SkMakeImageFromRasterBitmapPriv(const SkBitmap& bm, SkCopyPixelsMode cpm) {
bool hasColorTable = false; if (kAlways_SkCopyPixelsMode == cpm || (!bm.isImmutable() && kNever_SkCopyPixelsMode != cpm)) {
if (kIndex_8_SkColorType == bm.colorType()) { SkPixmap pmap;
hasColorTable = bm.getColorTable() != nullptr; 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; return nullptr;
} }
if (kAlways_SkCopyPixelsMode == cpm || (!bm.isImmutable() && kNever_SkCopyPixelsMode != cpm)) { return SkMakeImageFromRasterBitmapPriv(bm, 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>();
} }
sk_sp<SkImage> SkMakeImageInColorSpace(const SkBitmap& bm, sk_sp<SkColorSpace> dstCS, uint32_t id) { sk_sp<SkImage> SkMakeImageInColorSpace(const SkBitmap& bm, sk_sp<SkColorSpace> dstCS, uint32_t id) {
@ -339,7 +339,7 @@ sk_sp<SkImage> SkMakeImageInColorSpace(const SkBitmap& bm, sk_sp<SkColorSpace> d
// For the Android use case, this is very likely to be true. // For the Android use case, this is very likely to be true.
if (SkColorSpace::Equals(srcCS.get(), dstCS.get())) { if (SkColorSpace::Equals(srcCS.get(), dstCS.get())) {
SkASSERT(0 == id || bm.getGenerationID() == id); SkASSERT(0 == id || bm.getGenerationID() == id);
return SkMakeImageFromRasterBitmap(bm, kNever_SkCopyPixelsMode); return SkMakeImageFromRasterBitmapPriv(bm, kNever_SkCopyPixelsMode);
} }
return SkImage::MakeFromGenerator(SkColorSpaceXformImageGenerator::Make( return SkImage::MakeFromGenerator(SkColorSpaceXformImageGenerator::Make(

View File

@ -175,7 +175,7 @@ void SkSurface_Gpu::onPrepareForExternalIO() {
bool SkSurface_Gpu::Valid(const SkImageInfo& info) { bool SkSurface_Gpu::Valid(const SkImageInfo& info) {
switch (info.colorType()) { switch (info.colorType()) {
case kRGBA_F16_SkColorType: case kRGBA_F16_SkColorType:
return !info.colorSpace() || info.colorSpace()->gammaIsLinear(); return info.colorSpace() && info.colorSpace()->gammaIsLinear();
case kRGBA_8888_SkColorType: case kRGBA_8888_SkColorType:
case kBGRA_8888_SkColorType: case kBGRA_8888_SkColorType:
return !info.colorSpace() || info.colorSpace()->gammaCloseToSRGB(); return !info.colorSpace() || info.colorSpace()->gammaCloseToSRGB();
@ -187,7 +187,7 @@ bool SkSurface_Gpu::Valid(const SkImageInfo& info) {
bool SkSurface_Gpu::Valid(GrContext* context, GrPixelConfig config, SkColorSpace* colorSpace) { bool SkSurface_Gpu::Valid(GrContext* context, GrPixelConfig config, SkColorSpace* colorSpace) {
switch (config) { switch (config) {
case kRGBA_half_GrPixelConfig: case kRGBA_half_GrPixelConfig:
return !colorSpace || colorSpace->gammaIsLinear(); return colorSpace && colorSpace->gammaIsLinear();
case kSRGBA_8888_GrPixelConfig: case kSRGBA_8888_GrPixelConfig:
case kSBGRA_8888_GrPixelConfig: case kSBGRA_8888_GrPixelConfig:
return context->caps()->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB(); return context->caps()->srgbSupport() && colorSpace && colorSpace->gammaCloseToSRGB();

View File

@ -63,7 +63,7 @@ bool SkSurfaceValidateRasterInfo(const SkImageInfo& info, size_t rowBytes) {
shift = 2; shift = 2;
break; break;
case kRGBA_F16_SkColorType: case kRGBA_F16_SkColorType:
if (info.colorSpace() && !info.colorSpace()->gammaIsLinear()) { if (!info.colorSpace() || !info.colorSpace()->gammaIsLinear()) {
return false; return false;
} }
shift = 3; shift = 3;

View File

@ -837,7 +837,7 @@ static void test_surface_creation_and_snapshot_with_color_space(
{ kN32_SkColorType, srgbColorSpace, true, "N32-srgb" }, { kN32_SkColorType, srgbColorSpace, true, "N32-srgb" },
{ kN32_SkColorType, adobeColorSpace, true, "N32-adobe" }, { kN32_SkColorType, adobeColorSpace, true, "N32-adobe" },
{ kN32_SkColorType, oddColorSpace, false, "N32-odd" }, { 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, linearColorSpace, true, "F16-linear" },
{ kRGBA_F16_SkColorType, srgbColorSpace, false, "F16-srgb" }, { kRGBA_F16_SkColorType, srgbColorSpace, false, "F16-srgb" },
{ kRGBA_F16_SkColorType, adobeColorSpace, false, "F16-adobe" }, { kRGBA_F16_SkColorType, adobeColorSpace, false, "F16-adobe" },