diff options
author | Greg Daniel <egdaniel@google.com> | 2018-07-03 16:18:29 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-03 20:46:27 +0000 |
commit | 108bb232775c0b768ce1beca929ed31a97b46ed3 (patch) | |
tree | ff882d51dac3e7dfd66ae79a0be0883d6b379c25 /src | |
parent | 58a1605d2b9bab077f53b6a223f9e7ce1891d3ea (diff) |
Reland "Remove setting/use of GrPixelConfig in GrBackendTex/RT ctors."
This reverts commit 34aa059c1502d67c9a5f4db449667a8709b69fb9.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> Revert "Remove setting/use of GrPixelConfig in GrBackendTex/RT ctors."
>
> This reverts commit ff2181e62e79ffd2ce628fc8c05b5457d4f54163.
>
> Reason for revert: suspect it's behind Chrome roll failure
>
> Original change's description:
> > Remove setting/use of GrPixelConfig in GrBackendTex/RT ctors.
> >
> > Bug: skia:
> > Change-Id: I1466668e3502cd1e6e1f6aed4105e0f626d293dd
> > Reviewed-on: https://skia-review.googlesource.com/138987
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I4cba44858aafffbadc45e18349b93c741d7cfc66
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/139220
> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Bug: skia:
Change-Id: Ib1fd10c126862824f3e31c420c697ac749c637f5
Reviewed-on: https://skia-review.googlesource.com/139221
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrAHardwareBufferImageGenerator.cpp | 4 | ||||
-rw-r--r-- | src/gpu/GrBackendSurface.cpp | 48 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 12 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.cpp | 37 | ||||
-rw-r--r-- | src/gpu/gl/GrGLUtil.h | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 12 | ||||
-rw-r--r-- | src/gpu/vk/GrVkUtil.cpp | 34 | ||||
-rw-r--r-- | src/gpu/vk/GrVkUtil.h | 5 | ||||
-rw-r--r-- | src/image/SkImage_Gpu.cpp | 21 |
9 files changed, 41 insertions, 134 deletions
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp index e3ae782d9a..40be392230 100644 --- a/src/gpu/GrAHardwareBufferImageGenerator.cpp +++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp @@ -213,12 +213,14 @@ sk_sp<GrTextureProxy> GrAHardwareBufferImageGenerator::makeProxy(GrContext* cont return nullptr; } - GrBackendTexture backendTex(getInfo().width(), getInfo().height(), pixelConfig, textureInfo); + GrBackendTexture backendTex(getInfo().width(), getInfo().height(), GrMipMapped::kNo, + textureInfo); if (backendTex.width() <= 0 || backendTex.height() <= 0) { glDeleteTextures(1, &texID); eglDestroyImageKHR(display, image); return nullptr; } + backendTex.fConfig = pixelConfig; sk_sp<GrTexture> tex = context->contextPriv().resourceProvider()->wrapBackendTexture( backendTex, kAdopt_GrWrapOwnership); if (!tex) { diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp index 9977555093..7e10cb20a2 100644 --- a/src/gpu/GrBackendSurface.cpp +++ b/src/gpu/GrBackendSurface.cpp @@ -96,7 +96,7 @@ GrBackendTexture::GrBackendTexture(int width, : fIsValid(true) , fWidth(width) , fHeight(height) - , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat)) + , fConfig(kUnknown_GrPixelConfig) , fMipMapped(GrMipMapped(vkInfo.fLevelCount > 1)) , fBackend(kVulkan_GrBackend) , fVkInfo(vkInfo, layout.release()) { @@ -117,28 +117,6 @@ GrBackendTexture::GrBackendTexture(int width, , fMtlInfo(mtlInfo) {} #endif -#if GR_TEST_UTILS - -GrBackendTexture::GrBackendTexture(int width, - int height, - GrPixelConfig config, - const GrGLTextureInfo& glInfo) - : GrBackendTexture(width, height, config, GrMipMapped::kNo, glInfo) {} - -GrBackendTexture::GrBackendTexture(int width, - int height, - GrPixelConfig config, - GrMipMapped mipMapped, - const GrGLTextureInfo& glInfo) - : fIsValid(true) - , fWidth(width) - , fHeight(height) - , fConfig(config) - , fMipMapped(mipMapped) - , fBackend(kOpenGL_GrBackend) - , fGLInfo(glInfo) {} -#endif - GrBackendTexture::GrBackendTexture(int width, int height, GrMipMapped mipMapped, @@ -146,7 +124,7 @@ GrBackendTexture::GrBackendTexture(int width, : fIsValid(true) , fWidth(width) , fHeight(height) - , fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat)) + , fConfig(kUnknown_GrPixelConfig) , fMipMapped(mipMapped) , fBackend(kOpenGL_GrBackend) , fGLInfo(glInfo) {} @@ -334,7 +312,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, , fHeight(height) , fSampleCnt(SkTMax(1, sampleCnt)) , fStencilBits(0) // We always create stencil buffers internally for vulkan - , fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat)) + , fConfig(kUnknown_GrPixelConfig) , fBackend(kVulkan_GrBackend) , fVkInfo(vkInfo, layout.release()) {} #endif @@ -354,24 +332,6 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, , fMtlInfo(mtlInfo) {} #endif -#if GR_TEST_UTILS - -GrBackendRenderTarget::GrBackendRenderTarget(int width, - int height, - int sampleCnt, - int stencilBits, - GrPixelConfig config, - const GrGLFramebufferInfo& glInfo) - : fIsValid(true) - , fWidth(width) - , fHeight(height) - , fSampleCnt(SkTMax(1, sampleCnt)) - , fStencilBits(stencilBits) - , fConfig(config) - , fBackend(kOpenGL_GrBackend) - , fGLInfo(glInfo) {} -#endif - GrBackendRenderTarget::GrBackendRenderTarget(int width, int height, int sampleCnt, @@ -382,7 +342,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width, , fHeight(height) , fSampleCnt(SkTMax(1, sampleCnt)) , fStencilBits(stencilBits) - , fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat)) + , fConfig(kUnknown_GrPixelConfig) , fBackend(kOpenGL_GrBackend) , fGLInfo(glInfo) {} diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index d5c3cc3de2..58aad4d18e 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -3975,7 +3975,11 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in // unbind the texture from the texture unit to avoid asserts GL_CALL(BindTexture(info.fTarget, 0)); - return GrBackendTexture(w, h, mipMapped, info); + GrBackendTexture beTex = GrBackendTexture(w, h, mipMapped, info); + // Lots of tests don't go through Skia's public interface which will set the config so for + // testing we make sure we set a config here. + beTex.setPixelConfig(config); + return beTex; } bool GrGLGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const { @@ -4069,7 +4073,11 @@ GrBackendRenderTarget GrGLGpu::createTestingOnlyBackendRenderTarget(int w, int h return {}; } auto stencilBits = SkToInt(this->glCaps().stencilFormats()[sFormatIdx].fStencilBits); - return {w, h, 1, stencilBits, config, info}; + GrBackendRenderTarget beRT = GrBackendRenderTarget(w, h, 1, stencilBits, info); + // Lots of tests don't go through Skia's public interface which will set the config so for + // testing we make sure we set a config here. + beRT.setPixelConfig(config); + return beRT; } void GrGLGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget& backendRT) { diff --git a/src/gpu/gl/GrGLUtil.cpp b/src/gpu/gl/GrGLUtil.cpp index e785c1e2f6..3732b481a9 100644 --- a/src/gpu/gl/GrGLUtil.cpp +++ b/src/gpu/gl/GrGLUtil.cpp @@ -532,40 +532,3 @@ GrGLenum GrToGLStencilFunc(GrStencilTest test) { return gTable[(int)test]; } -GrPixelConfig GrGLSizedFormatToPixelConfig(GrGLenum sizedFormat) { - switch (sizedFormat) { - case GR_GL_R8: - return kAlpha_8_as_Red_GrPixelConfig; - case GR_GL_ALPHA8: - return kAlpha_8_as_Alpha_GrPixelConfig; - case GR_GL_RGBA8: - return kRGBA_8888_GrPixelConfig; - case GR_GL_RGB8: - return kRGB_888_GrPixelConfig; - case GR_GL_BGRA8: - return kBGRA_8888_GrPixelConfig; - case GR_GL_SRGB8_ALPHA8: - return kSRGBA_8888_GrPixelConfig; - case GR_GL_RGB565: - return kRGB_565_GrPixelConfig; - case GR_GL_RGB5: - return kRGB_565_GrPixelConfig; - case GR_GL_RGBA4: - return kRGBA_4444_GrPixelConfig; - case GR_GL_RGB10_A2: - return kRGBA_1010102_GrPixelConfig; - case GR_GL_LUMINANCE8: - return kGray_8_GrPixelConfig; - case GR_GL_RGBA32F: - return kRGBA_float_GrPixelConfig; - case GR_GL_RG32F: - return kRG_float_GrPixelConfig; - case GR_GL_R16F: - return kAlpha_half_as_Red_GrPixelConfig; - case GR_GL_RGBA16F: - return kRGBA_half_GrPixelConfig; - default: - return kUnknown_GrPixelConfig; - } -} - diff --git a/src/gpu/gl/GrGLUtil.h b/src/gpu/gl/GrGLUtil.h index 039c1eea78..909c8fd7d5 100644 --- a/src/gpu/gl/GrGLUtil.h +++ b/src/gpu/gl/GrGLUtil.h @@ -256,6 +256,4 @@ void GrGLClearErr(const GrGLInterface* gl); GrGLenum GrToGLStencilFunc(GrStencilTest test); -GrPixelConfig GrGLSizedFormatToPixelConfig(GrGLenum sizedFormat); - #endif diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 881e28d514..a98b3b3108 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -1359,7 +1359,11 @@ GrBackendTexture GrVkGpu::createTestingOnlyBackendTexture(const void* srcData, i &info)) { return {}; } - return GrBackendTexture(w, h, info); + GrBackendTexture beTex = GrBackendTexture(w, h, info); + // Lots of tests don't go through Skia's public interface which will set the config so for + // testing we make sure we set a config here. + beTex.setPixelConfig(config); + return beTex; } bool GrVkGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const { @@ -1409,7 +1413,11 @@ GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h &info)) { return {}; } - return {w, h, 1, 0, info}; + GrBackendRenderTarget beRT = GrBackendRenderTarget(w, h, 1, 0, info); + // Lots of tests don't go through Skia's public interface which will set the config so for + // testing we make sure we set a config here. + beRT.setPixelConfig(config); + return beRT; } void GrVkGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget& rt) { diff --git a/src/gpu/vk/GrVkUtil.cpp b/src/gpu/vk/GrVkUtil.cpp index 2b0bba732d..b0aa3d4c14 100644 --- a/src/gpu/vk/GrVkUtil.cpp +++ b/src/gpu/vk/GrVkUtil.cpp @@ -75,40 +75,6 @@ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format) { return false; } -GrPixelConfig GrVkFormatToPixelConfig(VkFormat format) { - switch (format) { - case VK_FORMAT_R8G8B8A8_UNORM: - return kRGBA_8888_GrPixelConfig; - case VK_FORMAT_B8G8R8A8_UNORM: - return kBGRA_8888_GrPixelConfig; - case VK_FORMAT_R8G8B8A8_SRGB: - return kSRGBA_8888_GrPixelConfig; - case VK_FORMAT_B8G8R8A8_SRGB: - return kSBGRA_8888_GrPixelConfig; - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: - return kRGBA_1010102_GrPixelConfig; - case VK_FORMAT_R5G6B5_UNORM_PACK16: - return kRGB_565_GrPixelConfig; - break; - case VK_FORMAT_B4G4R4A4_UNORM_PACK16: - // R4G4B4A4 is not required to be supported so we actually - // store RGBA_4444 data as B4G4R4A4. - return kRGBA_4444_GrPixelConfig; - case VK_FORMAT_R8_UNORM: - return kAlpha_8_GrPixelConfig; - case VK_FORMAT_R32G32B32A32_SFLOAT: - return kRGBA_float_GrPixelConfig; - case VK_FORMAT_R32G32_SFLOAT: - return kRG_float_GrPixelConfig; - case VK_FORMAT_R16G16B16A16_SFLOAT: - return kRGBA_half_GrPixelConfig; - case VK_FORMAT_R16_SFLOAT: - return kAlpha_half_GrPixelConfig; - default: - return kUnknown_GrPixelConfig; - } -} - bool GrVkFormatPixelConfigPairIsValid(VkFormat format, GrPixelConfig config) { switch (format) { case VK_FORMAT_R8G8B8A8_UNORM: diff --git a/src/gpu/vk/GrVkUtil.h b/src/gpu/vk/GrVkUtil.h index 71cc5d4e6a..7c56c6941f 100644 --- a/src/gpu/vk/GrVkUtil.h +++ b/src/gpu/vk/GrVkUtil.h @@ -33,11 +33,6 @@ class GrVkGpu; */ bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format); -/** -* Returns the GrPixelConfig for the given vulkan texture format -*/ -GrPixelConfig GrVkFormatToPixelConfig(VkFormat format); - bool GrVkFormatIsSupported(VkFormat); /** diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 1a89ba42ae..7b24858c2f 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -370,6 +370,10 @@ sk_sp<SkImage> SkImage_Gpu::MakeFromYUVATexturesCopyImpl(GrContext* ctx, bool nv12 = (yuvaIndices[1].fIndex == yuvaIndices[2].fIndex); auto ct = nv12 ? kRGBA_8888_SkColorType : kAlpha_8_SkColorType; + // We need to make a copy of the input backend textures because we need to preserve the result + // of validate_backend_texture. + GrBackendTexture yuvaTexturesCopy[4]; + for (int i = 0; i < 4; ++i) { // Validate that the yuvaIndices refer to valid backend textures. SkYUVAIndex& yuvaIndex = yuvaIndices[i]; @@ -382,12 +386,14 @@ sk_sp<SkImage> SkImage_Gpu::MakeFromYUVATexturesCopyImpl(GrContext* ctx, // at most 4 images sources being passed in, could not have a index more than 3. return nullptr; } - auto texture = yuvaTextures[yuvaIndex.fIndex]; - // TODO: Instead of using assumption about whether it is NV12 format to guess colorType, - // actually use channel information here. - if (!validate_backend_texture(ctx, texture, &texture.fConfig, ct, kPremul_SkAlphaType, - nullptr)) { - return nullptr; + if (!yuvaTexturesCopy[yuvaIndex.fIndex].isValid()) { + yuvaTexturesCopy[yuvaIndex.fIndex] = yuvaTextures[yuvaIndex.fIndex]; + // TODO: Instead of using assumption about whether it is NV12 format to guess colorType, + // actually use channel information here. + if (!validate_backend_texture(ctx, yuvaTexturesCopy[i], &yuvaTexturesCopy[i].fConfig, + ct, kPremul_SkAlphaType, nullptr)) { + return nullptr; + } } // TODO: Check that for each plane, the channel actually exist in the image source we are @@ -406,8 +412,9 @@ sk_sp<SkImage> SkImage_Gpu::MakeFromYUVATexturesCopyImpl(GrContext* ctx, } if (!tempTextureProxies[textureIndex]) { + SkASSERT(yuvaTexturesCopy[textureIndex].isValid()); tempTextureProxies[textureIndex] = - proxyProvider->wrapBackendTexture(yuvaTextures[textureIndex], origin); + proxyProvider->wrapBackendTexture(yuvaTexturesCopy[textureIndex], origin); } } sk_sp<GrTextureProxy> yProxy = tempTextureProxies[yuvaIndices[0].fIndex]; |