62static void cleanup(GLTestContext* glctx0,
64 GLTestContext* glctx1,
70 glctx1->destroyEGLImage(image1);
74 glctx0->makeCurrent();
76 GR_GL_CALL(glctx0->gl(), DeleteTextures(1, &texID0));
81 auto context0 = ctxInfo.directContext();
95 std::unique_ptr<GLTestContext> glCtx1 = glCtx0->
makeNew();
102 externalTexture.
fID = 0;
105 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
109 if (!glCtx1->gl()->hasExtension(
"EGL_KHR_image") ||
110 !glCtx1->gl()->hasExtension(
"EGL_KHR_gl_texture_2D_image")) {
111 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
119 static const int kSize = 100;
121 auto mbet = sk_gpu_test::ManagedBackendTexture::MakeWithoutData(context1.
get(),
131 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
143 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
148 image = glCtx1->texture2DToEGLImage(texInfo.
fID);
151 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
166 pixels.get()[
i] = 0xDDAABBCC;
184 if (0 == externalTexture.
fID) {
186 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
201 ERRORF(
reporter,
"Error wrapping external texture in GrTextureProxy.");
202 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
206 colorInfo.colorType());
208 auto surfaceContext = context0->priv().makeSC(std::move(view), colorInfo);
210 if (!surfaceContext) {
211 ERRORF(
reporter,
"Error wrapping external texture in SurfaceContext.");
212 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
227 auto temp = context0->priv().makeSFCFromBackendTexture(colorInfo,
233 ERRORF(
reporter,
"Should not be able to wrap an EXTERNAL texture as a RT.");
246 surfaceContext->asSurfaceProxyRef(),
247 surfaceContext->origin(),
248 colorInfo.colorType(),
250 "EGLImageTest-copy");
252 cleanup(glCtx0, externalTexture.
fID, glCtx1.get(), context1,
image);
#define GR_GL_UNSIGNED_BYTE
#define GR_GL_TEXTURE_EXTERNAL
#define GR_GL_CALL(IFACE, X)
@ kBorrow_GrWrapOwnership
@ kBottomLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
sk_sp< T > sk_ref_sp(T *obj)
void TestWritePixels(skiatest::Reporter *reporter, GrDirectContext *dContext, skgpu::ganesh::SurfaceContext *dstContext, bool expectedToWork, const char *testName)
void TestCopyFromSurface(skiatest::Reporter *reporter, GrDirectContext *dContext, sk_sp< GrSurfaceProxy > proxy, GrSurfaceOrigin origin, GrColorType colorType, uint32_t expectedPixelValues[], const char *testName)
#define REPORTER_ASSERT(r, cond,...)
#define DEF_GANESH_TEST_FOR_GL_CONTEXT(name, reporter, context_info, ctsEnforcement)
const GrShaderCaps * shaderCaps() const
void resetContext(uint32_t state=kAll_GrBackendState)
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
const GrGLCaps & glCaps() const
const GrBackendFormat & backendFormat() const
GrSurfaceProxyPriv priv()
GrTexture * peekTexture() const
GrTextureType textureType() const
bool hasRestrictedSampling() const
skgpu::Mipmapped mipmapped() const
GrTextureProxy * asTextureProxy() override
skgpu::Mipmapped mipmapped() const
bool hasRestrictedSampling() const
GrTextureType textureType() const
virtual std::unique_ptr< GLTestContext > makeNew() const
virtual GrGLuint eglImageToExternalTexture(GrEGLImage) const
const GrGLInterface * gl() const
SK_API GrBackendTexture MakeGL(int width, int height, skgpu::Mipmapped, const GrGLTextureInfo &glInfo, std::string_view label={})
SK_API bool GetGLTextureInfo(const GrBackendTexture &, GrGLTextureInfo *)
SK_API sk_sp< GrDirectContext > MakeGL(sk_sp< const GrGLInterface >, const GrContextOptions &)
sk_sp< const SkImage > image
static void Finish(Thread *thread)
bool fExternalTextureSupport