diff options
author | Robert Phillips <robertphillips@google.com> | 2018-04-11 10:08:06 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-12 14:56:10 +0000 |
commit | ba375a88843160e6884023e9108ea84de8eb3a0f (patch) | |
tree | 18dc34f015079a4ef7aedbc4d0fc877fa56d6d92 /tests/ImageTest.cpp | |
parent | 21f6437764253c304c839409ea7883ad56cfcd63 (diff) |
Add SK_SUPPORT_LEGACY_BACKEND_OBJECTS
This relies on the Chrome CL: https://chromium-review.googlesource.com/c/chromium/src/+/999796 (Add SK_SUPPORT_LEGACY_BACKEND_OBJECTS to SkUserConfig.h) landing first.
Change-Id: Ie0a2b7b84cc02e46957765a0a7d6444a5320769d
Reviewed-on: https://skia-review.googlesource.com/119140
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
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.", |