Revert "Improve handling of GrPixelConfig in GrBackendTex/RT ctors"

This reverts commit 7d2b16ad13.

Reason for revert: Maybe breaking chrome?

Original change's description:
> Improve handling of GrPixelConfig in GrBackendTex/RT ctors
> 
> Make sure that no client facing code was relying on what we set as the
> default value for fConfig by making in kUnkown.
> 
> Bug: skia:
> Change-Id: Ie52ff08ba8deeacc16fe06eb0dd0c7292b2edf91
> Reviewed-on: https://skia-review.googlesource.com/114261
> Reviewed-by: Robert Phillips <robertphillips@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com

Change-Id: I91e190d72407f9c4bee93a031a557f740bb49b66
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/114423
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2018-03-14 17:32:12 +00:00 committed by Skia Commit-Bot
parent 9aef424b71
commit 8a3f55c659
17 changed files with 122 additions and 96 deletions

View File

@ -138,10 +138,7 @@ public:
// Returns true if the backend texture has been initialized.
bool isValid() const { return fConfig != kUnknown_GrPixelConfig; }
#if GR_TEST_UTILS
GrPixelConfig getPixelConfig() const { return fConfig; }
void setPixelConfig(GrPixelConfig config) { fConfig = config; }
#endif
GrPixelConfig testingOnly_getPixelConfig() const;
private:
// Friending for access to the GrPixelConfig
@ -152,7 +149,6 @@ private:
friend class GrGpu;
friend class GrGLGpu;
friend class GrVkGpu;
friend class PromiseImageHelper;
GrPixelConfig config() const { return fConfig; }
int fWidth; //<! width in pixels
@ -228,10 +224,7 @@ public:
// Returns true if the backend texture has been initialized.
bool isValid() const { return fConfig != kUnknown_GrPixelConfig; }
#if GR_TEST_UTILS
GrPixelConfig getPixelConfig() const { return fConfig; }
void setPixelConfig(GrPixelConfig config) { fConfig = config; }
#endif
GrPixelConfig testingOnly_getPixelConfig() const;
private:
// Friending for access to the GrPixelConfig

View File

@ -69,7 +69,7 @@ GrBackendTexture::GrBackendTexture(int width,
const GrVkImageInfo& vkInfo)
: fWidth(width)
, fHeight(height)
, fConfig(kUnknown_GrPixelConfig)
, fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat))
, fMipMapped(GrMipMapped(vkInfo.fLevelCount > 1))
, fBackend(kVulkan_GrBackend)
, fVkInfo(vkInfo) {}
@ -99,7 +99,7 @@ GrBackendTexture::GrBackendTexture(int width,
const GrGLTextureInfo& glInfo)
: fWidth(width)
, fHeight(height)
, fConfig(kUnknown_GrPixelConfig)
, fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat))
, fMipMapped(mipMapped)
, fBackend(kOpenGL_GrBackend)
, fGLInfo(glInfo) {}
@ -159,7 +159,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
, fHeight(height)
, fSampleCnt(SkTMax(1, sampleCnt))
, fStencilBits(0) // We always create stencil buffers internally for vulkan
, fConfig(kUnknown_GrPixelConfig)
, fConfig(GrVkFormatToPixelConfig(vkInfo.fFormat))
, fBackend(kVulkan_GrBackend)
, fVkInfo(vkInfo) {}
#endif
@ -187,7 +187,7 @@ GrBackendRenderTarget::GrBackendRenderTarget(int width,
, fHeight(height)
, fSampleCnt(SkTMax(1, sampleCnt))
, fStencilBits(stencilBits)
, fConfig(kUnknown_GrPixelConfig)
, fConfig(GrGLSizedFormatToPixelConfig(glInfo.fFormat))
, fBackend(kOpenGL_GrBackend)
, fGLInfo(glInfo) {}

View File

@ -4411,9 +4411,7 @@ GrBackendTexture GrGLGpu::createTestingOnlyBackendTexture(const void* pixels, in
// unbind the texture from the texture unit to avoid asserts
GL_CALL(BindTexture(info.fTarget, 0));
GrBackendTexture beTex = GrBackendTexture(w, h, mipMapped, info);
beTex.setPixelConfig(config);
return beTex;
return GrBackendTexture(w, h, mipMapped, info);
}
bool GrGLGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
@ -4503,9 +4501,7 @@ GrBackendRenderTarget GrGLGpu::createTestingOnlyBackendRenderTarget(int w, int h
return {};
}
auto stencilBits = SkToInt(this->glCaps().stencilFormats()[sFormatIdx].fStencilBits);
GrBackendRenderTarget beRT = {w, h, 1, stencilBits, info};
beRT.setPixelConfig(config);
return beRT;
return {w, h, 1, stencilBits, config, info};
}
void GrGLGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget& backendRT) {

View File

@ -91,16 +91,8 @@ GrBackendRenderTarget GrGLRenderTarget::getBackendRenderTarget() const {
numStencilBits = stencil->bits();
}
GrBackendRenderTarget beRT = GrBackendRenderTarget(this->width(), this->height(),
this->numColorSamples(), numStencilBits,
fbi);
#if GR_TEST_UTILS
// We shouldn't have to set this since the client can't access it and we will handle the config
// correctly if we go through our public SkSurface APIs. However, some of our tests bypass the
// public APIs so we need to set this manually here.
beRT.setPixelConfig(this->config());
#endif
return beRT;
return GrBackendRenderTarget(this->width(), this->height(), this->numColorSamples(),
numStencilBits, fbi);
}
size_t GrGLRenderTarget::onGpuMemorySize() const {

View File

@ -98,15 +98,7 @@ GrBackendObject GrGLTexture::getTextureHandle() const {
}
GrBackendTexture GrGLTexture::getBackendTexture() const {
GrBackendTexture beTex = GrBackendTexture(this->width(), this->height(),
this->texturePriv().mipMapped(), fInfo);
#if GR_TEST_UTILS
// We shouldn't have to set this since the client can't access it and we will handle the config
// correctly if we go through our public SkSurface and SkImage APIs. However, some of our tests
// bypass the public APIs so we need to set this manually here.
beTex.setPixelConfig(this->config());
#endif
return beTex;
return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), fInfo);
}
void GrGLTexture::setMemoryBacking(SkTraceMemoryDump* traceMemoryDump,

View File

@ -486,3 +486,38 @@ 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_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;
}
}

View File

@ -248,4 +248,6 @@ void GrGLClearErr(const GrGLInterface* gl);
GrGLenum GrToGLStencilFunc(GrStencilTest test);
GrPixelConfig GrGLSizedFormatToPixelConfig(GrGLenum sizedFormat);
#endif

View File

@ -1422,6 +1422,7 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.image = image;
barrier.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, mipLevels, 0, 1};
initialLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
VK_CALL(CmdPipelineBarrier(cmdBuffer,
GrVkMemory::LayoutToPipelineStageFlags(initialLayout),
VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
@ -1429,7 +1430,6 @@ bool GrVkGpu::createTestingOnlyVkImage(GrPixelConfig config, int w, int h, bool
0, nullptr,
0, nullptr,
1, &barrier));
initialLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
}
// End CommandBuffer
@ -1499,9 +1499,7 @@ GrBackendTexture GrVkGpu::createTestingOnlyBackendTexture(const void* srcData, i
&info)) {
return {};
}
GrBackendTexture beTex = GrBackendTexture(w, h, info);
beTex.setPixelConfig(config);
return beTex;
return GrBackendTexture(w, h, info);
}
bool GrVkGpu::isTestingOnlyBackendTexture(const GrBackendTexture& tex) const {
@ -1545,9 +1543,7 @@ GrBackendRenderTarget GrVkGpu::createTestingOnlyBackendRenderTarget(int w, int h
&info)) {
return {};
}
GrBackendRenderTarget beRT = {w, h, 1, 0, info};
beRT.setPixelConfig(config);
return beRT;
return {w, h, 1, 0, info};
}
void GrVkGpu::deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget& rt) {

View File

@ -352,16 +352,8 @@ GrBackendRenderTarget GrVkRenderTarget::getBackendRenderTarget() const {
if (GrStencilAttachment* stencil = this->renderTargetPriv().getStencilAttachment()) {
numStencilBits = stencil->bits();
}
GrBackendRenderTarget beRT = GrBackendRenderTarget(this->width(), this->height(),
this->numColorSamples(), numStencilBits,
fInfo);
#if GR_TEST_UTILS
// We shouldn't have to set this since the client can't access it and we will handle the config
// correctly if we go through our public SkSurface APIs. However, some of our tests bypass the
// public APIs so we need to set this manually here.
beRT.setPixelConfig(this->config());
#endif
return beRT;
return GrBackendRenderTarget(this->width(), this->height(), this->numColorSamples(),
numStencilBits, fInfo);
}
const GrVkResource* GrVkRenderTarget::stencilImageResource() const {

View File

@ -162,14 +162,7 @@ GrBackendObject GrVkTexture::getTextureHandle() const {
}
GrBackendTexture GrVkTexture::getBackendTexture() const {
GrBackendTexture beTex = GrBackendTexture(this->width(), this->height(), fInfo);
#if GR_TEST_UTILS
// We shouldn't have to set this since the client can't access it and we will handle the config
// correctly if we go through our public SkSurface and SkImage APIs. However, some of our tests
// bypass the public APIs so we need to set this manually here.
beTex.setPixelConfig(this->config());
#endif
return beTex;
return GrBackendTexture(this->width(), this->height(), fInfo);
}
GrVkGpu* GrVkTexture::getVkGpu() const {

View File

@ -72,6 +72,40 @@ 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:

View File

@ -32,6 +32,11 @@ class GrVkGpu;
*/
bool GrPixelConfigToVkFormat(GrPixelConfig config, VkFormat* format);
/**
* Returns the GrPixelConfig for the given vulkan texture format
*/
GrPixelConfig GrVkFormatToPixelConfig(VkFormat format);
bool GrVkFormatIsSupported(VkFormat);
/**

View File

@ -589,7 +589,7 @@ public:
this->resetReleaseHelper();
}
sk_sp<GrTexture> getTexture(GrResourceProvider* resourceProvider, GrPixelConfig config) {
sk_sp<GrTexture> getTexture(GrResourceProvider* resourceProvider) {
// Releases the promise helper if there are no outstanding hard refs. This means that we
// don't have any ReleaseProcs waiting to be called so we will need to do a fulfill.
if (fReleaseHelper && fReleaseHelper->weak_expired()) {
@ -599,7 +599,6 @@ public:
sk_sp<GrTexture> tex;
if (!fReleaseHelper) {
fFulfillProc(fContext, &fBackendTex);
fBackendTex.fConfig = config;
if (!fBackendTex.isValid()) {
// Even though the GrBackendTexture is not valid, we must call the release
// proc to keep our contract of always calling Fulfill and Release in pairs.
@ -701,13 +700,13 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
PromiseImageHelper promiseHelper(textureFulfillProc, textureReleaseProc, textureContext);
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
[promiseHelper, config] (GrResourceProvider* resourceProvider) mutable {
[promiseHelper] (GrResourceProvider* resourceProvider) mutable {
if (!resourceProvider) {
promiseHelper.reset();
return sk_sp<GrTexture>();
}
return promiseHelper.getTexture(resourceProvider, config);
return promiseHelper.getTexture(resourceProvider);
}, desc, origin, mipMapped, GrRenderTargetFlags::kNone, SkBackingFit::kExact,
SkBudgeted::kNo, GrSurfaceProxy::LazyInstantiationType::kUninstantiate);

View File

@ -215,7 +215,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
sk_sp<GrSurfaceProxy> sProxy(
proxyProvider->wrapBackendRenderTarget(backendRT, origin));
check_surface(reporter, sProxy.get(), origin, kWidthHeight, kWidthHeight,
backendRT.getPixelConfig(), SkBudgeted::kNo);
backendRT.testingOnly_getPixelConfig(), SkBudgeted::kNo);
static constexpr int kExpectedNumSamples = 1;
check_rendertarget(reporter, caps, resourceProvider, sProxy->asRenderTargetProxy(),
kExpectedNumSamples, SkBackingFit::kExact,
@ -244,7 +244,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
proxyProvider->wrapBackendRenderTarget(backendRT, origin));
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
backendRT.getPixelConfig(), SkBudgeted::kNo);
backendRT.testingOnly_getPixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact, 0);
@ -265,7 +265,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
backendTex.getPixelConfig(), SkBudgeted::kNo);
backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@ -290,7 +290,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
backendTex.getPixelConfig(), SkBudgeted::kNo);
backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
check_rendertarget(reporter, caps, resourceProvider,
sProxy->asRenderTargetProxy(),
supportedNumSamples, SkBackingFit::kExact,
@ -316,7 +316,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
check_surface(reporter, sProxy.get(), origin,
kWidthHeight, kWidthHeight,
backendTex.getPixelConfig(), SkBudgeted::kNo);
backendTex.testingOnly_getPixelConfig(), SkBudgeted::kNo);
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
SkBackingFit::kExact);

View File

@ -205,8 +205,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, repo
->accessRenderTargetContext()
->numStencilSamples();
REPORTER_ASSERT(reporter, sampleCnt == max, "Exected: %d, actual: %d", max, sampleCnt);
gpu->deleteTestingOnlyBackendTexture(backendTex);
}
}
#endif

View File

@ -46,7 +46,6 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkImageInfo backendCopy = *imageInfo;
backendCopy.fImage = VK_NULL_HANDLE;
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, !tex);
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
@ -58,7 +57,6 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkImageInfo backendCopy = *imageInfo;
backendCopy.fAlloc = GrVkAlloc();
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
tex = gpu->wrapBackendTexture(backendTex, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, !tex);
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
@ -69,7 +67,6 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
{
GrVkImageInfo backendCopy = *imageInfo;
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
tex = gpu->wrapBackendTexture(backendTex, kAdopt_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
@ -79,11 +76,12 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkGpu* gpu = static_cast<GrVkGpu*>(context->contextPriv().getGpu());
GrBackendRenderTarget origBackendRT = gpu->createTestingOnlyBackendRenderTarget(
kW, kH, GrColorType::kRGBA_8888, GrSRGBEncoded::kNo);
GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(nullptr, kW, kH,
kPixelConfig, true,
GrMipMapped::kNo);
const GrVkImageInfo* imageInfo = origBackendTex.getVkImageInfo();
const GrVkImageInfo* imageInfo = origBackendRT.getVkImageInfo();
GrPixelConfig pixelConfig = origBackendRT.getPixelConfig();
GrBackendRenderTarget origBackendRT(kW, kH, 1, 0, *imageInfo);
sk_sp<GrRenderTarget> rt = gpu->wrapBackendRenderTarget(origBackendRT);
REPORTER_ASSERT(reporter, rt);
@ -93,7 +91,6 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkImageInfo backendCopy = *imageInfo;
backendCopy.fImage = VK_NULL_HANDLE;
GrBackendRenderTarget backendRT(kW, kH, 1, 0, backendCopy);
backendRT.setPixelConfig(pixelConfig);
rt = gpu->wrapBackendRenderTarget(backendRT);
REPORTER_ASSERT(reporter, !rt);
}
@ -104,12 +101,13 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
backendCopy.fAlloc = GrVkAlloc();
// can wrap null alloc
GrBackendRenderTarget backendRT(kW, kH, 1, 0, backendCopy);
backendRT.setPixelConfig(pixelConfig);
rt = gpu->wrapBackendRenderTarget(backendRT);
REPORTER_ASSERT(reporter, rt);
}
gpu->deleteTestingOnlyBackendRenderTarget(origBackendRT);
// When we wrapBackendRenderTarget it is always borrowed, so we must make sure to free the
// resource when we're done.
gpu->deleteTestingOnlyBackendTexture(origBackendTex);
}
void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
@ -129,7 +127,6 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkImageInfo backendCopy = *imageInfo;
backendCopy.fImage = VK_NULL_HANDLE;
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, !tex);
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership);
@ -141,7 +138,6 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
GrVkImageInfo backendCopy = *imageInfo;
backendCopy.fAlloc = GrVkAlloc();
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kBorrow_GrWrapOwnership);
REPORTER_ASSERT(reporter, !tex);
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership);
@ -152,7 +148,6 @@ void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
{
GrVkImageInfo backendCopy = *imageInfo;
GrBackendTexture backendTex = GrBackendTexture(kW, kH, backendCopy);
backendTex.setPixelConfig(kPixelConfig);
tex = gpu->wrapRenderableBackendTexture(backendTex, 1, kAdopt_GrWrapOwnership);
REPORTER_ASSERT(reporter, tex);
}

View File

@ -56,32 +56,26 @@ void SetupAlwaysEvictAtlas(GrContext* context, int dim) {
GrBackendTexture CreateBackendTexture(GrBackend backend, int width, int height,
GrPixelConfig config, GrMipMapped mipMapped,
GrBackendObject handle) {
GrBackendTexture beTex;
switch (backend) {
#ifdef SK_VULKAN
case kVulkan_GrBackend: {
GrVkImageInfo* vkInfo = (GrVkImageInfo*)(handle);
SkASSERT((GrMipMapped::kYes == mipMapped) == (vkInfo->fLevelCount > 1));
beTex = GrBackendTexture(width, height, *vkInfo);
break;
return GrBackendTexture(width, height, *vkInfo);
}
#endif
case kOpenGL_GrBackend: {
GrGLTextureInfo* glInfo = (GrGLTextureInfo*)(handle);
SkASSERT(glInfo->fFormat);
beTex = GrBackendTexture(width, height, mipMapped, *glInfo);
break;
return GrBackendTexture(width, height, mipMapped, *glInfo);
}
case kMock_GrBackend: {
GrMockTextureInfo* mockInfo = (GrMockTextureInfo*)(handle);
beTex = GrBackendTexture(width, height, mipMapped, *mockInfo);
break;
return GrBackendTexture(width, height, mipMapped, *mockInfo);
}
default:
return GrBackendTexture();
}
beTex.setPixelConfig(config);
return beTex;
}
GrBackendFormat CreateBackendFormatFromTexture(const GrBackendTexture& tex) {
@ -344,6 +338,16 @@ void GrDrawingManager::testingOnly_removeOnFlushCallbackObject(GrOnFlushCallback
//////////////////////////////////////////////////////////////////////////////
GrPixelConfig GrBackendTexture::testingOnly_getPixelConfig() const {
return fConfig;
}
GrPixelConfig GrBackendRenderTarget::testingOnly_getPixelConfig() const {
return fConfig;
}
//////////////////////////////////////////////////////////////////////////////
#define DRAW_OP_TEST_EXTERN(Op) \
extern std::unique_ptr<GrDrawOp> Op##__Test(GrPaint&&, SkRandom*, GrContext*, GrFSAAType)
#define DRAW_OP_TEST_ENTRY(Op) Op##__Test