aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-07-02 16:47:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-03 13:41:13 +0000
commitff2181e62e79ffd2ce628fc8c05b5457d4f54163 (patch)
tree5185ca093986d1ee49dd3abfa93a00991c77ac7a /src
parent94d57c477fe122c146a034c625cebb6c44ef21b0 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrAHardwareBufferImageGenerator.cpp4
-rw-r--r--src/gpu/GrBackendSurface.cpp48
-rw-r--r--src/gpu/gl/GrGLGpu.cpp12
-rw-r--r--src/gpu/gl/GrGLUtil.cpp37
-rw-r--r--src/gpu/gl/GrGLUtil.h2
-rw-r--r--src/gpu/vk/GrVkGpu.cpp12
-rw-r--r--src/gpu/vk/GrVkUtil.cpp34
-rw-r--r--src/gpu/vk/GrVkUtil.h5
8 files changed, 27 insertions, 127 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 ba1f7caf2d..ed45c55758 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);
/**