Store context options on caps.

Review URL: https://codereview.chromium.org/1158433006
diff --git a/bench/nanobench.cpp b/bench/nanobench.cpp
index 85685fb..2fba1f0 100644
--- a/bench/nanobench.cpp
+++ b/bench/nanobench.cpp
@@ -47,6 +47,8 @@
     SkAutoTDelete<GrContextFactory> gGrFactory;
 #endif
 
+    struct GrContextOptions;
+
 __SK_FORCE_IMAGE_DECODER_LINKING;
 
 static const int kAutoTuneLoops = 0;
@@ -844,7 +846,7 @@
     SkTaskGroup::Enabler enabled;
 
 #if SK_SUPPORT_GPU
-    GrContext::Options grContextOpts;
+    GrContextOptions grContextOpts;
     grContextOpts.fDrawPathToCompressedTexture = FLAGS_gpuCompressAlphaMasks;
     gGrFactory.reset(SkNEW_ARGS(GrContextFactory, (grContextOpts)));
 #endif
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 9f8ab72..e56175b 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -16,6 +16,7 @@
       '<(skia_include_path)/gpu/GrClip.h',
       '<(skia_include_path)/gpu/GrColor.h',
       '<(skia_include_path)/gpu/GrConfig.h',
+      '<(skia_include_path)/gpu/GrContextOptions.h',
       '<(skia_include_path)/gpu/GrContext.h',
       '<(skia_include_path)/gpu/GrCoordTransform.h',
       '<(skia_include_path)/gpu/GrFragmentProcessor.h',
diff --git a/include/gpu/GrCaps.h b/include/gpu/GrCaps.h
index 580017a..be62d8a 100644
--- a/include/gpu/GrCaps.h
+++ b/include/gpu/GrCaps.h
@@ -14,6 +14,8 @@
 #include "SkRefCnt.h"
 #include "SkString.h"
 
+struct GrContextOptions;
+
 class GrShaderCaps : public SkRefCnt {
 public:
     SK_DECLARE_INST_COUNT(GrShaderCaps)
@@ -103,7 +105,7 @@
 public:
     SK_DECLARE_INST_COUNT(GrCaps)
 
-    GrCaps();
+    GrCaps(const GrContextOptions&);
 
     virtual SkString dump() const;
 
@@ -186,6 +188,11 @@
         return fConfigTextureSupport[config];
     }
 
+    bool suppressPrints() const { return fSupressPrints; }
+
+    bool drawPathMasksToCompressedTexturesSupport() const {
+        return fDrawPathMasksToCompressedTextureSupport; }
+
 protected:
     SkAutoTUnref<GrShaderCaps>    fShaderCaps;
 
@@ -214,6 +221,9 @@
     bool fConfigTextureSupport[kGrPixelConfigCnt];
 
 private:
+    bool fSupressPrints : 1;
+    bool fDrawPathMasksToCompressedTextureSupport : 1;
+
     typedef SkRefCnt INHERITED;
 };
 
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index a6fdf75..b6fef3d 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -20,6 +20,7 @@
 
 class GrAARectRenderer;
 class GrBatchFontCache;
+struct GrContextOptions;
 class GrDrawTarget;
 class GrFragmentProcessor;
 class GrGpu;
@@ -46,20 +47,11 @@
 public:
     SK_DECLARE_INST_COUNT(GrContext)
 
-    struct Options {
-        Options() : fDrawPathToCompressedTexture(false), fSuppressPrints(false) { }
-
-        // EXPERIMENTAL
-        // May be removed in the future, or may become standard depending
-        // on the outcomes of a variety of internal tests.
-        bool fDrawPathToCompressedTexture;
-        bool fSuppressPrints;
-    };
-
     /**
      * Creates a GrContext for a backend context.
      */
-    static GrContext* Create(GrBackend, GrBackendContext, const Options* opts = NULL);
+    static GrContext* Create(GrBackend, GrBackendContext, const GrContextOptions& options);
+    static GrContext* Create(GrBackend, GrBackendContext);
 
     /**
      * Only defined in test apps.
@@ -530,7 +522,6 @@
     GrResourceProvider* resourceProvider() { return fResourceProvider; }
     const GrResourceProvider* resourceProvider() const { return fResourceProvider; }
     GrResourceCache* getResourceCache() { return fResourceCache; }
-    bool suppressPrints() const { return fOptions.fSuppressPrints; }
 
     // Called by tests that draw directly to the context via GrDrawTarget
     void getTestTarget(GrTestTarget*);
@@ -548,12 +539,6 @@
                     GrPathRendererChain::DrawType drawType = GrPathRendererChain::kColor_DrawType,
                     GrPathRendererChain::StencilSupport* stencilSupport = NULL);
 
-    /**
-     *  This returns a copy of the the GrContext::Options that was passed to the
-     *  constructor of this class.
-     */
-    const Options& getOptions() const { return fOptions; }
-
     /** Prints cache stats to the string if GR_CACHE_STATS == 1. */
     void dumpCacheStats(SkString*) const;
     void printCacheStats() const;
@@ -599,11 +584,10 @@
 
     int                             fMaxTextureSizeOverride;
 
-    const Options                   fOptions;
     const uint32_t                  fUniqueID;
 
-    GrContext(const Options&); // init must be called after the constructor.
-    bool init(GrBackend, GrBackendContext);
+    GrContext(); // init must be called after the constructor.
+    bool init(GrBackend, GrBackendContext, const GrContextOptions& options);
     void initMockContext();
     void initCommon();
 
diff --git a/include/gpu/GrContextOptions.h b/include/gpu/GrContextOptions.h
new file mode 100644
index 0000000..a2b2d2d
--- /dev/null
+++ b/include/gpu/GrContextOptions.h
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrContextOptions_DEFINED
+#define GrContextOptions_DEFINED
+
+#include "GrTypes.h"
+
+struct GrContextOptions {
+    GrContextOptions() : fDrawPathToCompressedTexture(false), fSuppressPrints(false) {}
+
+    // EXPERIMENTAL
+    // May be removed in the future, or may become standard depending
+    // on the outcomes of a variety of internal tests.
+    bool fDrawPathToCompressedTexture;
+    // Suppress prints for the GrContext.
+    bool fSuppressPrints;
+};
+
+#endif
diff --git a/include/gpu/GrTypesPriv.h b/include/gpu/GrTypesPriv.h
index eaf1aa4..9202742 100644
--- a/include/gpu/GrTypesPriv.h
+++ b/include/gpu/GrTypesPriv.h
@@ -265,13 +265,13 @@
 };
 
 #ifdef SK_DEBUG
-// Takes a pointer to a GrContext, and will suppress prints if required
-#define GrContextDebugf(context, ...) \
-    if (!context->suppressPrints()) {         \
-        SkDebugf(__VA_ARGS__);      \
+// Takes a pointer to a GrCaps, and will suppress prints if required
+#define GrCapsDebugf(caps, ...)         \
+    if (!caps->suppressPrints()) {      \
+        SkDebugf(__VA_ARGS__);          \
     }
 #else
-#define GrContextDebugf(context, ...)
+#define GrCapsDebugf(caps, ...)
 #endif
 
 #endif
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index f4ca6c4..3ed0b6b 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -15,6 +15,7 @@
 #include "GrBatchTarget.h"
 #include "GrBatchTest.h"
 #include "GrCaps.h"
+#include "GrContextOptions.h"
 #include "GrDefaultGeoProcFactory.h"
 #include "GrGpuResource.h"
 #include "GrGpuResourcePriv.h"
@@ -70,16 +71,16 @@
     GrContext* fContext;
 };
 
-GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
-                             const Options* opts) {
-    GrContext* context;
-    if (NULL == opts) {
-        context = SkNEW_ARGS(GrContext, (Options()));
-    } else {
-        context = SkNEW_ARGS(GrContext, (*opts));
-    }
+GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext) {
+    GrContextOptions defaultOptions;
+    return Create(backend, backendContext, defaultOptions);
+}
 
-    if (context->init(backend, backendContext)) {
+GrContext* GrContext::Create(GrBackend backend, GrBackendContext backendContext,
+                             const GrContextOptions& options) {
+    GrContext* context = SkNEW(GrContext);
+
+    if (context->init(backend, backendContext, options)) {
         return context;
     } else {
         context->unref();
@@ -96,7 +97,7 @@
     return id;
 }
 
-GrContext::GrContext(const Options& opts) : fOptions(opts), fUniqueID(next_id()) {
+GrContext::GrContext() : fUniqueID(next_id()) {
     fGpu = NULL;
     fResourceCache = NULL;
     fResourceProvider = NULL;
@@ -110,10 +111,11 @@
     fMaxTextureSizeOverride = 1 << 20;
 }
 
-bool GrContext::init(GrBackend backend, GrBackendContext backendContext) {
+bool GrContext::init(GrBackend backend, GrBackendContext backendContext,
+                     const GrContextOptions& options) {
     SkASSERT(NULL == fGpu);
 
-    fGpu = GrGpu::Create(backend, backendContext, this);
+    fGpu = GrGpu::Create(backend, backendContext, options, this);
     if (NULL == fGpu) {
         return false;
     }
diff --git a/src/gpu/GrContextFactory.cpp b/src/gpu/GrContextFactory.cpp
index 1a3864a..7df1917 100755
--- a/src/gpu/GrContextFactory.cpp
+++ b/src/gpu/GrContextFactory.cpp
@@ -75,7 +75,7 @@
 
     glCtx->makeCurrent();
     GrBackendContext p3dctx = reinterpret_cast<GrBackendContext>(glInterface.get());
-    grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, &fGlobalOptions));
+    grCtx.reset(GrContext::Create(kOpenGL_GrBackend, p3dctx, fGlobalOptions));
     if (!grCtx.get()) {
         return NULL;
     }
diff --git a/src/gpu/GrContextFactory.h b/src/gpu/GrContextFactory.h
index 353e3d9..7fd4b77 100644
--- a/src/gpu/GrContextFactory.h
+++ b/src/gpu/GrContextFactory.h
@@ -9,6 +9,7 @@
 #define GrContextFactory_DEFINED
 
 #include "GrContext.h"
+#include "GrContextOptions.h"
 
 #include "gl/SkGLContext.h"
 #include "SkTArray.h"
@@ -80,7 +81,7 @@
         }
     }
 
-    explicit GrContextFactory(const GrContext::Options& opts) : fGlobalOptions(opts) { }
+    explicit GrContextFactory(const GrContextOptions& opts) : fGlobalOptions(opts) { }
     GrContextFactory() { }
 
     ~GrContextFactory() { this->destroyContexts(); }
@@ -126,7 +127,7 @@
         return NULL;
     }
 
-    const GrContext::Options& getGlobalOptions() const { return fGlobalOptions; }
+    const GrContextOptions& getGlobalOptions() const { return fGlobalOptions; }
 
 private:
     struct GPUContext {
@@ -135,7 +136,7 @@
         GrContext*                fGrContext;
     };
     SkTArray<GPUContext, true>    fContexts;
-    const GrContext::Options      fGlobalOptions;
+    const GrContextOptions        fGlobalOptions;
 };
 
 #endif
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 2d5d0b8..e5baaa7 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -11,6 +11,7 @@
 #include "GrBatch.h"
 #include "GrCaps.h"
 #include "GrContext.h"
+#include "GrContextOptions.h"
 #include "GrPath.h"
 #include "GrPipeline.h"
 #include "GrMemoryPool.h"
@@ -68,8 +69,8 @@
         drawBounds->roundOut(&drawIBounds);
         if (!copyRect.intersect(drawIBounds)) {
 #ifdef SK_DEBUG
-            GrContextDebugf(fContext, "Missed an early reject. "
-                                      "Bailing on draw from setupDstReadIfNecessary.\n");
+            GrCapsDebugf(fCaps, "Missed an early reject. "
+                         "Bailing on draw from setupDstReadIfNecessary.\n");
 #endif
             return false;
         }
@@ -598,7 +599,7 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-GrCaps::GrCaps() {
+GrCaps::GrCaps(const GrContextOptions& options) {
     fMipMapSupport = false;
     fNPOTTextureTileSupport = false;
     fTwoSidedStencilSupport = false;
@@ -621,6 +622,9 @@
 
     memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport));
     memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport));
+
+    fSupressPrints = options.fSuppressPrints;
+    fDrawPathMasksToCompressedTextureSupport = options.fDrawPathToCompressedTexture;
 }
 
 static SkString map_flags_to_string(uint32_t flags) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 6e8dc43..5b5be1b 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -31,7 +31,7 @@
      * not supported (at compile-time or run-time) this returns NULL. The context will not be
      * fully constructed and should not be used by GrGpu until after this function returns.
      */
-    static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context);
+    static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, GrContext* context);
 
     ////////////////////////////////////////////////////////////////////////////
 
diff --git a/src/gpu/GrGpuFactory.cpp b/src/gpu/GrGpuFactory.cpp
index bd572e6..3001a0d 100644
--- a/src/gpu/GrGpuFactory.cpp
+++ b/src/gpu/GrGpuFactory.cpp
@@ -20,10 +20,13 @@
     gGpuFactories[i] = proc;
 }
 
-GrGpu* GrGpu::Create(GrBackend backend, GrBackendContext backendContext, GrContext* context) {
+GrGpu* GrGpu::Create(GrBackend backend,
+                     GrBackendContext backendContext,
+                     const GrContextOptions& options,
+                     GrContext* context) {
     SkASSERT((int)backend < kMaxNumBackends);
     if (!gGpuFactories[backend]) {
         return NULL;
     }
-    return (gGpuFactories[backend])(backendContext, context);
+    return (gGpuFactories[backend])(backendContext, options, context);
 }
diff --git a/src/gpu/GrGpuFactory.h b/src/gpu/GrGpuFactory.h
index 180f264..aecc2c1 100644
--- a/src/gpu/GrGpuFactory.h
+++ b/src/gpu/GrGpuFactory.h
@@ -12,8 +12,9 @@
 
 class GrGpu;
 class GrContext;
+struct GrContextOptions;
 
-typedef GrGpu* (*CreateGpuProc)(GrBackendContext, GrContext*);
+typedef GrGpu* (*CreateGpuProc)(GrBackendContext, const GrContextOptions& options, GrContext*);
 
 class GrGpuFactoryRegistrar {
 public:
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index aa922ca..2591186 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -174,7 +174,7 @@
                                      resultBounds.height());
 
     if (allowCompression &&
-        fContext->getOptions().fDrawPathToCompressedTexture &&
+        fContext->getGpu()->caps()->drawPathMasksToCompressedTexturesSupport() &&
         choose_compressed_fmt(fContext->getGpu()->caps(), &fCompressedFormat)) {
         fCompressionMode = kCompress_CompressionMode;
     }
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 0801d03..8580661 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -7,6 +7,7 @@
  */
 
 #include "GrTest.h"
+#include "GrContextOptions.h"
 
 #include "GrGpuResourceCacheAccess.h"
 #include "GrInOrderDrawBuffer.h"
@@ -138,7 +139,9 @@
 
 class MockGpu : public GrGpu {
 public:
-    MockGpu(GrContext* context) : INHERITED(context) { fCaps.reset(SkNEW(GrCaps)); }
+    MockGpu(GrContext* context, const GrContextOptions& options) : INHERITED(context) {
+        fCaps.reset(SkNEW_ARGS(GrCaps, (options)));
+    }
     ~MockGpu() override {}
     bool canWriteTexturePixels(const GrTexture*, GrPixelConfig srcConfig) const override {
         return true;
@@ -249,15 +252,16 @@
 };
 
 GrContext* GrContext::CreateMockContext() {
-    GrContext* context = SkNEW_ARGS(GrContext, (Options()));
+    GrContext* context = SkNEW(GrContext);
 
     context->initMockContext();
     return context;
 }
 
 void GrContext::initMockContext() {
+    GrContextOptions options;
     SkASSERT(NULL == fGpu);
-    fGpu = SkNEW_ARGS(MockGpu, (this));
+    fGpu = SkNEW_ARGS(MockGpu, (this, options));
     SkASSERT(fGpu);
     this->initCommon();
 
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 2a97137..6f272b7 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -12,7 +12,9 @@
 #include "SkTSearch.h"
 #include "SkTSort.h"
 
-GrGLCaps::GrGLCaps(const GrGLContextInfo& ctxInfo, const GrGLInterface* glInterface) {
+GrGLCaps::GrGLCaps(const GrContextOptions& contextOptions,
+                   const GrGLContextInfo& ctxInfo,
+                   const GrGLInterface* glInterface) : INHERITED(contextOptions) {
     fVerifiedColorConfigs.reset();
     fStencilFormats.reset();
     fStencilVerifiedColorConfigs.reset();
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index cd84242..9d38c82 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -91,7 +91,8 @@
      * Initializes the GrGLCaps to the set of features supported in the current
      * OpenGL context accessible via ctxInfo.
      */
-    GrGLCaps(const GrGLContextInfo& ctxInfo, const GrGLInterface* glInterface);
+    GrGLCaps(const GrContextOptions& contextOptions, const GrGLContextInfo& ctxInfo,
+             const GrGLInterface* glInterface);
 
     /**
      * Call to note that a color config has been verified as a valid color
diff --git a/src/gpu/gl/GrGLContext.cpp b/src/gpu/gl/GrGLContext.cpp
index 8115687..3359865 100644
--- a/src/gpu/gl/GrGLContext.cpp
+++ b/src/gpu/gl/GrGLContext.cpp
@@ -9,7 +9,7 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 
-GrGLContext* GrGLContext::Create(const GrGLInterface* interface) {
+GrGLContext* GrGLContext::Create(const GrGLInterface* interface, const GrContextOptions& options) {
     // We haven't validated the GrGLInterface yet, so check for GetString function pointer
     if (!interface->fFunctions.fGetString) {
         return NULL;
@@ -55,6 +55,9 @@
     args.fIsMesa = GrGLIsMesaFromVersionString(ver);
 
     args.fIsChromium = GrGLIsChromiumFromRendererString(renderer);
+
+    args.fContextOptions = &options;
+
     return SkNEW_ARGS(GrGLContext, (args));
 }
 
@@ -67,5 +70,5 @@
     fIsMesa = args.fIsMesa;
     fIsChromium = args.fIsChromium;
 
-    fGLCaps.reset(SkNEW_ARGS(GrGLCaps, (*this, fInterface)));
+    fGLCaps.reset(SkNEW_ARGS(GrGLCaps, (*args.fContextOptions, *this, fInterface)));
 }
diff --git a/src/gpu/gl/GrGLContext.h b/src/gpu/gl/GrGLContext.h
index e84c8ec..50262cf 100644
--- a/src/gpu/gl/GrGLContext.h
+++ b/src/gpu/gl/GrGLContext.h
@@ -15,7 +15,7 @@
 #include "GrGLSL.h"
 #include "GrGLUtil.h"
 
-#include "SkString.h"
+struct GrContextOptions;
 
 /**
  * Encapsulates information about an OpenGL context including the OpenGL
@@ -51,6 +51,7 @@
         GrGLRenderer                        fRenderer;
         bool                                fIsMesa;
         bool                                fIsChromium;
+        const  GrContextOptions*            fContextOptions;
     };
 
     GrGLContextInfo(const ConstructorArgs& args);
@@ -74,7 +75,7 @@
      * Creates a GrGLContext from a GrGLInterface and the currently
      * bound OpenGL context accessible by the GrGLInterface.
      */
-    static GrGLContext* Create(const GrGLInterface* interface);
+    static GrGLContext* Create(const GrGLInterface* interface, const GrContextOptions& options);
 
     const GrGLInterface* interface() const { return fInterface; }
 
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 07aaaae..3a3b833 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -157,7 +157,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-GrGpu* GrGLGpu::Create(GrBackendContext backendContext, GrContext* context) {
+GrGpu* GrGLGpu::Create(GrBackendContext backendContext, const GrContextOptions& options,
+                       GrContext* context) {
     SkAutoTUnref<const GrGLInterface> glInterface(
         reinterpret_cast<const GrGLInterface*>(backendContext));
     if (!glInterface) {
@@ -168,7 +169,7 @@
     if (!glInterface) {
         return NULL;
     }
-    GrGLContext* glContext = GrGLContext::Create(glInterface);
+    GrGLContext* glContext = GrGLContext::Create(glInterface, options);
     if (glContext) {
         return SkNEW_ARGS(GrGLGpu, (glContext, context));
     }
@@ -1436,7 +1437,7 @@
 
     fCurrentProgram.reset(fProgramCache->getProgram(args));
     if (NULL == fCurrentProgram.get()) {
-        GrContextDebugf(this->getContext(), "Failed to create program!\n");
+        GrCapsDebugf(this->caps(), "Failed to create program!\n");
         return false;
     }
 
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index d7b1102..c777f77 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -32,7 +32,8 @@
 
 class GrGLGpu : public GrGpu {
 public:
-    static GrGpu* Create(GrBackendContext backendContext, GrContext* context);
+    static GrGpu* Create(GrBackendContext backendContext, const GrContextOptions& options,
+                         GrContext* context);
     ~GrGLGpu() override;
 
     void contextAbandoned() override;
diff --git a/src/gpu/gl/GrGLProgramDataManager.cpp b/src/gpu/gl/GrGLProgramDataManager.cpp
index ef2f59e..ce2598e 100644
--- a/src/gpu/gl/GrGLProgramDataManager.cpp
+++ b/src/gpu/gl/GrGLProgramDataManager.cpp
@@ -261,7 +261,7 @@
 #ifdef SK_DEBUG
 void GrGLProgramDataManager::printUnused(const Uniform& uni) const {
     if (kUnusedUniform == uni.fFSLocation && kUnusedUniform == uni.fVSLocation) {
-        GrContextDebugf(fGpu->getContext(), "Unused uniform in shader\n");
+        GrCapsDebugf(fGpu->caps(), "Unused uniform in shader\n");
     }
 }
 #endif
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.cpp b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
index 28e1fba..a3b0d68 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.cpp
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.cpp
@@ -207,7 +207,7 @@
 
         totalTextures += processor->numTextures();
         if (totalTextures >= maxTextureUnits) {
-            GrContextDebugf(fGpu->getContext(), "Program would use too many texture units\n");
+            GrCapsDebugf(fGpu->caps(), "Program would use too many texture units\n");
             return false;
         }
     }
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 90aac8b..ca801f9 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -283,7 +283,7 @@
 #endif
 
     // We suppress prints to avoid spew
-    GrContext::Options opts;
+    GrContextOptions opts;
     opts.fSuppressPrints = true;
     GrContextFactory debugFactory(opts);
     for (int type = 0; type < GrContextFactory::kLastGLContextType; ++type) {
diff --git a/tools/CopyTilesRenderer.cpp b/tools/CopyTilesRenderer.cpp
index 6f95da7..bc1e32e 100644
--- a/tools/CopyTilesRenderer.cpp
+++ b/tools/CopyTilesRenderer.cpp
@@ -18,7 +18,7 @@
 
 namespace sk_tools {
 #if SK_SUPPORT_GPU
-    CopyTilesRenderer::CopyTilesRenderer(const GrContext::Options& opts, int x, int y)
+    CopyTilesRenderer::CopyTilesRenderer(const GrContextOptions& opts, int x, int y)
     : INHERITED(opts)
     , fXTilesPerLargeTile(x)
     , fYTilesPerLargeTile(y) { }
diff --git a/tools/CopyTilesRenderer.h b/tools/CopyTilesRenderer.h
index 3d9a1eb..5ff4175 100644
--- a/tools/CopyTilesRenderer.h
+++ b/tools/CopyTilesRenderer.h
@@ -11,6 +11,7 @@
 #include "PictureRenderer.h"
 #include "SkTypes.h"
 
+struct GrContextOptions;
 class SkPicture;
 class SkString;
 
@@ -23,7 +24,7 @@
 
     public:
 #if SK_SUPPORT_GPU
-        CopyTilesRenderer(const GrContext::Options &opts, int x, int y);
+        CopyTilesRenderer(const GrContextOptions &opts, int x, int y);
 #else
         CopyTilesRenderer(int x, int y);
 #endif
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index 93701ba..0875c5a 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -465,7 +465,7 @@
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
 #if SK_SUPPORT_GPU
-TiledPictureRenderer::TiledPictureRenderer(const GrContext::Options& opts)
+TiledPictureRenderer::TiledPictureRenderer(const GrContextOptions& opts)
     : INHERITED(opts)
     , fTileWidth(kDefaultTileWidth)
 #else
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h
index e143468..fadf970 100644
--- a/tools/PictureRenderer.h
+++ b/tools/PictureRenderer.h
@@ -28,6 +28,7 @@
 
 #include "image_expectations.h"
 
+struct GrContextOptions;
 class SkBitmap;
 class SkCanvas;
 class SkGLContext;
@@ -392,7 +393,7 @@
         return fGrContext;
     }
 
-    const GrContext::Options& getGrContextOptions() {
+    const GrContextOptions& getGrContextOptions() {
         return fGrContextFactory.getGlobalOptions();
     }
 #endif
@@ -406,7 +407,7 @@
     }
 
 #if SK_SUPPORT_GPU
-    explicit PictureRenderer(const GrContext::Options &opts)
+    explicit PictureRenderer(const GrContextOptions &opts)
 #else
     PictureRenderer()
 #endif
@@ -498,7 +499,7 @@
 class RecordPictureRenderer : public PictureRenderer {
 public:
 #if SK_SUPPORT_GPU
-    RecordPictureRenderer(const GrContext::Options &opts) : INHERITED(opts) { }
+    RecordPictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
 #endif
 
     bool render(SkBitmap** out = NULL) override;
@@ -519,7 +520,7 @@
 class PipePictureRenderer : public PictureRenderer {
 public:
 #if SK_SUPPORT_GPU
-    PipePictureRenderer(const GrContext::Options &opts) : INHERITED(opts) { }
+    PipePictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
 #endif
 
     bool render(SkBitmap** out = NULL) override;
@@ -533,7 +534,7 @@
 class SimplePictureRenderer : public PictureRenderer {
 public:
 #if SK_SUPPORT_GPU
-    SimplePictureRenderer(const GrContext::Options &opts) : INHERITED(opts) { }
+    SimplePictureRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
 #endif
 
     virtual void init(const SkPicture* pict,
@@ -554,7 +555,7 @@
 class TiledPictureRenderer : public PictureRenderer {
 public:
 #if SK_SUPPORT_GPU
-    TiledPictureRenderer(const GrContext::Options &opts);
+    TiledPictureRenderer(const GrContextOptions &opts);
 #else
     TiledPictureRenderer();
 #endif
@@ -689,7 +690,7 @@
 class PlaybackCreationRenderer : public PictureRenderer {
 public:
 #if SK_SUPPORT_GPU
-    PlaybackCreationRenderer(const GrContext::Options &opts) : INHERITED(opts) { }
+    PlaybackCreationRenderer(const GrContextOptions &opts) : INHERITED(opts) { }
 #endif
 
     void setup() override;
@@ -709,7 +710,7 @@
 };
 
 #if SK_SUPPORT_GPU
-extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts);
+extern PictureRenderer* CreateGatherPixelRefsRenderer(const GrContextOptions& opts);
 #else
 extern PictureRenderer* CreateGatherPixelRefsRenderer();
 #endif
diff --git a/tools/PictureRenderingFlags.cpp b/tools/PictureRenderingFlags.cpp
index 82097e9..0cec3e1 100644
--- a/tools/PictureRenderingFlags.cpp
+++ b/tools/PictureRenderingFlags.cpp
@@ -8,6 +8,7 @@
 #include "PictureRenderingFlags.h"
 
 #include "CopyTilesRenderer.h"
+#include "GrContextOptions.h"
 #include "PictureRenderer.h"
 #include "picture_utils.h"
 #include "SkCommandLineFlags.h"
@@ -94,7 +95,7 @@
     const char* mode = NULL;
 
 #if SK_SUPPORT_GPU
-    GrContext::Options grContextOpts;
+    GrContextOptions grContextOpts;
     grContextOpts.fDrawPathToCompressedTexture = FLAGS_gpuCompressAlphaMasks;
   #define RENDERER_ARGS (grContextOpts)
 #else