aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ImageTest.cpp
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2017-11-16 10:17:20 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-11-16 16:30:53 +0000
commit5627d65146cb92624b682389e017d488872228c7 (patch)
tree9b90fe789341a23d05dc0e896eeafc1a20b70a26 /tests/ImageTest.cpp
parent47f6029d3dc5ee9e484931a13a14dcbe9d3f23d3 (diff)
Add method to sk_gpu_test::TestContext to automatically restore the previous context.
The motivation for this is to allow a GM to create a GL context, do some some work in it, and then return to the context that was set when it was invoked. Change-Id: Ie8496072a10f8f3ff36a08889e593a6ca961b61a Reviewed-on: https://skia-review.googlesource.com/70720 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests/ImageTest.cpp')
-rw-r--r--tests/ImageTest.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/tests/ImageTest.cpp b/tests/ImageTest.cpp
index 30ae635c98..d18e6a9674 100644
--- a/tests/ImageTest.cpp
+++ b/tests/ImageTest.cpp
@@ -436,10 +436,10 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn
// Create a texture image.
[context] { return create_gpu_image(context); },
// Create a texture image in a another GrContext.
- [testContext, otherContextInfo] {
- otherContextInfo.testContext()->makeCurrent();
+ [otherContextInfo] {
+ auto restore = otherContextInfo.testContext()->makeCurrentAndAutoRestore();
sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo.grContext());
- testContext->makeCurrent();
+ otherContextInfo.grContext()->flush();
return otherContextImage;
}
};
@@ -487,7 +487,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SkImage_makeTextureImage, reporter, contextIn
}
}
- testContext->makeCurrent();
context->flush();
}
}
@@ -1197,10 +1196,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) {
{ create_picture_image, true, false },
{ [context] { return create_gpu_image(context); }, true, true },
// Create a texture image in a another GrContext.
- { [testContext, otherContextInfo] {
- otherContextInfo.testContext()->makeCurrent();
+ { [otherContextInfo] {
+ auto restore = otherContextInfo.testContext()->makeCurrentAndAutoRestore();
sk_sp<SkImage> otherContextImage = create_gpu_image(otherContextInfo.grContext());
- testContext->makeCurrent();
+ otherContextInfo.grContext()->flush();
return otherContextImage;
}, false, false },
// Create an image that is too large to be texture backed.
@@ -1232,7 +1231,6 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(makeBackendTexture, reporter, ctxInfo) {
kExpectedState[testCase.fCanTakeDirectly]);
}
- testContext->makeCurrent();
context->flush();
}
}