MakeCurrent when creating WrappedSkImage

Skia may change a bunch of GL state (including active texture unit) when
we create a backend texture. We can't easily restore that state, so do
a full (often virtual) context switch instead. This will avoid damaging
another client's state.

(cherry picked from commit a68d774ea2336dd36267ab2f430e7005a8011448)

Bug: 1095679
Change-Id: I511115f8add6c290fc6a63355cfc4b22a7b1b0c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476899
Commit-Queue: Jonathan Backer <[email protected]>
Commit-Queue: Peng Huang <[email protected]>
Auto-Submit: Jonathan Backer <[email protected]>
Reviewed-by: Peng Huang <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#817708}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487833
Reviewed-by: Jonathan Backer <[email protected]>
Cr-Commit-Position: refs/branch-heads/4280@{#550}
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
diff --git a/gpu/command_buffer/service/wrapped_sk_image.cc b/gpu/command_buffer/service/wrapped_sk_image.cc
index 72a75fb44..0f5d11c 100644
--- a/gpu/command_buffer/service/wrapped_sk_image.cc
+++ b/gpu/command_buffer/service/wrapped_sk_image.cc
@@ -190,7 +190,9 @@
     if (context_state_->context_lost())
       return false;
 
-    DCHECK(context_state_->IsCurrent(nullptr));
+    // MakeCurrent to avoid destroying another client's state because Skia may
+    // change GL state to create and upload textures (crbug.com/1095679).
+    context_state_->MakeCurrent(nullptr);
     context_state_->set_need_context_state_reset(true);
 
 #if BUILDFLAG(ENABLE_VULKAN)