diff options
Diffstat (limited to 'tests/ImageTest.cpp')
-rw-r--r-- | tests/ImageTest.cpp | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp index 55730816bb..9940574eee 100644 --- a/tests/ImageTest.cpp +++ b/tests/ImageTest.cpp @@ -1044,35 +1044,6 @@ DEF_GPUTEST(SkImage_CrossContextGrayAlphaConfigs, reporter, options) { } } -static uint32_t GetIdForBackendObject(GrContext* ctx, GrBackendObject object) { - if (!object) { - return 0; - } - - if (ctx->contextPriv().getBackend() != kOpenGL_GrBackend) { - return 0; - } - - return reinterpret_cast<const GrGLTextureInfo*>(object)->fID; -} - -static uint32_t GetIdForBackendTexture(GrBackendTexture texture) { - if (!texture.isValid()) { - return 0; - } - - if (texture.backend() != kOpenGL_GrBackend) { - return 0; - } - - GrGLTextureInfo info; - if (!texture.getGLTextureInfo(&info)) { - return 0; - } - - return info.fID; -} - DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); sk_gpu_test::TestContext* testContext = ctxInfo.testContext(); @@ -1114,18 +1085,26 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) { continue; } - uint32_t originalID = GetIdForBackendObject(context, image->getTextureHandle(true, nullptr)); - GrBackendTexture texture; + GrBackendTexture origBackend = image->getBackendTexture(true); + if (testCase.fCanTakeDirectly) { + SkASSERT(origBackend.isValid()); + } + + GrBackendTexture newBackend; SkImage::BackendTextureReleaseProc proc; - bool result = - SkImage::MakeBackendTextureFromSkImage(context, std::move(image), &texture, &proc); + bool result = SkImage::MakeBackendTextureFromSkImage(context, std::move(image), + &newBackend, &proc); if (result != testCase.fExpectation) { static const char *const kFS[] = { "fail", "succeed" }; ERRORF(reporter, "This image was expected to %s but did not.", kFS[testCase.fExpectation]); } - bool tookDirectly = result && originalID == GetIdForBackendTexture(texture); + if (result) { + SkASSERT(newBackend.isValid()); + } + + bool tookDirectly = result && GrBackendTexture::TestingOnly_Equals(origBackend, newBackend); if (testCase.fCanTakeDirectly != tookDirectly) { static const char *const kExpectedState[] = { "not expected", "expected" }; ERRORF(reporter, "This backend texture was %s to be taken directly.", |