More natural way to serialize GPU tasks and tests.

This basically takes out the Windows-only hacks and promotes them to
cross-platform behavior driven by --gpu_threading.
    - When --gpu_threading is false (the default), this puts GPU tasks and tests
      together in the same GPU enclave.  They all run serially.
    - When --gpu_threading is true, both the tests and the tasks run totally
      independently, just like the thread-safe CPU-bound work.

BUG=skia:3255

Review URL: https://codereview.chromium.org/847273005
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 2eb327e..affb844 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -141,22 +141,16 @@
     , fThreaded(threaded) {}
 
 int GPUSink::enclave() const {
-    return fThreaded ? kAnyThread_Enclave : kGPUSink_Enclave;
+    return fThreaded ? kAnyThread_Enclave : kGPU_Enclave;
 }
 
 Error GPUSink::draw(const Src& src, SkBitmap* dst, SkWStream*) const {
-    GrContextFactory* factory = GetThreadLocalGrContextFactory();
-    if (FLAGS_abandonGpuContext) {
-        factory->abandonContexts();
-    }
-    if (FLAGS_resetGpuContext || FLAGS_abandonGpuContext) {
-        factory->destroyContexts();
-    }
+    GrContextFactory factory;
     const SkISize size = src.size();
     const SkImageInfo info =
         SkImageInfo::Make(size.width(), size.height(), kN32_SkColorType, kPremul_SkAlphaType);
     SkAutoTUnref<SkSurface> surface(
-            NewGpuSurface(factory, fContextType, fGpuAPI, info, fSampleCount, fUseDFText));
+            NewGpuSurface(&factory, fContextType, fGpuAPI, info, fSampleCount, fUseDFText));
     if (!surface) {
         return "Could not create a surface.";
     }
@@ -168,6 +162,9 @@
     canvas->flush();
     dst->allocPixels(info);
     canvas->readPixels(dst, 0,0);
+    if (FLAGS_abandonGpuContext) {
+        factory.abandonContexts();
+    }
     return "";
 }