Switch over to using new direct allocation API in our tests (as much as possible at least)

To fully switch over we need the entry point that uploads data but most of the old call
sites can be switched over now.

Change-Id: I362b1dfde7d88bf8d3f8f90155f53d9ac442a329
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/214300
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2019-05-17 10:01:21 -04:00 committed by Skia Commit-Bot
parent 4f71cccb9d
commit 9b16f81858
24 changed files with 171 additions and 206 deletions

View File

@ -1388,7 +1388,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
&props); &props);
break; break;
case SkCommandLineConfigGpu::SurfType::kBackendTexture: case SkCommandLineConfigGpu::SurfType::kBackendTexture:
backendTexture = context->priv().getGpu()->createTestingOnlyBackendTexture( backendTexture = context->priv().createBackendTexture(
info.width(), info.height(), info.colorType(), info.width(), info.height(), info.colorType(),
GrMipMapped::kNo, GrRenderable::kYes); GrMipMapped::kNo, GrRenderable::kYes);
surface = SkSurface::MakeFromBackendTexture(context, backendTexture, surface = SkSurface::MakeFromBackendTexture(context, backendTexture,
@ -1440,7 +1440,7 @@ Error GPUSink::onDraw(const Src& src, SkBitmap* dst, SkWStream*, SkString* log,
if (!context->abandoned()) { if (!context->abandoned()) {
surface.reset(); surface.reset();
if (backendTexture.isValid()) { if (backendTexture.isValid()) {
context->priv().getGpu()->deleteTestingOnlyBackendTexture(backendTexture); context->priv().deleteBackendTexture(backendTexture);
} }
if (backendRT.isValid()) { if (backendRT.isValid()) {
context->priv().getGpu()->deleteTestingOnlyBackendRenderTarget(backendRT); context->priv().getGpu()->deleteTestingOnlyBackendRenderTarget(backendRT);

View File

@ -142,12 +142,7 @@ protected:
void createResultTexture(GrContext* context, int width, int height, void createResultTexture(GrContext* context, int width, int height,
GrBackendTexture* resultTexture) { GrBackendTexture* resultTexture) {
GrGpu* gpu = context->priv().getGpu(); *resultTexture = context->priv().createBackendTexture(
if (!gpu) {
return;
}
*resultTexture = gpu->createTestingOnlyBackendTexture(
width, height, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes); width, height, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes);
context->resetContext(); context->resetContext();
@ -166,9 +161,7 @@ protected:
context->flush(); context->flush();
gpu->testingOnly_flushGpuAndSync(); gpu->testingOnly_flushGpuAndSync();
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
if (textures[i].isValid()) { context->priv().deleteBackendTexture(textures[i]);
gpu->deleteTestingOnlyBackendTexture(textures[i]);
}
} }
context->resetContext(); context->resetContext();

View File

@ -1089,7 +1089,7 @@ protected:
SkASSERT(gpu); SkASSERT(gpu);
gpu->testingOnly_flushGpuAndSync(); gpu->testingOnly_flushGpuAndSync();
for (const auto& tex : fBackendTextures) { for (const auto& tex : fBackendTextures) {
gpu->deleteTestingOnlyBackendTexture(tex); context->priv().deleteBackendTexture(tex);
} }
fBackendTextures.reset(); fBackendTextures.reset();
} }
@ -1241,7 +1241,7 @@ protected:
SkASSERT(gpu); SkASSERT(gpu);
gpu->testingOnly_flushGpuAndSync(); gpu->testingOnly_flushGpuAndSync();
for (const auto& tex : fBackendTextures) { for (const auto& tex : fBackendTextures) {
gpu->deleteTestingOnlyBackendTexture(tex); context->priv().deleteBackendTexture(tex);
} }
fBackendTextures.reset(); fBackendTextures.reset();
} }

View File

@ -185,7 +185,7 @@ public:
fColorType, fColorSpace, &fSurfaceProps); fColorType, fColorSpace, &fSurfaceProps);
} }
*backend = gpu->createTestingOnlyBackendTexture(fWidth, fHeight, fColorType, *backend = context->priv().createBackendTexture(fWidth, fHeight, fColorType,
mipmapped, GrRenderable::kYes); mipmapped, GrRenderable::kYes);
if (!backend->isValid() || !gpu->isTestingOnlyBackendTexture(*backend)) { if (!backend->isValid() || !gpu->isTestingOnlyBackendTexture(*backend)) {
return nullptr; return nullptr;
@ -204,7 +204,7 @@ public:
} }
if (!surface) { if (!surface) {
gpu->deleteTestingOnlyBackendTexture(*backend); this->cleanUpBackEnd(context, *backend);
return nullptr; return nullptr;
} }
@ -212,13 +212,7 @@ public:
} }
void cleanUpBackEnd(GrContext* context, const GrBackendTexture& backend) const { void cleanUpBackEnd(GrContext* context, const GrBackendTexture& backend) const {
if (!backend.isValid()) { context->priv().deleteBackendTexture(backend);
return;
}
GrGpu* gpu = context->priv().getGpu();
gpu->deleteTestingOnlyBackendTexture(backend);
} }
private: private:
@ -582,8 +576,8 @@ enum class DDLStage { kMakeImage, kDrawImage, kDetach, kDrawDDL };
// This tests the ability to create and use wrapped textures in a DDL world // This tests the ability to create and use wrapped textures in a DDL world
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext(); GrContext* context = ctxInfo.grContext();
GrGpu* gpu = context->priv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); kSize, kSize, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
if (!backendTex.isValid()) { if (!backendTex.isValid()) {
return; return;
@ -594,7 +588,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
sk_sp<SkSurface> s = params.make(context, &backend); sk_sp<SkSurface> s = params.make(context, &backend);
if (!s) { if (!s) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -607,7 +601,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
if (!canvas) { if (!canvas) {
s = nullptr; s = nullptr;
params.cleanUpBackEnd(context, backend); params.cleanUpBackEnd(context, backend);
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -615,7 +609,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
if (!deferredContext) { if (!deferredContext) {
s = nullptr; s = nullptr;
params.cleanUpBackEnd(context, backend); params.cleanUpBackEnd(context, backend);
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -631,7 +625,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
TextureReleaseChecker::Release, &releaseChecker); TextureReleaseChecker::Release, &releaseChecker);
REPORTER_ASSERT(reporter, !image); REPORTER_ASSERT(reporter, !image);
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
s = nullptr; s = nullptr;
params.cleanUpBackEnd(context, backend); params.cleanUpBackEnd(context, backend);

View File

@ -30,8 +30,7 @@ static void cleanup(GLTestContext* glctx0, GrGLuint texID0, GLTestContext* glctx
glctx1->makeCurrent(); glctx1->makeCurrent();
if (grctx1) { if (grctx1) {
if (backendTex1 && backendTex1->isValid()) { if (backendTex1 && backendTex1->isValid()) {
GrGLGpu* gpu1 = static_cast<GrGLGpu*>(grctx1->priv().getGpu()); grctx1->priv().deleteBackendTexture(*backendTex1);
gpu1->deleteTestingOnlyBackendTexture(*backendTex1);
} }
} }
if (GR_EGL_NO_IMAGE != image1) { if (GR_EGL_NO_IMAGE != image1) {
@ -88,7 +87,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
GrGpu* gpu1 = context1->priv().getGpu(); GrGpu* gpu1 = context1->priv().getGpu();
static const int kSize = 100; static const int kSize = 100;
backendTexture1 = backendTexture1 =
gpu1->createTestingOnlyBackendTexture(kSize, kSize, kRGBA_8888_SkColorType, context1->priv().createBackendTexture(kSize, kSize, kRGBA_8888_SkColorType,
GrMipMapped::kNo, GrRenderable::kNo); GrMipMapped::kNo, GrRenderable::kNo);
if (!backendTexture1.isValid() || !gpu1->isTestingOnlyBackendTexture(backendTexture1)) { if (!backendTexture1.isValid() || !gpu1->isTestingOnlyBackendTexture(backendTexture1)) {

View File

@ -34,14 +34,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
if (!context->priv().caps()->mipMapSupport()) { if (!context->priv().caps()->mipMapSupport()) {
return; return;
} }
GrGpu* gpu = context->priv().getGpu();
for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) { for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
// CreateTestingOnlyBackendTexture currently doesn't support uploading data to mip maps // createBackendTexture currently doesn't support uploading data to mip maps
// so we don't send any. However, we pretend there is data for the checks below which is // so we don't send any. However, we pretend there is data for the checks below which is
// fine since we are never actually using these textures for any work on the gpu. // fine since we are never actually using these textures for any work on the gpu.
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType, mipMapped, renderable); kSize, kSize, kRGBA_8888_SkColorType, mipMapped, renderable);
sk_sp<GrTextureProxy> proxy; sk_sp<GrTextureProxy> proxy;
@ -68,7 +67,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
} }
REPORTER_ASSERT(reporter, proxy); REPORTER_ASSERT(reporter, proxy);
if (!proxy) { if (!proxy) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -77,7 +76,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
GrTexture* texture = proxy->peekTexture(); GrTexture* texture = proxy->peekTexture();
REPORTER_ASSERT(reporter, texture); REPORTER_ASSERT(reporter, texture);
if (!texture) { if (!texture) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -91,7 +90,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrWrappedMipMappedTest, reporter, ctxInfo) {
} else { } else {
REPORTER_ASSERT(reporter, GrMipMapped::kNo == texture->texturePriv().mipMapped()); REPORTER_ASSERT(reporter, GrMipMapped::kNo == texture->texturePriv().mipMapped());
} }
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
} }
@ -103,11 +102,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
if (!context->priv().caps()->mipMapSupport()) { if (!context->priv().caps()->mipMapSupport()) {
return; return;
} }
GrGpu* gpu = context->priv().getGpu();
for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) { for (auto mipMapped : {GrMipMapped::kNo, GrMipMapped::kYes}) {
for (auto willUseMips : {false, true}) { for (auto willUseMips : {false, true}) {
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType, mipMapped, GrRenderable::kNo); kSize, kSize, kRGBA_8888_SkColorType, mipMapped, GrRenderable::kNo);
sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex, sk_sp<SkImage> image = SkImage::MakeFromTexture(context, backendTex,
@ -119,7 +117,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
GrTextureProxy* proxy = as_IB(image)->peekProxy(); GrTextureProxy* proxy = as_IB(image)->peekProxy();
REPORTER_ASSERT(reporter, proxy); REPORTER_ASSERT(reporter, proxy);
if (!proxy) { if (!proxy) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -128,7 +126,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
sk_sp<GrTexture> texture = sk_ref_sp(proxy->peekTexture()); sk_sp<GrTexture> texture = sk_ref_sp(proxy->peekTexture());
REPORTER_ASSERT(reporter, texture); REPORTER_ASSERT(reporter, texture);
if (!texture) { if (!texture) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -137,7 +135,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
kPremul_SkAlphaType, nullptr); kPremul_SkAlphaType, nullptr);
REPORTER_ASSERT(reporter, imageGen); REPORTER_ASSERT(reporter, imageGen);
if (!imageGen) { if (!imageGen) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -149,7 +147,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
REPORTER_ASSERT(reporter, genProxy); REPORTER_ASSERT(reporter, genProxy);
if (!genProxy) { if (!genProxy) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -161,14 +159,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
REPORTER_ASSERT(reporter, genProxy->isInstantiated()); REPORTER_ASSERT(reporter, genProxy->isInstantiated());
if (!genProxy->isInstantiated()) { if (!genProxy->isInstantiated()) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
GrTexture* genTexture = genProxy->peekTexture(); GrTexture* genTexture = genProxy->peekTexture();
REPORTER_ASSERT(reporter, genTexture); REPORTER_ASSERT(reporter, genTexture);
if (!genTexture) { if (!genTexture) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return; return;
} }
@ -227,9 +225,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrBackendTextureImageMipMappedTest, reporter,
// Must make sure the uses of the backend texture have finished (we possibly have a // Must make sure the uses of the backend texture have finished (we possibly have a
// queued up copy) before we delete the backend texture. // queued up copy) before we delete the backend texture.
context->flush(); context->flush();
gpu->testingOnly_flushGpuAndSync();
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().getGpu()->testingOnly_flushGpuAndSync();
context->priv().deleteBackendTexture(backendTex);
} }
} }
} }
@ -243,13 +242,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
} }
auto resourceProvider = context->priv().resourceProvider(); auto resourceProvider = context->priv().resourceProvider();
GrGpu* gpu = context->priv().getGpu();
for (auto willUseMips : {false, true}) { for (auto willUseMips : {false, true}) {
for (auto isWrapped : {false, true}) { for (auto isWrapped : {false, true}) {
GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo; GrMipMapped mipMapped = willUseMips ? GrMipMapped::kYes : GrMipMapped::kNo;
sk_sp<SkSurface> surface; sk_sp<SkSurface> surface;
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType, mipMapped, GrRenderable::kYes); kSize, kSize, kRGBA_8888_SkColorType, mipMapped, GrRenderable::kYes);
if (isWrapped) { if (isWrapped) {
surface = SkSurface::MakeFromBackendTexture(context, surface = SkSurface::MakeFromBackendTexture(context,
@ -268,7 +266,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
} }
REPORTER_ASSERT(reporter, surface); REPORTER_ASSERT(reporter, surface);
if (!surface) { if (!surface) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice(); SkGpuDevice* device = ((SkSurface_Gpu*)surface.get())->getDevice();
GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy(); GrTextureProxy* texProxy = device->accessRenderTargetContext()->asTextureProxy();
@ -281,7 +279,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
sk_sp<SkImage> image = surface->makeImageSnapshot(); sk_sp<SkImage> image = surface->makeImageSnapshot();
REPORTER_ASSERT(reporter, image); REPORTER_ASSERT(reporter, image);
if (!image) { if (!image) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
texProxy = as_IB(image)->peekProxy(); texProxy = as_IB(image)->peekProxy();
REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped()); REPORTER_ASSERT(reporter, mipMapped == texProxy->mipMapped());
@ -293,8 +291,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrImageSnapshotMipMappedTest, reporter, ctxIn
// Must flush the context to make sure all the cmds (copies, etc.) from above are sent // Must flush the context to make sure all the cmds (copies, etc.) from above are sent
// to the gpu before we delete the backendHandle. // to the gpu before we delete the backendHandle.
context->flush(); context->flush();
gpu->testingOnly_flushGpuAndSync(); context->priv().getGpu()->testingOnly_flushGpuAndSync();
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
} }

View File

@ -989,7 +989,6 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
return; return;
} }
GrGpu* gpu = ctx->priv().getGpu();
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider(); GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
const GrCaps& caps = *ctx->priv().caps(); const GrCaps& caps = *ctx->priv().caps();
if (caps.shaderCaps()->dualSourceBlendingSupport()) { if (caps.shaderCaps()->dualSourceBlendingSupport()) {
@ -998,8 +997,8 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
} }
GrBackendTexture backendTex = GrBackendTexture backendTex =
gpu->createTestingOnlyBackendTexture(100, 100, kRGBA_8888_SkColorType, ctx->priv().createBackendTexture(100, 100, kRGBA_8888_SkColorType,
GrMipMapped::kNo, GrRenderable::kNo); GrMipMapped::kNo, GrRenderable::kNo);
GrXferProcessor::DstProxy fakeDstProxy; GrXferProcessor::DstProxy fakeDstProxy;
{ {
@ -1031,5 +1030,5 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
} }
} }
} }
gpu->deleteTestingOnlyBackendTexture(backendTex); ctx->priv().deleteBackendTexture(backendTex);
} }

View File

@ -26,7 +26,6 @@
DEF_GPUTEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo) { DEF_GPUTEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext(); GrContext* context = ctxInfo.grContext();
auto resourceProvider = context->priv().resourceProvider(); auto resourceProvider = context->priv().resourceProvider();
GrGpu* gpu = context->priv().getGpu();
GrSurfaceDesc desc; GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag; desc.fFlags = kRenderTarget_GrSurfaceFlag;
@ -53,7 +52,7 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture()); REPORTER_ASSERT(reporter, tex1.get() == tex1->asTexture());
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture()); REPORTER_ASSERT(reporter, static_cast<GrSurface*>(tex1.get()) == tex1->asTexture());
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
256, 256, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); 256, 256, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
sk_sp<GrSurface> texRT2 = resourceProvider->wrapRenderableBackendTexture( sk_sp<GrSurface> texRT2 = resourceProvider->wrapRenderableBackendTexture(
@ -68,7 +67,7 @@ DEF_GPUTEST_FOR_MOCK_CONTEXT(GrSurface, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) == REPORTER_ASSERT(reporter, static_cast<GrSurface*>(texRT2->asRenderTarget()) ==
static_cast<GrSurface*>(texRT2->asTexture())); static_cast<GrSurface*>(texRT2->asTexture()));
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
// This test checks that the isConfigTexturable and isConfigRenderable are // This test checks that the isConfigTexturable and isConfigRenderable are
@ -330,7 +329,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
// Mip regen should not work with a read only texture. // Mip regen should not work with a read only texture.
if (context->priv().caps()->mipMapSupport()) { if (context->priv().caps()->mipMapSupport()) {
backendTex = context->priv().getGpu()->createTestingOnlyBackendTexture( backendTex = context->priv().createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType, GrMipMapped::kYes, GrRenderable::kYes); kSize, kSize, kRGBA_8888_SkColorType, GrMipMapped::kYes, GrRenderable::kYes);
proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin, proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
@ -345,7 +344,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadOnlyTexture, reporter, context_info) {
} }
static sk_sp<GrTexture> make_wrapped_texture(GrContext* context, GrRenderable renderable) { static sk_sp<GrTexture> make_wrapped_texture(GrContext* context, GrRenderable renderable) {
auto backendTexture = context->priv().getGpu()->createTestingOnlyBackendTexture( auto backendTexture = context->priv().createBackendTexture(
10, 10, kRGBA_8888_SkColorType, GrMipMapped::kNo, renderable); 10, 10, kRGBA_8888_SkColorType, GrMipMapped::kNo, renderable);
sk_sp<GrTexture> texture; sk_sp<GrTexture> texture;
if (GrRenderable::kYes == renderable) { if (GrRenderable::kYes == renderable) {
@ -362,11 +361,8 @@ static sk_sp<GrTexture> make_wrapped_texture(GrContext* context, GrRenderable re
}; };
auto release = [](void* rc) { auto release = [](void* rc) {
auto releaseContext = static_cast<ReleaseContext*>(rc); auto releaseContext = static_cast<ReleaseContext*>(rc);
if (!releaseContext->fContext->abandoned()) { auto context = releaseContext->fContext;
if (auto gpu = releaseContext->fContext->priv().getGpu()) { context->priv().deleteBackendTexture(releaseContext->fBackendTexture);
gpu->deleteTestingOnlyBackendTexture(releaseContext->fBackendTexture);
}
}
delete releaseContext; delete releaseContext;
}; };
texture->setRelease(release, new ReleaseContext{context, backendTexture}); texture->setRelease(release, new ReleaseContext{context, backendTexture});

View File

@ -27,10 +27,11 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
} }
SkAutoTMalloc<GrColor> dstBuffer(kWidth * kHeight); SkAutoTMalloc<GrColor> dstBuffer(kWidth * kHeight);
const GrCaps* caps = context->priv().caps();
GrGpu* gpu = context->priv().getGpu(); GrGpu* gpu = context->priv().getGpu();
GrPixelConfig config = SkColorType2GrPixelConfig(ct); GrPixelConfig config = SkColorType2GrPixelConfig(ct);
if (!gpu->caps()->isConfigTexturable(config)) { if (!caps->isConfigTexturable(config)) {
return; return;
} }
@ -39,7 +40,7 @@ void testing_only_texture_test(skiatest::Reporter* reporter, GrContext* context,
return; return;
} }
if (gpu->caps()->supportedReadPixelsColorType(config, grCT) != grCT) { if (caps->supportedReadPixelsColorType(config, grCT) != grCT) {
return; return;
} }

View File

@ -482,25 +482,26 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeNonTextureImage, reporter, contex
} }
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsImage, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
static constexpr int kSize = 10;
for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) { for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) {
static constexpr int kSize = 10;
SkColorType colorType = static_cast<SkColorType>(ct); SkColorType colorType = static_cast<SkColorType>(ct);
bool can = ctxInfo.grContext()->colorTypeSupportedAsImage(colorType); bool can = context->colorTypeSupportedAsImage(colorType);
auto* gpu = ctxInfo.grContext()->priv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
kSize, kSize, colorType, GrMipMapped::kNo, GrRenderable::kNo); kSize, kSize, colorType, GrMipMapped::kNo, GrRenderable::kNo);
auto img =
SkImage::MakeFromTexture(ctxInfo.grContext(), backendTex, kTopLeft_GrSurfaceOrigin, auto img = SkImage::MakeFromTexture(context, backendTex, kTopLeft_GrSurfaceOrigin,
colorType, kOpaque_SkAlphaType, nullptr); colorType, kOpaque_SkAlphaType, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(img), REPORTER_ASSERT(reporter, can == SkToBool(img),
"colorTypeSupportedAsImage:%d, actual:%d, ct:%d", can, SkToBool(img), "colorTypeSupportedAsImage:%d, actual:%d, ct:%d", can, SkToBool(img),
colorType); colorType);
img.reset(); img.reset();
ctxInfo.grContext()->flush(); context->flush();
if (backendTex.isValid()) { context->priv().deleteBackendTexture(backendTex);
gpu->deleteTestingOnlyBackendTexture(backendTex);
}
} }
} }

View File

@ -448,7 +448,6 @@ DEF_GPUTEST(LazyProxyDeinstantiateTest, reporter, /* options */) {
GrMockOptions mockOptions; GrMockOptions mockOptions;
sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions()); sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider(); GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
GrGpu* gpu = ctx->priv().getGpu();
GrBackendFormat format = GrBackendFormat format =
ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType); ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
@ -472,7 +471,7 @@ DEF_GPUTEST(LazyProxyDeinstantiateTest, reporter, /* options */) {
desc.fHeight = kSize; desc.fHeight = kSize;
desc.fConfig = kRGBA_8888_GrPixelConfig; desc.fConfig = kRGBA_8888_GrPixelConfig;
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = ctx->priv().createBackendTexture(
kSize, kSize, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); kSize, kSize, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
sk_sp<GrTextureProxy> lazyProxy = proxyProvider->createLazyProxy( sk_sp<GrTextureProxy> lazyProxy = proxyProvider->createLazyProxy(
@ -526,6 +525,6 @@ DEF_GPUTEST(LazyProxyDeinstantiateTest, reporter, /* options */) {
REPORTER_ASSERT(reporter, 1 == releaseTestValue); REPORTER_ASSERT(reporter, 1 == releaseTestValue);
} }
gpu->deleteTestingOnlyBackendTexture(backendTex); ctx->priv().deleteBackendTexture(backendTex);
} }
} }

View File

@ -167,7 +167,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo) {
GrContext* ctx = ctxInfo.grContext(); GrContext* ctx = ctxInfo.grContext();
GrGpu* gpu = ctx->priv().getGpu(); GrGpu* gpu = ctx->priv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = ctx->priv().createBackendTexture(
kWidth, kHeight, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes); kWidth, kHeight, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes);
REPORTER_ASSERT(reporter, backendTex.isValid()); REPORTER_ASSERT(reporter, backendTex.isValid());
@ -228,7 +228,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTest, reporter, ctxInfo) {
// Now Done should definitely have been called. // Now Done should definitely have been called.
check_all_done(reporter, promiseChecker); check_all_done(reporter, promiseChecker);
gpu->deleteTestingOnlyBackendTexture(backendTex); ctx->priv().deleteBackendTexture(backendTex);
} }
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureReuseDifferentConfig, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureReuseDifferentConfig, reporter, ctxInfo) {
@ -242,19 +242,19 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureReuseDifferentConfig, repo
GrContext* ctx = ctxInfo.grContext(); GrContext* ctx = ctxInfo.grContext();
GrGpu* gpu = ctx->priv().getGpu(); GrGpu* gpu = ctx->priv().getGpu();
GrBackendTexture backendTex1 = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex1 = ctx->priv().createBackendTexture(
kWidth, kHeight, kGray_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); kWidth, kHeight, kGray_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
REPORTER_ASSERT(reporter, backendTex1.isValid()); REPORTER_ASSERT(reporter, backendTex1.isValid());
GrBackendTexture backendTex2 = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex2 = ctx->priv().createBackendTexture(
kWidth, kHeight, kAlpha_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); kWidth, kHeight, kAlpha_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
REPORTER_ASSERT(reporter, backendTex2.isValid()); REPORTER_ASSERT(reporter, backendTex2.isValid());
if (backendTex1.getBackendFormat() != backendTex2.getBackendFormat()) { if (backendTex1.getBackendFormat() != backendTex2.getBackendFormat()) {
gpu->deleteTestingOnlyBackendTexture(backendTex1); ctx->priv().deleteBackendTexture(backendTex1);
return; return;
} }
// We only needed this texture to check that alpha and gray color types use the same format. // We only needed this texture to check that alpha and gray color types use the same format.
gpu->deleteTestingOnlyBackendTexture(backendTex2); ctx->priv().deleteBackendTexture(backendTex2);
SkImageInfo info = SkImageInfo info =
SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType); SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
@ -316,7 +316,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureReuseDifferentConfig, repo
grayImg.reset(); grayImg.reset();
ctx->flush(); // We do this to pick up any unref messages that are sent by unref'ing the image. ctx->flush(); // We do this to pick up any unref messages that are sent by unref'ing the image.
check_all_done(reporter, promiseChecker, 2); check_all_done(reporter, promiseChecker, 2);
gpu->deleteTestingOnlyBackendTexture(backendTex1); ctx->priv().deleteBackendTexture(backendTex1);
} }
DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) { DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) {
@ -351,9 +351,8 @@ DEF_GPUTEST(PromiseImageTextureShutdown, reporter, ctxInfo) {
if (!ctx) { if (!ctx) {
continue; continue;
} }
GrGpu* gpu = ctx->priv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = ctx->priv().createBackendTexture(
kWidth, kHeight, kAlpha_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); kWidth, kHeight, kAlpha_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
REPORTER_ASSERT(reporter, backendTex.isValid()); REPORTER_ASSERT(reporter, backendTex.isValid());
@ -390,9 +389,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
const int kHeight = 10; const int kHeight = 10;
GrContext* ctx = ctxInfo.grContext(); GrContext* ctx = ctxInfo.grContext();
GrGpu* gpu = ctx->priv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = ctx->priv().createBackendTexture(
kWidth, kHeight, kAlpha_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); kWidth, kHeight, kAlpha_8_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
REPORTER_ASSERT(reporter, backendTex.isValid()); REPORTER_ASSERT(reporter, backendTex.isValid());
@ -442,9 +440,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageTextureFullCache, reporter, ctxIn
// Must call these to ensure that all callbacks are performed before the checker is destroyed. // Must call these to ensure that all callbacks are performed before the checker is destroyed.
image.reset(); image.reset();
ctx->flush(); ctx->flush();
gpu->testingOnly_flushGpuAndSync(); ctx->priv().getGpu()->testingOnly_flushGpuAndSync();
gpu->deleteTestingOnlyBackendTexture(backendTex); ctx->priv().deleteBackendTexture(backendTex);
} }
// Test case where promise image fulfill returns nullptr. // Test case where promise image fulfill returns nullptr.
@ -453,15 +451,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(PromiseImageNullFulfill, reporter, ctxInfo) {
const int kHeight = 10; const int kHeight = 10;
GrContext* ctx = ctxInfo.grContext(); GrContext* ctx = ctxInfo.grContext();
GrGpu* gpu = ctx->priv().getGpu();
// Do all this just to get a valid backend format for the image. // Do all this just to get a valid backend format for the image.
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = ctx->priv().createBackendTexture(
kWidth, kHeight, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes); kWidth, kHeight, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes);
REPORTER_ASSERT(reporter, backendTex.isValid()); REPORTER_ASSERT(reporter, backendTex.isValid());
GrBackendFormat backendFormat = backendTex.getBackendFormat(); GrBackendFormat backendFormat = backendTex.getBackendFormat();
REPORTER_ASSERT(reporter, backendFormat.isValid()); REPORTER_ASSERT(reporter, backendFormat.isValid());
gpu->deleteTestingOnlyBackendTexture(backendTex); ctx->priv().deleteBackendTexture(backendTex);
struct Counts { struct Counts {
int fFulfillCount = 0; int fFulfillCount = 0;

View File

@ -213,9 +213,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DeferredProxyTest, reporter, ctxInfo) {
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
GrProxyProvider* proxyProvider = ctxInfo.grContext()->priv().proxyProvider(); GrProxyProvider* proxyProvider = ctxInfo.grContext()->priv().proxyProvider();
GrResourceProvider* resourceProvider = ctxInfo.grContext()->priv().resourceProvider(); GrContext* context = ctxInfo.grContext();
GrGpu* gpu = ctxInfo.grContext()->priv().getGpu(); GrResourceProvider* resourceProvider = context->priv().resourceProvider();
const GrCaps& caps = *ctxInfo.grContext()->priv().caps(); GrGpu* gpu = context->priv().getGpu();
const GrCaps& caps = *context->priv().caps();
static const int kWidthHeight = 100; static const int kWidthHeight = 100;
@ -274,14 +275,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
// Tests wrapBackendRenderTarget with a GrBackendTexture // Tests wrapBackendRenderTarget with a GrBackendTexture
{ {
GrBackendTexture backendTex = GrBackendTexture backendTex =
gpu->createTestingOnlyBackendTexture(kWidthHeight, kWidthHeight, context->priv().createBackendTexture(kWidthHeight, kWidthHeight,
colorType, colorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kYes); GrRenderable::kYes);
sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget( sk_sp<GrSurfaceProxy> sProxy = proxyProvider->wrapBackendTextureAsRenderTarget(
backendTex, origin, supportedNumSamples); backendTex, origin, supportedNumSamples);
if (!sProxy) { if (!sProxy) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
continue; // This can fail on Mesa continue; // This can fail on Mesa
} }
@ -293,13 +294,13 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
supportedNumSamples, SkBackingFit::kExact, supportedNumSamples, SkBackingFit::kExact,
caps.maxWindowRectangles()); caps.maxWindowRectangles());
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
// Tests wrapBackendTexture that is only renderable // Tests wrapBackendTexture that is only renderable
{ {
GrBackendTexture backendTex = GrBackendTexture backendTex =
gpu->createTestingOnlyBackendTexture(kWidthHeight, kWidthHeight, context->priv().createBackendTexture(kWidthHeight, kWidthHeight,
colorType, colorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kYes); GrRenderable::kYes);
@ -308,7 +309,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
backendTex, origin, supportedNumSamples, kBorrow_GrWrapOwnership, backendTex, origin, supportedNumSamples, kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, nullptr, nullptr); GrWrapCacheable::kNo, nullptr, nullptr);
if (!sProxy) { if (!sProxy) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
continue; // This can fail on Mesa continue; // This can fail on Mesa
} }
@ -320,14 +321,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
supportedNumSamples, SkBackingFit::kExact, supportedNumSamples, SkBackingFit::kExact,
caps.maxWindowRectangles()); caps.maxWindowRectangles());
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
// Tests wrapBackendTexture that is only textureable // Tests wrapBackendTexture that is only textureable
{ {
// Internal offscreen texture // Internal offscreen texture
GrBackendTexture backendTex = GrBackendTexture backendTex =
gpu->createTestingOnlyBackendTexture(kWidthHeight, kWidthHeight, context->priv().createBackendTexture(kWidthHeight, kWidthHeight,
colorType, colorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kNo); GrRenderable::kNo);
@ -336,7 +337,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
backendTex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, backendTex, origin, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo,
kRead_GrIOType); kRead_GrIOType);
if (!sProxy) { if (!sProxy) {
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
continue; continue;
} }
@ -346,7 +347,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WrappedProxyTest, reporter, ctxInfo) {
check_texture(reporter, resourceProvider, sProxy->asTextureProxy(), check_texture(reporter, resourceProvider, sProxy->asTextureProxy(),
SkBackingFit::kExact); SkBackingFit::kExact);
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
} }

View File

@ -61,9 +61,8 @@ static GrSurfaceProxy* make_deferred(GrProxyProvider* proxyProvider, const GrCap
static GrSurfaceProxy* make_backend(GrContext* context, const ProxyParams& p, static GrSurfaceProxy* make_backend(GrContext* context, const ProxyParams& p,
GrBackendTexture* backendTex) { GrBackendTexture* backendTex) {
GrProxyProvider* proxyProvider = context->priv().proxyProvider(); GrProxyProvider* proxyProvider = context->priv().proxyProvider();
GrGpu* gpu = context->priv().getGpu();
*backendTex = gpu->createTestingOnlyBackendTexture(p.fSize, p.fSize, p.fColorType, *backendTex = context->priv().createBackendTexture(p.fSize, p.fSize, p.fColorType,
GrMipMapped::kNo, GrRenderable::kNo); GrMipMapped::kNo, GrRenderable::kNo);
if (!backendTex->isValid()) { if (!backendTex->isValid()) {
return nullptr; return nullptr;
@ -83,7 +82,7 @@ static GrSurfaceProxy* make_backend(GrContext* context, const ProxyParams& p,
} }
static void cleanup_backend(GrContext* context, const GrBackendTexture& backendTex) { static void cleanup_backend(GrContext* context, const GrBackendTexture& backendTex) {
context->priv().getGpu()->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
// Basic test that two proxies with overlapping intervals and compatible descriptors are // Basic test that two proxies with overlapping intervals and compatible descriptors are

View File

@ -209,9 +209,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
static const int kW = 100; static const int kW = 100;
static const int kH = 100; static const int kH = 100;
backendTextures[0] = gpu->createTestingOnlyBackendTexture(kW, kH, kRGBA_8888_SkColorType, backendTextures[0] = context->priv().createBackendTexture(kW, kH, kRGBA_8888_SkColorType,
GrMipMapped::kNo, GrRenderable::kNo); GrMipMapped::kNo, GrRenderable::kNo);
backendTextures[1] = gpu->createTestingOnlyBackendTexture(kW, kH, kRGBA_8888_SkColorType, backendTextures[1] = context->priv().createBackendTexture(kW, kH, kRGBA_8888_SkColorType,
GrMipMapped::kNo, GrRenderable::kNo); GrMipMapped::kNo, GrRenderable::kNo);
REPORTER_ASSERT(reporter, backendTextures[0].isValid()); REPORTER_ASSERT(reporter, backendTextures[0].isValid());
REPORTER_ASSERT(reporter, backendTextures[1].isValid()); REPORTER_ASSERT(reporter, backendTextures[1].isValid());
@ -244,10 +244,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ResourceCacheWrappedResources, reporter, ctxI
REPORTER_ASSERT(reporter, !adoptedIsAlive); REPORTER_ASSERT(reporter, !adoptedIsAlive);
if (borrowedIsAlive) { if (borrowedIsAlive) {
gpu->deleteTestingOnlyBackendTexture(backendTextures[0]); context->priv().deleteBackendTexture(backendTextures[0]);
} }
if (adoptedIsAlive) { if (adoptedIsAlive) {
gpu->deleteTestingOnlyBackendTexture(backendTextures[1]); context->priv().deleteBackendTexture(backendTextures[1]);
} }
context->resetContext(); context->resetContext();

View File

@ -89,49 +89,46 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceEmpty_Gpu, reporter, ctxInfo) {
} }
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) { for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) {
static constexpr int kSize = 10; static constexpr int kSize = 10;
SkColorType colorType = static_cast<SkColorType>(ct); SkColorType colorType = static_cast<SkColorType>(ct);
auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr); auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr);
bool can = ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType); bool can = context->colorTypeSupportedAsSurface(colorType);
auto surf = SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kYes, info, 1, auto surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, 1, nullptr);
nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf)); colorType, can, SkToBool(surf));
auto* gpu = ctxInfo.grContext()->priv().getGpu(); GrBackendTexture backendTex = context->priv().createBackendTexture(
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
kSize, kSize, colorType, GrMipMapped::kNo, GrRenderable::kYes); kSize, kSize, colorType, GrMipMapped::kNo, GrRenderable::kYes);
surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, surf = SkSurface::MakeFromBackendTexture(context, backendTex,
kTopLeft_GrSurfaceOrigin, 0, colorType, nullptr, kTopLeft_GrSurfaceOrigin, 0, colorType, nullptr,
nullptr); nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf)); colorType, can, SkToBool(surf));
surf = SkSurface::MakeFromBackendTextureAsRenderTarget(ctxInfo.grContext(), backendTex, surf = SkSurface::MakeFromBackendTextureAsRenderTarget(context, backendTex,
kTopLeft_GrSurfaceOrigin, 1, kTopLeft_GrSurfaceOrigin, 1,
colorType, nullptr, nullptr); colorType, nullptr, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf)); colorType, can, SkToBool(surf));
surf.reset(); surf.reset();
ctxInfo.grContext()->flush(); context->flush();
if (backendTex.isValid()) { context->priv().deleteBackendTexture(backendTex);
gpu->deleteTestingOnlyBackendTexture(backendTex);
}
static constexpr int kSampleCnt = 2; static constexpr int kSampleCnt = 2;
can = ctxInfo.grContext()->maxSurfaceSampleCountForColorType(colorType) >= kSampleCnt; can = context->maxSurfaceSampleCountForColorType(colorType) >= kSampleCnt;
surf = SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kYes, info, kSampleCnt, surf = SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info, kSampleCnt, nullptr);
nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d",
colorType, can, SkToBool(surf)); colorType, can, SkToBool(surf));
backendTex = gpu->createTestingOnlyBackendTexture(kSize, kSize, colorType, backendTex = context->priv().createBackendTexture(kSize, kSize, colorType,
GrMipMapped::kNo, GrRenderable::kYes); GrMipMapped::kNo, GrRenderable::kYes);
surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, surf = SkSurface::MakeFromBackendTexture(context, backendTex,
kTopLeft_GrSurfaceOrigin, kSampleCnt, colorType, kTopLeft_GrSurfaceOrigin, kSampleCnt, colorType,
nullptr, nullptr); nullptr, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), REPORTER_ASSERT(reporter, can == SkToBool(surf),
@ -141,14 +138,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
if (surf) { if (surf) {
auto* rtc = ((SkSurface_Gpu*)(surf.get()))->getDevice()->accessRenderTargetContext(); auto* rtc = ((SkSurface_Gpu*)(surf.get()))->getDevice()->accessRenderTargetContext();
int storedCnt = rtc->numStencilSamples(); int storedCnt = rtc->numStencilSamples();
int allowedCnt = ctxInfo.grContext()->priv().caps()->getSampleCount( int allowedCnt = context->priv().caps()->getSampleCount(
storedCnt, rtc->asSurfaceProxy()->config()); storedCnt, rtc->asSurfaceProxy()->config());
REPORTER_ASSERT(reporter, storedCnt == allowedCnt, REPORTER_ASSERT(reporter, storedCnt == allowedCnt,
"Should store an allowed sample count (%d vs %d)", allowedCnt, "Should store an allowed sample count (%d vs %d)", allowedCnt,
storedCnt); storedCnt);
} }
surf = SkSurface::MakeFromBackendTextureAsRenderTarget(ctxInfo.grContext(), backendTex, surf = SkSurface::MakeFromBackendTextureAsRenderTarget(context, backendTex,
kTopLeft_GrSurfaceOrigin, kSampleCnt, kTopLeft_GrSurfaceOrigin, kSampleCnt,
colorType, nullptr, nullptr); colorType, nullptr, nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), REPORTER_ASSERT(reporter, can == SkToBool(surf),
@ -157,7 +154,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
if (surf) { if (surf) {
auto* rtc = ((SkSurface_Gpu*)(surf.get()))->getDevice()->accessRenderTargetContext(); auto* rtc = ((SkSurface_Gpu*)(surf.get()))->getDevice()->accessRenderTargetContext();
int storedCnt = rtc->numStencilSamples(); int storedCnt = rtc->numStencilSamples();
int allowedCnt = ctxInfo.grContext()->priv().caps()->getSampleCount( int allowedCnt = context->priv().caps()->getSampleCount(
storedCnt, rtc->asSurfaceProxy()->config()); storedCnt, rtc->asSurfaceProxy()->config());
REPORTER_ASSERT(reporter, storedCnt == allowedCnt, REPORTER_ASSERT(reporter, storedCnt == allowedCnt,
"Should store an allowed sample count (%d vs %d)", allowedCnt, "Should store an allowed sample count (%d vs %d)", allowedCnt,
@ -165,21 +162,21 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
} }
surf.reset(); surf.reset();
ctxInfo.grContext()->flush(); context->flush();
if (backendTex.isValid()) { context->priv().deleteBackendTexture(backendTex);
gpu->deleteTestingOnlyBackendTexture(backendTex);
} auto* gpu = context->priv().getGpu();
GrBackendRenderTarget backendRenderTarget = gpu->createTestingOnlyBackendRenderTarget( GrBackendRenderTarget backendRenderTarget = gpu->createTestingOnlyBackendRenderTarget(
16, 16, SkColorTypeToGrColorType(colorType)); 16, 16, SkColorTypeToGrColorType(colorType));
can = ctxInfo.grContext()->colorTypeSupportedAsSurface(colorType); can = context->colorTypeSupportedAsSurface(colorType);
surf = SkSurface::MakeFromBackendRenderTarget(ctxInfo.grContext(), backendRenderTarget, surf = SkSurface::MakeFromBackendRenderTarget(context, backendRenderTarget,
kTopLeft_GrSurfaceOrigin, colorType, nullptr, kTopLeft_GrSurfaceOrigin, colorType, nullptr,
nullptr); nullptr);
REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", colorType, REPORTER_ASSERT(reporter, can == SkToBool(surf), "ct: %d, can: %d, surf: %d", colorType,
can, SkToBool(surf)); can, SkToBool(surf));
surf.reset(); surf.reset();
ctxInfo.grContext()->flush(); context->flush();
if (backendRenderTarget.isValid()) { if (backendRenderTarget.isValid()) {
gpu->deleteTestingOnlyBackendRenderTarget(backendRenderTarget); gpu->deleteTestingOnlyBackendRenderTarget(backendRenderTarget);
} }
@ -187,23 +184,27 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_colorTypeSupportedAsSurface, report
} }
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrContext_maxSurfaceSamplesForColorType, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
static constexpr int kSize = 10;
for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) { for (int ct = 0; ct < kLastEnum_SkColorType; ++ct) {
static constexpr int kSize = 10;
SkColorType colorType = static_cast<SkColorType>(ct); SkColorType colorType = static_cast<SkColorType>(ct);
int max = ctxInfo.grContext()->maxSurfaceSampleCountForColorType(colorType); int max = context->maxSurfaceSampleCountForColorType(colorType);
if (!max) { if (!max) {
continue; continue;
} }
auto* gpu = ctxInfo.grContext()->priv().getGpu(); GrBackendTexture backendTex = context->priv().createBackendTexture(
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(
kSize, kSize, colorType, GrMipMapped::kNo, GrRenderable::kYes); kSize, kSize, colorType, GrMipMapped::kNo, GrRenderable::kYes);
if (!backendTex.isValid()) { if (!backendTex.isValid()) {
continue; continue;
} }
SkScopeExit freeTex([&backendTex, gpu] {gpu->deleteTestingOnlyBackendTexture(backendTex);}); SkScopeExit freeTex([&backendTex, context] {
context->priv().deleteBackendTexture(backendTex);
});
auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr); auto info = SkImageInfo::Make(kSize, kSize, colorType, kOpaque_SkAlphaType, nullptr);
auto surf = SkSurface::MakeFromBackendTexture(ctxInfo.grContext(), backendTex, auto surf = SkSurface::MakeFromBackendTexture(context, backendTex,
kTopLeft_GrSurfaceOrigin, max, kTopLeft_GrSurfaceOrigin, max,
colorType, nullptr, nullptr); colorType, nullptr, nullptr);
REPORTER_ASSERT(reporter, surf); REPORTER_ASSERT(reporter, surf);
@ -765,7 +766,6 @@ static void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> su
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) { DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext(); GrContext* context = ctxInfo.grContext();
GrGpu* gpu = context->priv().getGpu();
std::function<sk_sp<GrSurfaceContext>(SkSurface*)> grSurfaceContextGetters[] = { std::function<sk_sp<GrSurfaceContext>(SkSurface*)> grSurfaceContextGetters[] = {
[] (SkSurface* s){ [] (SkSurface* s){
@ -794,7 +794,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
auto surface = surfaceFunc(context, 1, kOrigColor, &backendTex); auto surface = surfaceFunc(context, 1, kOrigColor, &backendTex);
test_surface_clear(reporter, surface, grSurfaceGetter, kOrigColor); test_surface_clear(reporter, surface, grSurfaceGetter, kOrigColor);
surface.reset(); surface.reset();
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
} }
@ -842,10 +842,8 @@ static void test_surface_draw_partially(
} }
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacePartialDraw_Gpu, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacePartialDraw_Gpu, reporter, ctxInfo) {
GrGpu* gpu = ctxInfo.grContext()->priv().getGpu(); GrContext* context = ctxInfo.grContext();
if (!gpu) {
return;
}
static const SkColor kOrigColor = 0xFFAABBCC; static const SkColor kOrigColor = 0xFFAABBCC;
for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
@ -854,11 +852,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacePartialDraw_Gpu, reporter, ctxInfo) {
// preserved in pixels that aren't rendered to via the surface. // preserved in pixels that aren't rendered to via the surface.
// This works only for non-multisampled case. // This works only for non-multisampled case.
GrBackendTexture backendTex; GrBackendTexture backendTex;
auto surface = surfaceFunc(ctxInfo.grContext(), 1, kOrigColor, &backendTex); auto surface = surfaceFunc(context, 1, kOrigColor, &backendTex);
if (surface) { if (surface) {
test_surface_draw_partially(reporter, surface, kOrigColor); test_surface_draw_partially(reporter, surface, kOrigColor);
surface.reset(); surface.reset();
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
} }
@ -935,22 +933,22 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWrappedWithRelease_Gpu, reporter, ctxI
} }
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInfo) { DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInfo) {
GrGpu* gpu = ctxInfo.grContext()->priv().getGpu(); GrContext* context = ctxInfo.grContext();
if (!gpu) { const GrCaps* caps = context->priv().caps();
return;
} if (caps->avoidStencilBuffers()) {
if (gpu->caps()->avoidStencilBuffers()) {
return; return;
} }
static const SkColor kOrigColor = 0xFFAABBCC; static const SkColor kOrigColor = 0xFFAABBCC;
auto resourceProvider = ctxInfo.grContext()->priv().resourceProvider(); auto resourceProvider = context->priv().resourceProvider();
for (auto& surfaceFunc : {&create_gpu_surface_backend_texture, for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
&create_gpu_surface_backend_texture_as_render_target}) { &create_gpu_surface_backend_texture_as_render_target}) {
for (int sampleCnt : {1, 4, 8}) { for (int sampleCnt : {1, 4, 8}) {
GrBackendTexture backendTex; GrBackendTexture backendTex;
auto surface = surfaceFunc(ctxInfo.grContext(), sampleCnt, kOrigColor, &backendTex); auto surface = surfaceFunc(context, sampleCnt, kOrigColor, &backendTex);
if (!surface && sampleCnt > 1) { if (!surface && sampleCnt > 1) {
// Certain platforms don't support MSAA, skip these. // Certain platforms don't support MSAA, skip these.
@ -962,7 +960,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInf
GrRenderTarget* rt = surface->getCanvas() GrRenderTarget* rt = surface->getCanvas()
->internal_private_accessTopLayerRenderTargetContext()->accessRenderTarget(); ->internal_private_accessTopLayerRenderTargetContext()->accessRenderTarget();
REPORTER_ASSERT(reporter, resourceProvider->attachStencilAttachment(rt)); REPORTER_ASSERT(reporter, resourceProvider->attachStencilAttachment(rt));
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
} }

View File

@ -156,14 +156,7 @@ bool create_backend_texture(GrContext* context, GrBackendTexture* backendTex,
} }
void delete_backend_texture(GrContext* context, const GrBackendTexture& backendTex) { void delete_backend_texture(GrContext* context, const GrBackendTexture& backendTex) {
auto* gpu = context->priv().getGpu(); context->priv().deleteBackendTexture(backendTex);
if (!gpu) {
return;
}
if (backendTex.isValid()) {
gpu->deleteTestingOnlyBackendTexture(backendTex);
}
} }
bool does_full_buffer_contain_correct_color(GrColor* srcBuffer, bool does_full_buffer_contain_correct_color(GrColor* srcBuffer,

View File

@ -101,7 +101,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
context->resetContext(); context->resetContext();
if (supportExternal) { if (supportExternal) {
GrBackendTexture texture2D = gpu->createTestingOnlyBackendTexture( GrBackendTexture texture2D = context->priv().createBackendTexture(
10, 10, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); 10, 10, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
GrGLTextureInfo info2D; GrGLTextureInfo info2D;
REPORTER_ASSERT(reporter, texture2D.getGLTextureInfo(&info2D)); REPORTER_ASSERT(reporter, texture2D.getGLTextureInfo(&info2D));
@ -127,7 +127,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(TextureBindingsResetTest, reporter, ctxInf
resetBindings(); resetBindings();
GL(DeleteTextures(1, &infoExternal.fID)); GL(DeleteTextures(1, &infoExternal.fID));
ctxInfo.glContext()->destroyEGLImage(eglImage); ctxInfo.glContext()->destroyEGLImage(eglImage);
gpu->deleteTestingOnlyBackendTexture(texture2D); context->priv().deleteBackendTexture(texture2D);
context->resetContext(); context->resetContext();
} }

View File

@ -31,9 +31,8 @@
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) { DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext(); GrContext* context = ctxInfo.grContext();
GrGpu* gpu = context->priv().getGpu();
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(1, 1, GrBackendTexture backendTex = context->priv().createBackendTexture(1, 1,
kRGBA_8888_SkColorType, kRGBA_8888_SkColorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kNo); GrRenderable::kNo);
@ -120,7 +119,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, invalidTexture.isValid()); REPORTER_ASSERT(reporter, invalidTexture.isValid());
REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(invalidTexture, invalidTexture)); REPORTER_ASSERT(reporter, GrBackendTexture::TestingOnly_Equals(invalidTexture, invalidTexture));
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
static void testing_release_proc(void* ctx) { static void testing_release_proc(void* ctx) {
@ -139,7 +138,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkReleaseExternalQueueTest, reporter, ctxInfo) {
} }
for (bool useExternal : {false, true}) { for (bool useExternal : {false, true}) {
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture(1, 1, GrBackendTexture backendTex = context->priv().createBackendTexture(1, 1,
kRGBA_8888_SkColorType, kRGBA_8888_SkColorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kNo); GrRenderable::kNo);
@ -203,7 +202,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkReleaseExternalQueueTest, reporter, ctxInfo) {
// Now that we flushed and waited the release proc should have be triggered. // Now that we flushed and waited the release proc should have be triggered.
REPORTER_ASSERT(reporter, count == 1); REPORTER_ASSERT(reporter, count == 1);
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
@ -211,8 +210,8 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkReleaseExternalQueueTest, reporter, ctxInfo) {
// in flush calls // in flush calls
DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkPrepareForExternalIOQueueTransitionTest, reporter, ctxInfo) { DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkPrepareForExternalIOQueueTransitionTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext(); GrContext* context = ctxInfo.grContext();
GrGpu* gpu = context->priv().getGpu();
GrVkGpu* vkGpu = static_cast<GrVkGpu*>(gpu); GrVkGpu* vkGpu = static_cast<GrVkGpu*>(context->priv().getGpu());
if (!vkGpu->vkCaps().supportsExternalMemory()) { if (!vkGpu->vkCaps().supportsExternalMemory()) {
return; return;
} }
@ -223,7 +222,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkPrepareForExternalIOQueueTransitionTest, report
// We don't set textures to present // We don't set textures to present
continue; continue;
} }
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
4, 4, kRGBA_8888_SkColorType, GrMipMapped::kNo, 4, 4, kRGBA_8888_SkColorType, GrMipMapped::kNo,
useSurface ? GrRenderable::kYes : GrRenderable::kNo); useSurface ? GrRenderable::kYes : GrRenderable::kNo);
@ -324,7 +323,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkPrepareForExternalIOQueueTransitionTest, report
GrFlushInfo flushInfo; GrFlushInfo flushInfo;
flushInfo.fFlags = kSyncCpu_GrFlushFlag; flushInfo.fFlags = kSyncCpu_GrFlushFlag;
context->flush(flushInfo); context->flush(flushInfo);
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }
} }
@ -339,7 +338,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkTransitionExternalQueueTest, reporter, ctxInfo)
return; return;
} }
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
1, 1, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo); 1, 1, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kNo);
sk_sp<SkImage> image; sk_sp<SkImage> image;
// Make a backend texture with an external queue family and general layout. // Make a backend texture with an external queue family and general layout.
@ -378,7 +377,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkTransitionExternalQueueTest, reporter, ctxInfo)
image.reset(); image.reset();
gpu->testingOnly_flushGpuAndSync(); gpu->testingOnly_flushGpuAndSync();
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
#endif #endif

View File

@ -36,7 +36,7 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
GrGpu* gpu = context->priv().getGpu(); GrGpu* gpu = context->priv().getGpu();
GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(kW, kH, GrBackendTexture origBackendTex = context->priv().createBackendTexture(kW, kH,
kColorType, kColorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kNo); GrRenderable::kNo);
@ -90,7 +90,7 @@ void wrap_tex_test(skiatest::Reporter* reporter, GrContext* context) {
void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) { void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
GrGpu* gpu = context->priv().getGpu(); GrGpu* gpu = context->priv().getGpu();
GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(kW, kH, GrBackendTexture origBackendTex = context->priv().createBackendTexture(kW, kH,
kColorType, kColorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kYes); GrRenderable::kYes);
@ -127,13 +127,13 @@ void wrap_rt_test(skiatest::Reporter* reporter, GrContext* context) {
// When we wrapBackendRenderTarget it is always borrowed, so we must make sure to free the // When we wrapBackendRenderTarget it is always borrowed, so we must make sure to free the
// resource when we're done. // resource when we're done.
gpu->deleteTestingOnlyBackendTexture(origBackendTex); context->priv().deleteBackendTexture(origBackendTex);
} }
void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) { void wrap_trt_test(skiatest::Reporter* reporter, GrContext* context) {
GrGpu* gpu = context->priv().getGpu(); GrGpu* gpu = context->priv().getGpu();
GrBackendTexture origBackendTex = gpu->createTestingOnlyBackendTexture(kW, kH, GrBackendTexture origBackendTex = context->priv().createBackendTexture(kW, kH,
kColorType, kColorType,
GrMipMapped::kNo, GrMipMapped::kNo,
GrRenderable::kYes); GrRenderable::kYes);

View File

@ -450,12 +450,12 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixelsMSAA_Gpu, reporter, ctxInfo) {
test_write_pixels(reporter, ctxInfo.grContext(), 1); test_write_pixels(reporter, ctxInfo.grContext(), 1);
} }
static void test_write_pixels_non_texture(skiatest::Reporter* reporter, GrContext* context, static void test_write_pixels_non_texture(skiatest::Reporter* reporter,
GrContext* context,
int sampleCnt) { int sampleCnt) {
GrGpu* gpu = context->priv().getGpu();
for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) { for (auto& origin : { kTopLeft_GrSurfaceOrigin, kBottomLeft_GrSurfaceOrigin }) {
GrBackendTexture backendTex = gpu->createTestingOnlyBackendTexture( GrBackendTexture backendTex = context->priv().createBackendTexture(
DEV_W, DEV_H, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes); DEV_W, DEV_H, kRGBA_8888_SkColorType, GrMipMapped::kNo, GrRenderable::kYes);
if (!backendTex.isValid()) { if (!backendTex.isValid()) {
continue; continue;
@ -467,7 +467,7 @@ static void test_write_pixels_non_texture(skiatest::Reporter* reporter, GrContex
auto ii = SkImageInfo::MakeN32Premul(DEV_W, DEV_H); auto ii = SkImageInfo::MakeN32Premul(DEV_W, DEV_H);
test_write_pixels(reporter, surface.get(), ii); test_write_pixels(reporter, surface.get(), ii);
} }
gpu->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
} }
} }

View File

@ -24,8 +24,7 @@ DDLPromiseImageHelper::PromiseImageCallbackContext::~PromiseImageCallbackContext
SkASSERT(!fTotalFulfills || fDoneCnt); SkASSERT(!fTotalFulfills || fDoneCnt);
if (fPromiseImageTexture) { if (fPromiseImageTexture) {
GrGpu* gpu = fContext->priv().getGpu(); fContext->priv().deleteBackendTexture(fPromiseImageTexture->backendTexture());
gpu->deleteTestingOnlyBackendTexture(fPromiseImageTexture->backendTexture());
} }
} }

View File

@ -280,12 +280,11 @@ static sk_sp<SkImage> draw_with_gpu(std::function<bool(SkCanvas*)> draw,
break; break;
case SurfaceType::kBackendTexture: case SurfaceType::kBackendTexture:
backendTexture = context->priv().getGpu() backendTexture = context->priv().createBackendTexture(info.width(),
->createTestingOnlyBackendTexture(info.width(), info.height(),
info.height(), info.colorType(),
info.colorType(), GrMipMapped::kNo,
GrMipMapped::kNo, GrRenderable::kYes);
GrRenderable::kYes);
surface = SkSurface::MakeFromBackendTexture(context, surface = SkSurface::MakeFromBackendTexture(context,
backendTexture, backendTexture,
kTopLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin,
@ -332,7 +331,7 @@ static sk_sp<SkImage> draw_with_gpu(std::function<bool(SkCanvas*)> draw,
if (!context->abandoned()) { if (!context->abandoned()) {
surface.reset(); surface.reset();
if (backendTexture.isValid()) { if (backendTexture.isValid()) {
context->priv().getGpu()->deleteTestingOnlyBackendTexture(backendTexture); context->priv().deleteBackendTexture(backendTexture);
} }
if (backendRT.isValid()) { if (backendRT.isValid()) {
context->priv().getGpu()->deleteTestingOnlyBackendRenderTarget(backendRT); context->priv().getGpu()->deleteTestingOnlyBackendRenderTarget(backendRT);

View File

@ -34,7 +34,7 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, GrRenderable
sk_sp<GrTextureProxy> proxy; sk_sp<GrTextureProxy> proxy;
if (kBottomLeft_GrSurfaceOrigin == origin) { if (kBottomLeft_GrSurfaceOrigin == origin) {
// We (soon will) only support using kBottomLeft with wrapped textures. // We (soon will) only support using kBottomLeft with wrapped textures.
auto backendTex = context->priv().getGpu()->createTestingOnlyBackendTexture( auto backendTex = context->priv().createBackendTexture(
width, height, format, GrMipMapped::kNo, renderable); width, height, format, GrMipMapped::kNo, renderable);
if (!backendTex.isValid()) { if (!backendTex.isValid()) {
return nullptr; return nullptr;
@ -51,7 +51,7 @@ sk_sp<GrTextureProxy> MakeTextureProxyFromData(GrContext* context, GrRenderable
} }
if (!proxy) { if (!proxy) {
context->priv().getGpu()->deleteTestingOnlyBackendTexture(backendTex); context->priv().deleteBackendTexture(backendTex);
return nullptr; return nullptr;
} }