SkQP: make text context outlast gm

Change-Id: Ia8e3b42d1b88d111a3885a7b2ae90c29985a8c10
Reviewed-on: https://skia-review.googlesource.com/c/190672
Reviewed-by: Greg Daniel <egdaniel@google.com>
Cherry-Pick: 70441faaef1d845114f496887177b0f54da8d4ca
Reviewed-on: https://skia-review.googlesource.com/c/190674
Reviewed-by: Hal Canary <halcanary@google.com>
diff --git a/tools/skqp/src/skqp.cpp b/tools/skqp/src/skqp.cpp
index 7c41a99..b259a54 100644
--- a/tools/skqp/src/skqp.cpp
+++ b/tools/skqp/src/skqp.cpp
@@ -264,6 +264,12 @@
     static constexpr SkQP::RenderOutcome kError = {INT_MAX, INT_MAX, INT64_MAX};
     static constexpr SkQP::RenderOutcome kPass = {0, 0, 0};
 
+    std::unique_ptr<sk_gpu_test::TestContext> testCtx = make_test_context(backend);
+    if (!testCtx) {
+        return std::make_tuple(kError, "Skia Failure: test context");
+    }
+    testCtx->makeCurrent();
+
     SkASSERT(gmFact);
     std::unique_ptr<skiagm::GM> gm(gmFact(nullptr));
     SkASSERT(gm);
@@ -275,11 +281,6 @@
         SkImageInfo::Make(w, h, skqp::kColorType, kPremul_SkAlphaType, nullptr);
     const SkSurfaceProps props(0, SkSurfaceProps::kLegacyFontHost_InitType);
 
-    std::unique_ptr<sk_gpu_test::TestContext> testCtx = make_test_context(backend);
-    if (!testCtx) {
-        return std::make_tuple(kError, "Skia Failure: test context");
-    }
-    testCtx->makeCurrent();
     sk_sp<SkSurface> surf = SkSurface::MakeRenderTarget(
             testCtx->makeGrContext(context_options(gm.get())).get(),
             SkBudgeted::kNo, info, 0, &props);