Remove obsolete checks about colorType and colorSpace
Also remove the unit tests that were enforcing those rules, and the blacklist of that unit test. Bug: skia: Change-Id: I802c9e81a412fe0b19d02f9224b801f4fbd901f2 Reviewed-on: https://skia-review.googlesource.com/c/161562 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Brian Osman <brianosman@google.com> Auto-Submit: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
69261ba149
commit
38a62bdf64
@ -494,7 +494,6 @@
|
||||
"~^RGB565TextureTest$",
|
||||
"~^RGBA4444TextureTest$",
|
||||
"~^TransferPixelsTest$",
|
||||
"~^SurfaceCreationWithColorSpace_Gpu$",
|
||||
"~^SurfaceSemaphores$",
|
||||
"~^VertexAttributeCount$",
|
||||
"~^WrappedProxyTest$",
|
||||
|
@ -752,7 +752,6 @@ def dm_flags(api, bot):
|
||||
match.append('~^RGB565TextureTest$')
|
||||
match.append('~^RGBA4444TextureTest$')
|
||||
match.append('~^TransferPixelsTest$')
|
||||
match.append('~^SurfaceCreationWithColorSpace_Gpu$')
|
||||
match.append('~^SurfaceSemaphores$')
|
||||
match.append('~^VertexAttributeCount$')
|
||||
match.append('~^WrappedProxyTest$')
|
||||
|
@ -262,15 +262,7 @@ bool SkSurface_Gpu::onDraw(const SkDeferredDisplayList* ddl) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool SkSurface_Gpu::Valid(const SkImageInfo& info) {
|
||||
switch (info.colorType()) {
|
||||
case kRGBA_F16_SkColorType:
|
||||
case kRGBA_F32_SkColorType:
|
||||
case kRGBA_8888_SkColorType:
|
||||
case kBGRA_8888_SkColorType:
|
||||
return true;
|
||||
default:
|
||||
return !info.colorSpace();
|
||||
}
|
||||
}
|
||||
|
||||
bool SkSurface_Gpu::Valid(const GrCaps* caps, GrPixelConfig config, SkColorSpace* colorSpace) {
|
||||
@ -278,13 +270,8 @@ bool SkSurface_Gpu::Valid(const GrCaps* caps, GrPixelConfig config, SkColorSpace
|
||||
case kSRGBA_8888_GrPixelConfig:
|
||||
case kSBGRA_8888_GrPixelConfig:
|
||||
return caps->srgbSupport();
|
||||
case kRGBA_half_GrPixelConfig:
|
||||
case kRGBA_float_GrPixelConfig:
|
||||
case kRGBA_8888_GrPixelConfig:
|
||||
case kBGRA_8888_GrPixelConfig:
|
||||
return true;
|
||||
default:
|
||||
return !colorSpace;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,32 +42,6 @@ bool SkSurfaceValidateRasterInfo(const SkImageInfo& info, size_t rowBytes) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static const size_t kMaxTotalSize = SK_MaxS32;
|
||||
|
||||
// TODO(mtklein,brianosman): revisit all these color space decisions
|
||||
switch (info.colorType()) {
|
||||
case kAlpha_8_SkColorType:
|
||||
case kGray_8_SkColorType:
|
||||
case kRGB_565_SkColorType:
|
||||
case kARGB_4444_SkColorType:
|
||||
case kRGB_888x_SkColorType:
|
||||
case kRGBA_1010102_SkColorType:
|
||||
case kRGB_101010x_SkColorType:
|
||||
if (info.colorSpace()) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case kRGBA_8888_SkColorType:
|
||||
case kBGRA_8888_SkColorType:
|
||||
break;
|
||||
case kRGBA_F16_SkColorType:
|
||||
case kRGBA_F32_SkColorType:
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (kIgnoreRowBytesValue == rowBytes) {
|
||||
return true;
|
||||
}
|
||||
@ -85,6 +59,7 @@ bool SkSurfaceValidateRasterInfo(const SkImageInfo& info, size_t rowBytes) {
|
||||
}
|
||||
|
||||
uint64_t size = sk_64_mul(info.height(), rowBytes);
|
||||
static const size_t kMaxTotalSize = SK_MaxS32;
|
||||
if (size > kMaxTotalSize) {
|
||||
return false;
|
||||
}
|
||||
|
@ -904,126 +904,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf
|
||||
}
|
||||
}
|
||||
|
||||
static void test_surface_creation_and_snapshot_with_color_space(
|
||||
skiatest::Reporter* reporter,
|
||||
const char* prefix,
|
||||
bool supportsF16,
|
||||
bool supportsF32,
|
||||
bool supports1010102,
|
||||
std::function<sk_sp<SkSurface>(const SkImageInfo&)> surfaceMaker) {
|
||||
|
||||
auto srgbColorSpace = SkColorSpace::MakeSRGB();
|
||||
SkMatrix44 srgbMatrix;
|
||||
srgbColorSpace->toXYZD50(&srgbMatrix);
|
||||
|
||||
SkColorSpaceTransferFn oddGamma;
|
||||
oddGamma.fA = 1.0f;
|
||||
oddGamma.fB = oddGamma.fC = oddGamma.fD = oddGamma.fE = oddGamma.fF = 0.0f;
|
||||
oddGamma.fG = 4.0f;
|
||||
auto oddColorSpace = SkColorSpace::MakeRGB(oddGamma, srgbMatrix);
|
||||
auto linearColorSpace = SkColorSpace::MakeSRGBLinear();
|
||||
|
||||
const struct {
|
||||
SkColorType fColorType;
|
||||
sk_sp<SkColorSpace> fColorSpace;
|
||||
bool fShouldWork;
|
||||
const char* fDescription;
|
||||
} testConfigs[] = {
|
||||
{ kN32_SkColorType, nullptr, true, "N32-nullptr" },
|
||||
{ kN32_SkColorType, linearColorSpace, true, "N32-linear" },
|
||||
{ kN32_SkColorType, srgbColorSpace, true, "N32-srgb" },
|
||||
{ kN32_SkColorType, oddColorSpace, true, "N32-odd" },
|
||||
{ kRGBA_F16_SkColorType, nullptr, supportsF16, "F16-nullptr" },
|
||||
{ kRGBA_F16_SkColorType, linearColorSpace, supportsF16, "F16-linear" },
|
||||
{ kRGBA_F16_SkColorType, srgbColorSpace, supportsF16, "F16-srgb" },
|
||||
{ kRGBA_F16_SkColorType, oddColorSpace, supportsF16, "F16-odd" },
|
||||
{ kRGBA_F32_SkColorType, nullptr, supportsF32, "F32-nullptr" },
|
||||
{ kRGBA_F32_SkColorType, linearColorSpace, supportsF32, "F32-linear" },
|
||||
{ kRGBA_F32_SkColorType, srgbColorSpace, supportsF32, "F32-srgb" },
|
||||
{ kRGBA_F32_SkColorType, oddColorSpace, supportsF32, "F32-odd" },
|
||||
{ kRGB_565_SkColorType, srgbColorSpace, false, "565-srgb" },
|
||||
{ kAlpha_8_SkColorType, srgbColorSpace, false, "A8-srgb" },
|
||||
{ kRGBA_1010102_SkColorType, nullptr, supports1010102, "1010102-nullptr" },
|
||||
};
|
||||
|
||||
for (auto& testConfig : testConfigs) {
|
||||
SkString fullTestName = SkStringPrintf("%s-%s", prefix, testConfig.fDescription);
|
||||
SkImageInfo info = SkImageInfo::Make(10, 10, testConfig.fColorType, kPremul_SkAlphaType,
|
||||
testConfig.fColorSpace);
|
||||
|
||||
auto surface(surfaceMaker(info));
|
||||
REPORTER_ASSERT(reporter,
|
||||
SkToBool(surface) == testConfig.fShouldWork, fullTestName.c_str());
|
||||
|
||||
if (testConfig.fShouldWork && surface) {
|
||||
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
||||
REPORTER_ASSERT(reporter, image, testConfig.fDescription);
|
||||
SkColorSpace* imageColorSpace = as_IB(image)->onImageInfo().colorSpace();
|
||||
REPORTER_ASSERT(reporter, imageColorSpace == testConfig.fColorSpace.get(),
|
||||
fullTestName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEF_TEST(SurfaceCreationWithColorSpace, reporter) {
|
||||
auto surfaceMaker = [](const SkImageInfo& info) {
|
||||
return SkSurface::MakeRaster(info);
|
||||
};
|
||||
|
||||
test_surface_creation_and_snapshot_with_color_space(reporter, "raster",
|
||||
true, true, true,
|
||||
surfaceMaker);
|
||||
}
|
||||
|
||||
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, ctxInfo) {
|
||||
auto context = ctxInfo.grContext();
|
||||
|
||||
bool supportsF16 = context->contextPriv().caps()->isConfigRenderable(kRGBA_half_GrPixelConfig),
|
||||
supportsF32 = context->contextPriv().caps()->isConfigRenderable(kRGBA_float_GrPixelConfig),
|
||||
supports1010102 = context->contextPriv().caps()->isConfigRenderable(kRGBA_1010102_GrPixelConfig);
|
||||
|
||||
auto surfaceMaker = [context](const SkImageInfo& info) {
|
||||
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
|
||||
};
|
||||
|
||||
test_surface_creation_and_snapshot_with_color_space(reporter, "gpu",
|
||||
supportsF16, supportsF32, supports1010102,
|
||||
surfaceMaker);
|
||||
|
||||
std::vector<GrBackendTexture> backendTextures;
|
||||
auto wrappedSurfaceMaker = [ context, &backendTextures ](const SkImageInfo& info) {
|
||||
GrGpu* gpu = context->contextPriv().getGpu();
|
||||
|
||||
static const int kSize = 10;
|
||||
|
||||
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
|
||||
nullptr, kSize, kSize, info.colorType(), true, GrMipMapped::kNo);
|
||||
|
||||
if (!backendTex.isValid() ||
|
||||
!gpu->isTestingOnlyBackendTexture(backendTex)) {
|
||||
return sk_sp<SkSurface>(nullptr);
|
||||
}
|
||||
backendTextures.push_back(backendTex);
|
||||
|
||||
return SkSurface::MakeFromBackendTexture(context, backendTex,
|
||||
kTopLeft_GrSurfaceOrigin, 0,
|
||||
info.colorType(),
|
||||
sk_ref_sp(info.colorSpace()), nullptr);
|
||||
};
|
||||
|
||||
test_surface_creation_and_snapshot_with_color_space(reporter, "wrapped",
|
||||
supportsF16, supportsF32, supports1010102,
|
||||
wrappedSurfaceMaker);
|
||||
|
||||
context->flush();
|
||||
|
||||
GrGpu* gpu = context->contextPriv().getGpu();
|
||||
gpu->testingOnly_flushGpuAndSync();
|
||||
for (auto backendTex : backendTextures) {
|
||||
gpu->deleteTestingOnlyBackendTexture(backendTex);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_overdraw_surface(skiatest::Reporter* r, SkSurface* surface) {
|
||||
SkOverdrawCanvas canvas(surface->getCanvas());
|
||||
canvas.drawPaint(SkPaint());
|
||||
|
Loading…
Reference in New Issue
Block a user