When creating testing backendTexture take colorspace into account.

Bug: skia:
Change-Id: Ifa8dbad3eca81790648476f9a6d3fa5a088fede9
Reviewed-on: https://skia-review.googlesource.com/122341
Reviewed-by: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2018-04-19 10:28:37 -04:00 committed by Skia Commit-Bot
parent bc54533b2b
commit 57bf4a3dbf
7 changed files with 24 additions and 16 deletions

View File

@ -1510,7 +1510,8 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
break;
case SkCommandLineConfigGpu::SurfType::kBackendTexture:
backendTexture = context->contextPriv().getGpu()->createTestingOnlyBackendTexture(
nullptr, info.width(), info.height(), info.colorType(), true, GrMipMapped::kNo);
nullptr, info.width(), info.height(), info.colorType(), info.colorSpace(),
true, GrMipMapped::kNo);
surface = SkSurface::MakeFromBackendTexture(context, backendTexture,
kTopLeft_GrSurfaceOrigin, fSampleCount,
fColorType, info.refColorSpace(), &props);
@ -2107,6 +2108,7 @@ public:
info.fBitmap.width(),
info.fBitmap.height(),
info.fBitmap.colorType(),
info.fBitmap.colorSpace(),
false, GrMipMapped::kNo));
// The GMs sometimes request too large an image
//SkAssertResult(callbackContext->backendTexture().isValid());

View File

@ -454,7 +454,8 @@ public:
only to be used for testing (particularly for testing the methods that import an externally
created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */
GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, SkColorType,
bool isRenderTarget, GrMipMapped);
SkColorSpace* cs, bool isRenderTarget,
GrMipMapped);
/** Older version based on GrPixelConfig. Currently the preferred one above devolves to this. */
virtual GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h,
GrPixelConfig config,

View File

@ -1251,10 +1251,14 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool
mipLevels = SkMipMap::ComputeLevelCount(w, h) + 1;
}
// sRGB format images may need to be aliased to linear for various reasons (legacy mode):
VkImageCreateFlags createFlags = GrVkFormatIsSRGB(pixelFormat, nullptr)
? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0;
const VkImageCreateInfo imageCreateInfo = {
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
nullptr, // pNext
0, // VkImageCreateFlags
createFlags, // VkImageCreateFlags
VK_IMAGE_TYPE_2D, // VkImageType
pixelFormat, // VkFormat
{(uint32_t)w, (uint32_t)h, 1}, // VkExtent3D

View File

@ -494,7 +494,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter
bool can = ctxInfo.grContext()->colorTypeSupportedAsImage(colorType);
auto* gpu = ctxInfo.grContext()->contextPriv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
nullptr, kSize, kSize, colorType, false, GrMipMapped::kNo);
nullptr, kSize, kSize, colorType, nullptr, false, GrMipMapped::kNo);
auto img =
SkImage::MakeFromTexture(ctxInfo.grContext(), backendTex, kTopLeft_GrSurfaceOrigin,
colorType, kOpaque_SkAlphaType, nullptr);

View File

@ -255,8 +255,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
{
GrBackendTexture backendTex =
gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
kWidthHeight, colorType, true,
GrMipMapped::kNo);
kWidthHeight, colorType, nullptr,
true, GrMipMapped::kNo);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
backendTex, origin, supportedNumSamples);
if (!sProxy) {
@ -279,8 +279,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
{
GrBackendTexture backendTex =
gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
kWidthHeight, colorType, true,
GrMipMapped::kNo);
kWidthHeight, colorType, nullptr,
true, GrMipMapped::kNo);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapRenderableBackendTexture(
backendTex, origin, supportedNumSamples);
@ -305,8 +305,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
// Internal offscreen texture
GrBackendTexture backendTex =
gpu->createTestingOnlyBackendTexture(nullptr, kWidthHeight,
kWidthHeight, colorType, false,
GrMipMapped::kNo);
kWidthHeight, colorType, nullptr,
false, GrMipMapped::kNo);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTexture(
backendTex, origin, kBorrow_GrWrapOwnership, nullptr, nullptr);

View File

@ -109,7 +109,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
auto* gpu = ctxInfo.grContext()->contextPriv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
nullptr, kSize, kSize, colorType, true, GrMipMapped::kNo);
nullptr, kSize, kSize, colorType, nullptr, true, GrMipMapped::kNo);
surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex,
kTopLeft_GrSurfaceOrigin, 0, colorType, nullptr,
nullptr);
@ -136,8 +136,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf));
backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kSize, kSize, colorType, true,
GrMipMapped::kNo);
backendTex = gpu->createTestingOnlyBackendTexture(nullptr, kSize, kSize, colorType, nullptr,
true, GrMipMapped::kNo);
surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex,
kTopLeft_GrSurfaceOrigin, kSampleCnt, colorType,
nullptr, nullptr);
@ -190,7 +190,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, repo
}
auto* gpu = ctxInfo.grContext()->contextPriv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
nullptr, kSize, kSize, colorType, true, GrMipMapped::kNo);
nullptr, kSize, kSize, colorType, nullptr, true, GrMipMapped::kNo);
if (!backendTex.isValid()) {
continue;
}

View File

@ -164,9 +164,10 @@ void GrGpu::Stats::dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>*
#endif
GrBackendTexture GrGpu::createTestingOnlyBackendTexture(const void* pixels, int w, int h,
SkColorType colorType, bool isRenderTarget,
SkColorType colorType,
SkColorSpace* cs, bool isRenderTarget,
GrMipMapped mipMapped) {
GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, nullptr, *this->caps());
GrPixelConfig config = SkImageInfo2GrPixelConfig(colorType, cs, *this->caps());
if (kUnknown_GrPixelConfig == config) {
return GrBackendTexture();
}