aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-04-11 10:08:06 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-04-12 14:56:10 +0000
commitba375a88843160e6884023e9108ea84de8eb3a0f (patch)
tree18dc34f015079a4ef7aedbc4d0fc877fa56d6d92 /tests
parent21f6437764253c304c839409ea7883ad56cfcd63 (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')
-rw-r--r--tests/ImageTest.cpp47
-rw-r--r--tests/SurfaceSemaphoreTest.cpp18
-rw-r--r--tests/VkBackendSurfaceTest.cpp2
3 files changed, 22 insertions, 45 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.",
diff --git a/tests/SurfaceSemaphoreTest.cpp b/tests/SurfaceSemaphoreTest.cpp
index eea6e37670..980478bcef 100644
--- a/tests/SurfaceSemaphoreTest.cpp
+++ b/tests/SurfaceSemaphoreTest.cpp
@@ -63,13 +63,8 @@ void check_pixels(skiatest::Reporter* reporter, const SkBitmap& bitmap) {
void draw_child(skiatest::Reporter* reporter,
const sk_gpu_test::ContextInfo& childInfo,
- const GrBackendObject& backendImage,
+ const GrBackendTexture& backendTexture,
const GrBackendSemaphore& semaphore) {
- GrBackendTexture backendTexture = GrTest::CreateBackendTexture(childInfo.backend(),
- MAIN_W, MAIN_H,
- kRGBA_8888_GrPixelConfig,
- GrMipMapped::kNo,
- backendImage);
childInfo.testContext()->makeCurrent();
@@ -156,21 +151,22 @@ void surface_semaphore_test(skiatest::Reporter* reporter,
}
sk_sp<SkImage> mainImage = mainSurface->makeImageSnapshot();
- GrBackendObject backendImage = mainImage->getTextureHandle(false);
+ GrBackendTexture backendTexture = mainImage->getBackendTexture(false);
- draw_child(reporter, childInfo1, backendImage, semaphores[0]);
+ draw_child(reporter, childInfo1, backendTexture, semaphores[0]);
#ifdef SK_VULKAN
if (kVulkan_GrBackend == mainInfo.backend()) {
// In Vulkan we need to make sure we are sending the correct VkImageLayout in with the
// backendImage. After the first child draw the layout gets changed to SHADER_READ, so
// we just manually set that here.
- GrVkImageInfo* vkInfo = (GrVkImageInfo*)backendImage;
- vkInfo->updateImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
+ GrVkImageInfo vkInfo;
+ SkAssertResult(backendTexture.getVkImageInfo(&vkInfo));
+ vkInfo.updateImageLayout(VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
}
#endif
- draw_child(reporter, childInfo2, backendImage, semaphores[1]);
+ draw_child(reporter, childInfo2, backendTexture, semaphores[1]);
}
DEF_GPUTEST(SurfaceSemaphores, reporter, options) {
diff --git a/tests/VkBackendSurfaceTest.cpp b/tests/VkBackendSurfaceTest.cpp
index 298dc38b4e..fc0464d981 100644
--- a/tests/VkBackendSurfaceTest.cpp
+++ b/tests/VkBackendSurfaceTest.cpp
@@ -84,6 +84,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
backendTexImage.setVkImageLayout(VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL == vkTexture->currentLayout());
+#ifdef SK_SUPPORT_LEGACY_BACKEND_OBJECTS
// Verify that modifying the layout via the old textureHandle sitll works in is reflected in the
// GrVkTexture and GrBackendTexture.
GrVkImageInfo* backendInfo = (GrVkImageInfo*)wrappedImage->getTextureHandle(false);
@@ -94,6 +95,7 @@ DEF_GPUTEST_FOR_VULKAN_CONTEXT(VkImageLayoutTest, reporter, ctxInfo) {
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == vkTexture->currentLayout());
REPORTER_ASSERT(reporter, backendTexImage.getVkImageInfo(&info));
REPORTER_ASSERT(reporter, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL == info.fImageLayout);
+#endif
vkTexture->updateImageLayout(initLayout);