Skip to content

Commit f625e4c

Browse files
bsalomonSkia Commit-Bot
authored andcommitted
Revert "Use ManagedBackendTexture in place of TestUtils backend texture helpers."
This reverts commit 5ee0556. Reason for revert: breaking bots Original change's description: > Use ManagedBackendTexture in place of TestUtils backend texture helpers. > > Unify on a single family of helpers for making backend textures. > > Stresses callback systems in more tests by avoiding artificial > flush/submit/syncs. > > some misc test cleanup along the way. > > Change-Id: Ia692e8927ba97b391ee77ea06ebf437a555617b2 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/324710 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> TBR=egdaniel@google.com,bsalomon@google.com Change-Id: I7d4fc9412c870ae13f7498671379b871dbf5a6c4 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/325619 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
1 parent 3bfeab7 commit f625e4c

24 files changed

+695
-656
lines changed

dm/DMSrcSink.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,18 +1482,22 @@ sk_sp<SkSurface> GPUSink::createDstSurface(GrDirectContext* context, SkISize siz
14821482
break;
14831483
case SkCommandLineConfigGpu::SurfType::kBackendTexture:
14841484
surface = sk_gpu_test::MakeBackendTextureSurface(context,
1485-
info,
1485+
info.dimensions(),
14861486
kTopLeft_GrSurfaceOrigin,
14871487
fSampleCount,
1488+
info.colorType(),
1489+
info.refColorSpace(),
14881490
GrMipmapped::kNo,
14891491
GrProtected::kNo,
14901492
&props);
14911493
break;
14921494
case SkCommandLineConfigGpu::SurfType::kBackendRenderTarget:
14931495
surface = sk_gpu_test::MakeBackendRenderTargetSurface(context,
1494-
info,
1496+
info.dimensions(),
14951497
kBottomLeft_GrSurfaceOrigin,
14961498
fSampleCount,
1499+
info.colorType(),
1500+
info.refColorSpace(),
14971501
GrProtected::kNo,
14981502
&props);
14991503
break;

tests/DeferredDisplayListTest.cpp

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "tests/TestUtils.h"
4545
#include "tools/gpu/BackendSurfaceFactory.h"
4646
#include "tools/gpu/GrContextFactory.h"
47-
#include "tools/gpu/ManagedBackendTexture.h"
4847

4948
#include <initializer_list>
5049
#include <memory>
@@ -788,21 +787,18 @@ enum class DDLStage { kMakeImage, kDrawImage, kDetach, kDrawDDL };
788787
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
789788
auto dContext = ctxInfo.directContext();
790789

791-
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(dContext,
792-
kSize,
793-
kSize,
794-
kRGBA_8888_SkColorType,
795-
GrMipmapped::kNo,
796-
GrRenderable::kNo,
797-
GrProtected::kNo);
798-
if (!mbet) {
790+
GrBackendTexture backendTex;
791+
CreateBackendTexture(dContext, &backendTex, kSize, kSize, kRGBA_8888_SkColorType,
792+
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kNo, GrProtected::kNo);
793+
if (!backendTex.isValid()) {
799794
return;
800795
}
801796

802797
SurfaceParameters params(dContext);
803798

804799
sk_sp<SkSurface> s = params.make(dContext);
805800
if (!s) {
801+
dContext->deleteBackendTexture(backendTex);
806802
return;
807803
}
808804

@@ -816,21 +812,20 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLWrapBackendTest, reporter, ctxInfo) {
816812

817813
auto rContext = canvas->recordingContext();
818814
if (!rContext) {
815+
s = nullptr;
816+
dContext->deleteBackendTexture(backendTex);
819817
return;
820818
}
821819

822820
// Wrapped Backend Textures are not supported in DDL
823821
TextureReleaseChecker releaseChecker;
824-
sk_sp<SkImage> image = SkImage::MakeFromTexture(
825-
rContext,
826-
mbet->texture(),
827-
kTopLeft_GrSurfaceOrigin,
828-
kRGBA_8888_SkColorType,
829-
kPremul_SkAlphaType,
830-
nullptr,
831-
sk_gpu_test::ManagedBackendTexture::ReleaseProc,
832-
mbet->releaseContext(TextureReleaseChecker::Release, &releaseChecker));
822+
sk_sp<SkImage> image =
823+
SkImage::MakeFromTexture(rContext, backendTex, kTopLeft_GrSurfaceOrigin,
824+
kRGBA_8888_SkColorType, kPremul_SkAlphaType, nullptr,
825+
TextureReleaseChecker::Release, &releaseChecker);
833826
REPORTER_ASSERT(reporter, !image);
827+
828+
dContext->deleteBackendTexture(backendTex);
834829
}
835830

836831
static sk_sp<SkPromiseImageTexture> dummy_fulfill_proc(void*) {
@@ -994,14 +989,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) {
994989
SkSurfaceCharacterization characterization;
995990
SkAssertResult(s->characterize(&characterization));
996991

997-
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeFromInfo(context, ii);
998-
if (!mbet) {
999-
ERRORF(reporter, "Could not make texture.");
992+
GrBackendTexture backendTexture;
993+
994+
if (!CreateBackendTexture(context, &backendTexture, ii, SkColors::kCyan, GrMipmapped::kNo,
995+
GrRenderable::kNo)) {
996+
REPORTER_ASSERT(reporter, false);
1000997
return;
1001998
}
1002999

10031000
FulfillInfo fulfillInfo;
1004-
fulfillInfo.fTex = SkPromiseImageTexture::Make(mbet->texture());
1001+
fulfillInfo.fTex = SkPromiseImageTexture::Make(backendTexture);
10051002

10061003
sk_sp<SkDeferredDisplayList> ddl;
10071004

@@ -1053,6 +1050,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(DDLSkSurfaceFlush, reporter, ctxInfo) {
10531050

10541051
REPORTER_ASSERT(reporter, fulfillInfo.fTex->unique());
10551052
fulfillInfo.fTex.reset();
1053+
1054+
DeleteBackendTexture(context, backendTexture);
10561055
}
10571056

10581057
////////////////////////////////////////////////////////////////////////////////

tests/EGLImageTest.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,22 @@
1717
#include "tests/Test.h"
1818
#include "tests/TestUtils.h"
1919
#include "tools/gpu/GrContextFactory.h"
20-
#include "tools/gpu/ManagedBackendTexture.h"
2120
#include "tools/gpu/gl/GLTestContext.h"
2221

2322
#ifdef SK_GL
2423

2524
using sk_gpu_test::GLTestContext;
2625

27-
static void cleanup(GLTestContext* glctx0,
28-
GrGLuint texID0,
29-
GLTestContext* glctx1,
30-
sk_sp<GrDirectContext> dContext,
26+
static void cleanup(GLTestContext* glctx0, GrGLuint texID0, GLTestContext* glctx1,
27+
sk_sp<GrDirectContext> dContext, GrBackendTexture* backendTex1,
3128
GrEGLImage image1) {
3229
if (glctx1) {
3330
glctx1->makeCurrent();
31+
if (dContext) {
32+
if (backendTex1 && backendTex1->isValid()) {
33+
dContext->deleteBackendTexture(*backendTex1);
34+
}
35+
}
3436
if (GR_EGL_NO_IMAGE != image1) {
3537
glctx1->destroyEGLImage(image1);
3638
}
@@ -62,18 +64,19 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
6264
return;
6365
}
6466
sk_sp<GrDirectContext> context1 = GrDirectContext::MakeGL(sk_ref_sp(glCtx1->gl()));
67+
GrBackendTexture backendTexture1;
6568
GrEGLImage image = GR_EGL_NO_IMAGE;
6669
GrGLTextureInfo externalTexture;
6770
externalTexture.fID = 0;
6871

6972
if (!context1) {
70-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
73+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
7174
return;
7275
}
7376

7477
if (!glCtx1->gl()->hasExtension("EGL_KHR_image") ||
7578
!glCtx1->gl()->hasExtension("EGL_KHR_gl_texture_2D_image")) {
76-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
79+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
7780
return;
7881
}
7982

@@ -83,33 +86,33 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
8386
context1->flushAndSubmit();
8487
static const int kSize = 100;
8588

86-
auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(
87-
context1.get(), kSize, kSize, kRGBA_8888_SkColorType, GrMipmapped::kNo,
88-
GrRenderable::kNo, GrProtected::kNo);
89+
CreateBackendTexture(context1.get(), &backendTexture1, kSize, kSize, kRGBA_8888_SkColorType,
90+
SkColors::kTransparent, GrMipmapped::kNo, GrRenderable::kNo,
91+
GrProtected::kNo);
8992

90-
if (!mbet) {
93+
if (!backendTexture1.isValid()) {
9194
ERRORF(reporter, "Error creating texture for EGL Image");
92-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
95+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
9396
return;
9497
}
9598

9699
GrGLTextureInfo texInfo;
97-
if (!mbet->texture().getGLTextureInfo(&texInfo)) {
100+
if (!backendTexture1.getGLTextureInfo(&texInfo)) {
98101
ERRORF(reporter, "Failed to get GrGLTextureInfo");
99102
return;
100103
}
101104

102105
if (GR_GL_TEXTURE_2D != texInfo.fTarget) {
103106
ERRORF(reporter, "Expected backend texture to be 2D");
104-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
107+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
105108
return;
106109
}
107110

108111
// Wrap the texture in an EGLImage
109112
image = glCtx1->texture2DToEGLImage(texInfo.fID);
110113
if (GR_EGL_NO_IMAGE == image) {
111114
ERRORF(reporter, "Error creating EGL Image from texture");
112-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
115+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
113116
return;
114117
}
115118

@@ -144,7 +147,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
144147
externalTexture.fFormat = GR_GL_RGBA8;
145148
if (0 == externalTexture.fID) {
146149
ERRORF(reporter, "Error converting EGL Image back to texture");
147-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
150+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
148151
return;
149152
}
150153

@@ -160,7 +163,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
160163
backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
161164
if (!texProxy) {
162165
ERRORF(reporter, "Error wrapping external texture in GrTextureProxy.");
163-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
166+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
164167
return;
165168
}
166169
GrSwizzle swizzle =
@@ -171,7 +174,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
171174

172175
if (!surfaceContext) {
173176
ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext.");
174-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
177+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
175178
return;
176179
}
177180

@@ -203,7 +206,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
203206
TestCopyFromSurface(reporter, context0, surfaceContext->asSurfaceProxy(),
204207
surfaceContext->origin(), colorType, pixels.get(), "EGLImageTest-copy");
205208

206-
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, image);
209+
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
207210
}
208211

209212
#endif // SK_GL

0 commit comments

Comments
 (0)