Add SkColorSpace to GrDrawContext

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2164363002

Review-Url: https://codereview.chromium.org/2164363002
diff --git a/example/HelloWorld.h b/example/HelloWorld.h
index 619ee7c..deb56ba 100644
--- a/example/HelloWorld.h
+++ b/example/HelloWorld.h
@@ -36,7 +36,7 @@
     SkSurface* createSurface() override {
         SkSurfaceProps props(INHERITED::getSurfaceProps());
         if (kGPU_DeviceType == fType) {
-            return SkSurface::MakeRenderTargetDirect(fRenderTarget, &props).release();
+            return SkSurface::MakeRenderTargetDirect(fRenderTarget, nullptr, &props).release();
         }
         static const SkImageInfo info = SkImageInfo::MakeN32Premul(
                 SkScalarRoundToInt(this->width()), SkScalarRoundToInt(this->height()));
diff --git a/include/core/SkSurface.h b/include/core/SkSurface.h
index 6c85be0..4d38d30 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -82,7 +82,7 @@
     /**
      *  Return a new surface using the specified render target.
      */
-    static sk_sp<SkSurface> MakeRenderTargetDirect(GrRenderTarget*,
+    static sk_sp<SkSurface> MakeRenderTargetDirect(GrRenderTarget*, sk_sp<SkColorSpace> colorSpace,
                                                    const SkSurfaceProps* = nullptr);
 
     /**
@@ -92,7 +92,7 @@
      *  SkSurface.
      */
     static sk_sp<SkSurface> MakeFromBackendTexture(GrContext*, const GrBackendTextureDesc&,
-                                                   const SkSurfaceProps*);
+                                                   sk_sp<SkColorSpace>, const SkSurfaceProps*);
 
     /**
      *  Used to wrap a pre-existing 3D API rendering target as a SkSurface. Skia will not assume
@@ -101,6 +101,7 @@
      */
     static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext*,
                                                         const GrBackendRenderTargetDesc&,
+                                                        sk_sp<SkColorSpace>,
                                                         const SkSurfaceProps*);
 
     /**
@@ -112,7 +113,28 @@
      *  SkSurface.
      */
     static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(
-            GrContext*, const GrBackendTextureDesc&, const SkSurfaceProps*);
+        GrContext*, const GrBackendTextureDesc&, sk_sp<SkColorSpace>, const SkSurfaceProps*);
+
+    /**
+     * Legacy versions of the above factories, without color space support. These create "legacy"
+     * surfaces that operate without gamma correction or color management.
+     */
+    static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
+                                                   const SkSurfaceProps* props) {
+        return MakeFromBackendTexture(ctx, desc, nullptr, props);
+    }
+
+    static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* ctx,
+                                                        const GrBackendRenderTargetDesc& desc,
+                                                        const SkSurfaceProps* props) {
+        return MakeFromBackendRenderTarget(ctx, desc, nullptr, props);
+    }
+
+    static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(
+            GrContext* ctx, const GrBackendTextureDesc& desc, const SkSurfaceProps* props) {
+        return MakeFromBackendTextureAsRenderTarget(ctx, desc, nullptr, props);
+    }
+
 
     /**
      *  Return a new surface whose contents will be drawn to an offscreen
@@ -149,7 +171,7 @@
         return NewRaster(SkImageInfo::MakeN32Premul(width, height), props);
     }
     static SkSurface* NewRenderTargetDirect(GrRenderTarget* rt, const SkSurfaceProps* props) {
-        return MakeRenderTargetDirect(rt, props).release();
+        return MakeRenderTargetDirect(rt, nullptr, props).release();
     }
     static SkSurface* NewRenderTargetDirect(GrRenderTarget* target) {
         return NewRenderTargetDirect(target, NULL);
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 3a57cd8..b156ba6 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -189,7 +189,8 @@
      *
      * @return a draw context
      */
-    sk_sp<GrDrawContext> drawContext(sk_sp<GrRenderTarget> rt, const SkSurfaceProps* = nullptr);
+    sk_sp<GrDrawContext> drawContext(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpace> colorSpace,
+                                     const SkSurfaceProps* = nullptr);
 
     /**
      * Create both a GrRenderTarget and a matching GrDrawContext to wrap it.
@@ -199,6 +200,7 @@
     sk_sp<GrDrawContext> newDrawContext(SkBackingFit fit, 
                                         int width, int height,
                                         GrPixelConfig config,
+                                        sk_sp<SkColorSpace> colorSpace,
                                         int sampleCnt = 0,
                                         GrSurfaceOrigin origin = kDefault_GrSurfaceOrigin,
                                         const SkSurfaceProps* surfaceProps = nullptr,
diff --git a/include/gpu/GrDrawContext.h b/include/gpu/GrDrawContext.h
index bf9a2fd..9be0f3cc 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -272,6 +272,7 @@
     int numColorSamples() const { return fRenderTarget->numColorSamples(); }
     bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); }
     const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; }
+    SkColorSpace* getColorSpace() const { return fColorSpace.get(); }
 
     bool wasAbandoned() const;
 
@@ -288,7 +289,7 @@
     GrAuditTrail* auditTrail() { return fAuditTrail; }
 
 protected:
-    GrDrawContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTarget>,
+    GrDrawContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTarget>, sk_sp<SkColorSpace>,
                   const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwner*);
 
     GrDrawingManager* drawingManager() { return fDrawingManager; }
@@ -362,6 +363,7 @@
     GrContext*                        fContext;
     GrInstancedPipelineInfo           fInstancedPipelineInfo;
 
+    sk_sp<SkColorSpace>               fColorSpace;
     SkSurfaceProps                    fSurfaceProps;
     GrAuditTrail*                     fAuditTrail;
 
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 7afaa96..a02a360 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -297,7 +297,9 @@
                 return SkSurface::MakeRenderTarget(fCurContext, SkBudgeted::kNo, win->info(),
                                                    fMSAASampleCount, &props).release();
             } else {
-                return SkSurface::MakeRenderTargetDirect(fCurRenderTarget, &props).release();
+                return SkSurface::MakeRenderTargetDirect(fCurRenderTarget,
+                                                         sk_ref_sp(win->info().colorSpace()),
+                                                         &props).release();
             }
         }
 #endif
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 18ebcc8..4927825 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -283,7 +283,8 @@
 
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
                                                              bounds.width(), bounds.height(),
-                                                             kRGBA_8888_GrPixelConfig));
+                                                             kRGBA_8888_GrPixelConfig,
+                                                             std::move(colorSpace)));
     if (!drawContext) {
         return nullptr;
     }
@@ -294,9 +295,9 @@
     GrFixedClip clip(dstIRect);
     drawContext->fillRectToRect(clip, paint, SkMatrix::I(), dstRect, srcRect);
 
-    // TODO: Get the colorSpace from the drawContext (once it has one)
     return SkSpecialImage::MakeFromGpu(dstIRect, kNeedNewImageUniqueID_SpecialImage,
-                                       drawContext->asTexture(), std::move(colorSpace));
+                                       drawContext->asTexture(),
+                                       sk_ref_sp(drawContext->getColorSpace()));
 }
 #endif
 
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index d6fbd2a..d01e485 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -391,7 +391,7 @@
 
         return SkSpecialSurface::MakeRenderTarget(fTexture->getContext(),
                                                   info.width(), info.height(),
-                                                  config);
+                                                  config, sk_ref_sp(info.colorSpace()));
     }
 
     sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index b339c27..02f54d8 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -155,13 +155,15 @@
 
 sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
                                                            int width, int height,
-                                                           GrPixelConfig config) {
+                                                           GrPixelConfig config,
+                                                           sk_sp<SkColorSpace> colorSpace) {
     if (!context) {
         return nullptr;
     }
 
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
-                                                             width, height, config));
+                                                             width, height, config,
+                                                             std::move(colorSpace)));
     if (!drawContext) {
         return nullptr;
     }
diff --git a/src/core/SkSpecialSurface.h b/src/core/SkSpecialSurface.h
index d971648..2aa03dd 100644
--- a/src/core/SkSpecialSurface.h
+++ b/src/core/SkSpecialSurface.h
@@ -57,7 +57,8 @@
      */
     static sk_sp<SkSpecialSurface> MakeRenderTarget(GrContext*,
                                                     int width, int height,
-                                                    GrPixelConfig config);
+                                                    GrPixelConfig config,
+                                                    sk_sp<SkColorSpace> colorSpace);
 #endif
 
     /**
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 67ede53..f2b7430 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -104,7 +104,7 @@
 
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
                                                              bounds.width(), bounds.height(),
-                                                             config));
+                                                             config, nullptr));
     if (!drawContext) {
         return nullptr;
     }
diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp
index d98f105..23fb2cb 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -121,13 +121,14 @@
         inputBounds.offset(-inputOffset);
         dstBounds.offset(-inputOffset);
         sk_sp<GrDrawContext> drawContext(SkGpuBlurUtils::GaussianBlur(
-                                                                  context,
-                                                                  inputTexture.get(),
-                                                                  source->props().isGammaCorrect(),
-                                                                  dstBounds,
-                                                                  &inputBounds,
-                                                                  sigma.x(),
-                                                                  sigma.y()));
+                                                                context,
+                                                                inputTexture.get(),
+                                                                sk_ref_sp(source->getColorSpace()),
+                                                                source->props().isGammaCorrect(),
+                                                                dstBounds,
+                                                                &inputBounds,
+                                                                sigma.x(),
+                                                                sigma.y()));
         if (!drawContext) {
             return nullptr;
         }
diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp
index b7893c5..76f446c 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -1248,7 +1248,7 @@
     static const bool kIsGammaCorrect = false;
     bool isNormalBlur = (kNormal_SkBlurStyle == fBlurStyle);
     sk_sp<GrDrawContext> drawContext(SkGpuBlurUtils::GaussianBlur(context, src,
-                                                                  kIsGammaCorrect,
+                                                                  nullptr, kIsGammaCorrect,
                                                                   clipRect, nullptr,
                                                                   xformedSigma, xformedSigma));
     if (!drawContext) {
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index 392ac43..9370a9f 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -335,9 +335,9 @@
         SkMatrix matrix;
         matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
 
-        sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
-                                                                 bounds.width(), bounds.height(),
-                                                                 kSkia8888_GrPixelConfig));
+        sk_sp<GrDrawContext> drawContext(
+            context->newDrawContext(SkBackingFit::kApprox, bounds.width(), bounds.height(),
+                                    kSkia8888_GrPixelConfig, sk_ref_sp(source->getColorSpace())));
         if (!drawContext) {
             return nullptr;
         }
@@ -346,11 +346,10 @@
 
         offset->fX = bounds.left();
         offset->fY = bounds.top();
-        // TODO: Get the colorSpace from the drawContext (once it has one)
         return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()),
                                            kNeedNewImageUniqueID_SpecialImage,
                                            drawContext->asTexture(),
-                                           sk_ref_sp(source->getColorSpace()));
+                                           sk_ref_sp(drawContext->getColorSpace()));
     }
 #endif
 
diff --git a/src/effects/SkGpuBlurUtils.cpp b/src/effects/SkGpuBlurUtils.cpp
index f0f684d..02629f7 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -182,6 +182,7 @@
 
 sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
                                   GrTexture* origSrc,
+                                  sk_sp<SkColorSpace> colorSpace,
                                   bool gammaCorrect,
                                   const SkIRect& dstBounds,
                                   const SkIRect* srcBounds,
@@ -230,7 +231,7 @@
                                SkSurfaceProps::kLegacyFontHost_InitType);
 
     sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit::kApprox,
-                                                                width, height, config,
+                                                                width, height, config, colorSpace,
                                                                 0, kDefault_GrSurfaceOrigin,
                                                                 &props));
     if (!dstDrawContext) {
@@ -251,7 +252,7 @@
     } 
 
     sk_sp<GrDrawContext> tmpDrawContext(context->newDrawContext(SkBackingFit::kApprox,
-                                                                width, height, config,
+                                                                width, height, config, colorSpace,
                                                                 0, kDefault_GrSurfaceOrigin,
                                                                 &props));
     if (!tmpDrawContext) {
diff --git a/src/effects/SkGpuBlurUtils.h b/src/effects/SkGpuBlurUtils.h
index 4f80fc3..550f3b8 100644
--- a/src/effects/SkGpuBlurUtils.h
+++ b/src/effects/SkGpuBlurUtils.h
@@ -23,6 +23,7 @@
     * Note: one of sigmaX and sigmaY should be non-zero!
     * @param context         The GPU context
     * @param srcTexture      The source texture to be blurred.
+    * @param colorSpace      Color space of the source (used for the drawContext result, too).
     * @param gammaCorrect    Should blur be gamma-correct (sRGB to linear, etc...)
     * @param dstBounds       The destination bounds, relative to the source texture.
     * @param srcBounds       The source bounds, relative to the source texture. If non-null,
@@ -33,6 +34,7 @@
     */
     sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
                                       GrTexture* srcTexture,
+                                      sk_sp<SkColorSpace> colorSpace,
                                       bool gammaCorrect,
                                       const SkIRect& dstBounds,
                                       const SkIRect* srcBounds,
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 7de86fb..ebe80b0 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -411,7 +411,8 @@
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
                                                              offsetBounds.width(),
                                                              offsetBounds.height(),
-                                                             kRGBA_8888_GrPixelConfig));
+                                                             kRGBA_8888_GrPixelConfig,
+                                                             sk_ref_sp(source->getColorSpace())));
     if (!drawContext) {
         return nullptr;
     }
@@ -453,11 +454,10 @@
     this->drawRect(drawContext.get(), inputTexture.get(), matrix, clip, bottomRight,
                    kBottomRight_BoundaryMode, pSrcBounds, offsetBounds);
 
-    // TODO: Get the colorSpace from the drawContext (once it has one)
     return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(offsetBounds.width(), offsetBounds.height()),
                                        kNeedNewImageUniqueID_SpecialImage,
                                        drawContext->asTexture(),
-                                       sk_ref_sp(source->getColorSpace()));
+                                       sk_ref_sp(drawContext->getColorSpace()));
 }
 #endif
 
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 5d4b58c..7e27249 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -474,6 +474,7 @@
                                               SkISize radius) {
     sk_sp<GrTexture> srcTexture(input->asTextureRef(context));
     SkASSERT(srcTexture);
+    sk_sp<SkColorSpace> colorSpace = sk_ref_sp(input->getColorSpace());
 
     // setup new clip
     const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->height()));
@@ -486,7 +487,8 @@
     if (radius.fWidth > 0) {
         sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit::kApprox,
                                                                     rect.width(), rect.height(),
-                                                                    kSkia8888_GrPixelConfig));
+                                                                    kSkia8888_GrPixelConfig,
+                                                                    colorSpace));
         if (!dstDrawContext) {
             return nullptr;
         }
@@ -507,7 +509,8 @@
     if (radius.fHeight > 0) {
         sk_sp<GrDrawContext> dstDrawContext(context->newDrawContext(SkBackingFit::kApprox,
                                                                     rect.width(), rect.height(),
-                                                                    kSkia8888_GrPixelConfig));
+                                                                    kSkia8888_GrPixelConfig,
+                                                                    colorSpace));
         if (!dstDrawContext) {
             return nullptr;
         }
@@ -519,10 +522,9 @@
         srcTexture = dstDrawContext->asTexture();
     }
 
-    // TODO: Get the colorSpace from the drawContext (once it has one)
     return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(rect.width(), rect.height()),
                                        kNeedNewImageUniqueID_SpecialImage,
-                                       std::move(srcTexture), sk_ref_sp(input->getColorSpace()),
+                                       std::move(srcTexture), std::move(colorSpace),
                                        &input->props());
 }
 #endif
diff --git a/src/effects/SkXfermodeImageFilter.cpp b/src/effects/SkXfermodeImageFilter.cpp
index 0102538..6c3298d 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -243,7 +243,8 @@
 
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
                                                              bounds.width(), bounds.height(),
-                                                             kSkia8888_GrPixelConfig));
+                                                             kSkia8888_GrPixelConfig,
+                                                             sk_ref_sp(source->getColorSpace())));
     if (!drawContext) {
         return nullptr;
     }
@@ -252,11 +253,10 @@
     matrix.setTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
     drawContext->drawRect(GrNoClip(), paint, matrix, SkRect::Make(bounds));
 
-    // TODO: Get the colorSpace from the drawContext (once it has one)
     return SkSpecialImage::MakeFromGpu(SkIRect::MakeWH(bounds.width(), bounds.height()),
                                        kNeedNewImageUniqueID_SpecialImage,
                                        drawContext->asTexture(),
-                                       sk_ref_sp(source->getColorSpace()));
+                                       sk_ref_sp(drawContext->getColorSpace()));
 }
 
 #endif
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 3ad225b..f6d6fc2 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -113,6 +113,7 @@
                                                              maskRect.width(), 
                                                              maskRect.height(),
                                                              config,
+                                                             nullptr,
                                                              sampleCnt));
     if (!drawContext) {
         return nullptr;
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 77d5ea1..6e2a303 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -474,7 +474,7 @@
     sk_sp<GrDrawContext> dc(context->newDrawContext(SkBackingFit::kApprox,
                                                     clipSpaceIBounds.width(),
                                                     clipSpaceIBounds.height(),
-                                                    config));
+                                                    config, nullptr));
     if (!dc) {
         return nullptr;
     }
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 4cb90c6..6bb3ea6 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -357,7 +357,10 @@
             }
             SkMatrix matrix;
             matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
-            sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(renderTarget)));
+            // TODO: Need to decide the semantics of this function for color spaces. Do we support
+            // conversion from a passed-in color space? For now, specifying nullptr means that this
+            // path will do no conversion, so it will match the behavior of the non-draw path.
+            sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(renderTarget), nullptr));
             if (!drawContext) {
                 return false;
             }
@@ -444,10 +447,14 @@
                 tempDrawInfo.fTempSurfaceFit= SkBackingFit::kApprox;
             }
         }
+        // TODO: Need to decide the semantics of this function for color spaces. Do we support
+        // conversion to a passed-in color space? For now, specifying nullptr means that this
+        // path will do no conversion, so it will match the behavior of the non-draw path.
         sk_sp<GrDrawContext> tempDC = this->newDrawContext(tempDrawInfo.fTempSurfaceFit,
                                                            tempDrawInfo.fTempSurfaceDesc.fWidth,
                                                            tempDrawInfo.fTempSurfaceDesc.fHeight,
                                                            tempDrawInfo.fTempSurfaceDesc.fConfig,
+                                                           nullptr,
                                                            tempDrawInfo.fTempSurfaceDesc.fSampleCnt,
                                                            tempDrawInfo.fTempSurfaceDesc.fOrigin);
         if (tempDC) {
@@ -534,7 +541,8 @@
 
     SkSurfaceProps props(SkSurfaceProps::kGammaCorrect_Flag,
                          SkSurfaceProps::kLegacyFontHost_InitType);
-    sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst), &props));
+    // TODO: Supply color space?
+    sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst), nullptr, &props));
     if (!drawContext) {
         return false;
     }
@@ -596,7 +604,7 @@
         src->flushWrites();
         return fGpu->copySurface(dst, src, clippedSrcRect, clippedDstPoint);
     }
-    sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst->asRenderTarget())));
+    sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(dst->asRenderTarget()), nullptr));
     if (!drawContext) {
         return false;
     }
@@ -636,14 +644,16 @@
 
 
 sk_sp<GrDrawContext> GrContext::drawContext(sk_sp<GrRenderTarget> rt,
+                                            sk_sp<SkColorSpace> colorSpace,
                                             const SkSurfaceProps* surfaceProps) {
     ASSERT_SINGLE_OWNER
-    return fDrawingManager->drawContext(std::move(rt), surfaceProps);
+    return fDrawingManager->drawContext(std::move(rt), std::move(colorSpace), surfaceProps);
 }
 
 sk_sp<GrDrawContext> GrContext::newDrawContext(SkBackingFit fit,
                                                int width, int height,
                                                GrPixelConfig config,
+                                               sk_sp<SkColorSpace> colorSpace,
                                                int sampleCnt,
                                                GrSurfaceOrigin origin,
                                                const SkSurfaceProps* surfaceProps,
@@ -667,7 +677,7 @@
     }
 
     sk_sp<GrDrawContext> drawContext(this->drawContext(sk_ref_sp(tex->asRenderTarget()),
-                                                       surfaceProps));
+                                                       std::move(colorSpace), surfaceProps));
     if (!drawContext) {
         return nullptr;
     }
diff --git a/src/gpu/GrDrawContext.cpp b/src/gpu/GrDrawContext.cpp
index 52f7fc0..9a647c0 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -69,6 +69,7 @@
 GrDrawContext::GrDrawContext(GrContext* context,
                              GrDrawingManager* drawingMgr,
                              sk_sp<GrRenderTarget> rt,
+                             sk_sp<SkColorSpace> colorSpace,
                              const SkSurfaceProps* surfaceProps,
                              GrAuditTrail* auditTrail,
                              GrSingleOwner* singleOwner)
@@ -77,6 +78,7 @@
     , fDrawTarget(SkSafeRef(fRenderTarget->getLastDrawTarget()))
     , fContext(context)
     , fInstancedPipelineInfo(fRenderTarget.get())
+    , fColorSpace(std::move(colorSpace))
     , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
     , fAuditTrail(auditTrail)
 #ifdef SK_DEBUG
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index 75ee0db..5dc07dd 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -175,6 +175,7 @@
 }
 
 sk_sp<GrDrawContext> GrDrawingManager::drawContext(sk_sp<GrRenderTarget> rt,
+                                                   sk_sp<SkColorSpace> colorSpace,
                                                    const SkSurfaceProps* surfaceProps) {
     if (this->wasAbandoned()) {
         return nullptr;
@@ -191,13 +192,14 @@
         GrStencilAttachment* sb = fContext->resourceProvider()->attachStencilAttachment(rt.get());
         if (sb) {
             return sk_sp<GrDrawContext>(new GrPathRenderingDrawContext(
-                                                        fContext, this, std::move(rt), 
-                                                        surfaceProps,
+                                                        fContext, this, std::move(rt),
+                                                        std::move(colorSpace), surfaceProps,
                                                         fContext->getAuditTrail(), fSingleOwner));
         }
     }
 
-    return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt), surfaceProps,
+    return sk_sp<GrDrawContext>(new GrDrawContext(fContext, this, std::move(rt),
+                                                  std::move(colorSpace), surfaceProps,
                                                   fContext->getAuditTrail(),
                                                   fSingleOwner));
 }
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index fa644b5..d777242 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -31,7 +31,8 @@
     bool wasAbandoned() const { return fAbandoned; }
     void freeGpuResources();
 
-    sk_sp<GrDrawContext> drawContext(sk_sp<GrRenderTarget> rt, const SkSurfaceProps*);
+    sk_sp<GrDrawContext> drawContext(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpace> colorSpace,
+                                     const SkSurfaceProps*);
 
     // The caller automatically gets a ref on the returned drawTarget. It must
     // be balanced by an unref call.
diff --git a/src/gpu/GrPathRenderingDrawContext.h b/src/gpu/GrPathRenderingDrawContext.h
index 5d1893c..5c1a968 100644
--- a/src/gpu/GrPathRenderingDrawContext.h
+++ b/src/gpu/GrPathRenderingDrawContext.h
@@ -27,9 +27,9 @@
                       SkDrawFilter*, const SkIRect& clipBounds) override;
 protected:
     GrPathRenderingDrawContext(GrContext* ctx, GrDrawingManager* mgr, sk_sp<GrRenderTarget> rt,
-                               const SkSurfaceProps* surfaceProps, GrAuditTrail* at,
-                               GrSingleOwner* so)
-        : INHERITED(ctx, mgr, std::move(rt), surfaceProps, at, so) {}
+                               sk_sp<SkColorSpace> colorSpace, const SkSurfaceProps* surfaceProps,
+                               GrAuditTrail* at, GrSingleOwner* so)
+        : INHERITED(ctx, mgr, std::move(rt), std::move(colorSpace), surfaceProps, at, so) {}
 
 private:
     SkAutoTDelete<GrStencilAndCoverTextContext> fStencilAndCoverTextContext;
diff --git a/src/gpu/GrRenderTarget.cpp b/src/gpu/GrRenderTarget.cpp
index 6a9d489..9eba180 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -29,7 +29,7 @@
         return;
     }
 
-    sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(this)));
+    sk_sp<GrDrawContext> drawContext(context->drawContext(sk_ref_sp(this), nullptr));
     if (!drawContext) {
         return;
     }
diff --git a/src/gpu/GrTextureParamsAdjuster.cpp b/src/gpu/GrTextureParamsAdjuster.cpp
index fe81bea..e077fee 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -61,7 +61,7 @@
     }
 
     sk_sp<GrDrawContext> copyDC = context->newDrawContext(SkBackingFit::kExact, copyParams.fWidth,
-                                                          copyParams.fHeight, config);
+                                                          copyParams.fHeight, config, nullptr);
     if (!copyDC) {
         return nullptr;
     }
diff --git a/src/gpu/GrTextureToYUVPlanes.cpp b/src/gpu/GrTextureToYUVPlanes.cpp
index da98547..25a79e4 100644
--- a/src/gpu/GrTextureToYUVPlanes.cpp
+++ b/src/gpu/GrTextureToYUVPlanes.cpp
@@ -71,14 +71,14 @@
         if (sizes[0] == sizes[1] && sizes[1] == sizes[2]) {
             yuvDrawContext = context->newDrawContext(SkBackingFit::kApprox,
                                                      sizes[0].fWidth, sizes[0].fHeight,
-                                                     kRGBA_8888_GrPixelConfig);
+                                                     kRGBA_8888_GrPixelConfig, nullptr);
             if (!yuvDrawContext) {
                 return false;
             }
         } else {
             yDrawContext = context->newDrawContext(SkBackingFit::kApprox,
                                                    sizes[0].fWidth, sizes[0].fHeight,
-                                                   singleChannelPixelConfig);
+                                                   singleChannelPixelConfig, nullptr);
             if (!yDrawContext) {
                 return false;
             }
@@ -86,17 +86,17 @@
                 // TODO: Add support for GL_RG when available.
                 uvDrawContext = context->newDrawContext(SkBackingFit::kApprox,
                                                         sizes[1].fWidth, sizes[1].fHeight,
-                                                        kRGBA_8888_GrPixelConfig);
+                                                        kRGBA_8888_GrPixelConfig, nullptr);
                 if (!uvDrawContext) {
                     return false;
                 }
             } else {
                 uDrawContext = context->newDrawContext(SkBackingFit::kApprox,
                                                        sizes[1].fWidth, sizes[1].fHeight,
-                                                       singleChannelPixelConfig);
+                                                       singleChannelPixelConfig, nullptr);
                 vDrawContext = context->newDrawContext(SkBackingFit::kApprox,
                                                        sizes[2].fWidth, sizes[2].fHeight,
-                                                       singleChannelPixelConfig);
+                                                       singleChannelPixelConfig, nullptr);
                 if (!uDrawContext || !vDrawContext) {
                     return false;
                 }
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index c35f57a..e9b2ef5 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -113,9 +113,11 @@
             }
     }
 
+    // We never want to perform color-space conversion during the decode
     sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact,
                                                          desc.fWidth, desc.fHeight,
-                                                         desc.fConfig, desc.fSampleCnt));
+                                                         desc.fConfig, nullptr,
+                                                         desc.fSampleCnt));
     if (!drawContext) {
         return nullptr;
     }
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 2b4c084..20e5afe 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -126,8 +126,8 @@
     return true;
 }
 
-sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, const SkSurfaceProps* props,
-                                     InitContents init) {
+sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, sk_sp<SkColorSpace> colorSpace,
+                                     const SkSurfaceProps* props, InitContents init) {
     if (!rt || rt->wasDestroyed() || !rt->getContext()) {
         return nullptr;
     }
@@ -141,7 +141,8 @@
 
     GrContext* context = rt->getContext();
 
-    sk_sp<GrDrawContext> drawContext(context->drawContext(std::move(rt), props));
+    sk_sp<GrDrawContext> drawContext(context->drawContext(std::move(rt), std::move(colorSpace),
+                                                          props));
     return sk_sp<SkGpuDevice>(new SkGpuDevice(std::move(drawContext), width, height, flags));
 }
 
@@ -223,7 +224,7 @@
 
     return context->newDrawContext(SkBackingFit::kExact,               // Why exact?
                                    origInfo.width(), origInfo.height(),
-                                   config, sampleCount,
+                                   config, sk_ref_sp(cs), sampleCount,
                                    kDefault_GrSurfaceOrigin, surfaceProps, budgeted);
 }
 
@@ -1842,6 +1843,7 @@
     sk_sp<GrDrawContext> dc(fContext->newDrawContext(fit,
                                                      cinfo.fInfo.width(), cinfo.fInfo.height(),
                                                      fDrawContext->config(),
+                                                     sk_ref_sp(fDrawContext->getColorSpace()),
                                                      fDrawContext->desc().fSampleCnt,
                                                      kDefault_GrSurfaceOrigin,
                                                      &props));
diff --git a/src/gpu/SkGpuDevice.h b/src/gpu/SkGpuDevice.h
index d341b39..8111759 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -42,7 +42,8 @@
      *       MakeFromBackendTexture, MakeFromBackendRenderTarget,
      *       and MakeFromBackendTextureAsRenderTarget. Only the first is worrisome.
      */
-    static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target, 
+    static sk_sp<SkGpuDevice> Make(sk_sp<GrRenderTarget> target,
+                                   sk_sp<SkColorSpace> colorSpace,
                                    const SkSurfaceProps*,
                                    InitContents);
 
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 5294492..f41e154 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -174,9 +174,9 @@
     }
 
     sk_sp<GrDrawContext> readDC(context->newDrawContext(SkBackingFit::kExact, kSize, kSize,
-                                                        kConfig));
+                                                        kConfig, nullptr));
     sk_sp<GrDrawContext> tempDC(context->newDrawContext(SkBackingFit::kExact, kSize, kSize,
-                                                        kConfig));
+                                                        kConfig, nullptr));
     if (!readDC || !tempDC) {
         return;
     }
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 9e10dab..fa697cd 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -245,6 +245,7 @@
     sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact,
                                                          width, height,
                                                          kRGBA_8888_GrPixelConfig,
+                                                         std::move(imageColorSpace),
                                                          0,
                                                          origin));
     if (!drawContext) {
@@ -262,7 +263,7 @@
     ctx->flushSurfaceWrites(drawContext->accessRenderTarget());
     return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID,
                                    kOpaque_SkAlphaType, drawContext->asTexture().get(),
-                                   std::move(imageColorSpace), budgeted);
+                                   sk_ref_sp(drawContext->getColorSpace()), budgeted);
 }
 
 sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx, SkYUVColorSpace colorSpace,
diff --git a/src/image/SkSurface.cpp b/src/image/SkSurface.cpp
index 8f6e308..2035e4c 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -223,7 +223,8 @@
 
 #if !SK_SUPPORT_GPU
 
-sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget*, const SkSurfaceProps*) {
+sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget*, sk_sp<SkColorSpace>,
+                                                   const SkSurfaceProps*) {
     return nullptr;
 }
 
@@ -233,18 +234,19 @@
 }
 
 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext*, const GrBackendTextureDesc&,
-                                                   const SkSurfaceProps*) {
+                                                   sk_sp<SkColorSpace>, const SkSurfaceProps*) {
     return nullptr;
 }
 
 sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext*,
                                                         const GrBackendRenderTargetDesc&,
+                                                        sk_sp<SkColorSpace>,
                                                         const SkSurfaceProps*) {
     return nullptr;
 }
 
 sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext*, const GrBackendTextureDesc&,
-                                                      const SkSurfaceProps*) {
+                                                      sk_sp<SkColorSpace>, const SkSurfaceProps*) {
     return nullptr;
 }
 
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 8d5601d..ef8dd5f 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -132,9 +132,11 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 sk_sp<SkSurface> SkSurface::MakeRenderTargetDirect(GrRenderTarget* target,
+                                                   sk_sp<SkColorSpace> colorSpace,
                                                    const SkSurfaceProps* props) {
     sk_sp<SkGpuDevice> device(
-        SkGpuDevice::Make(sk_ref_sp(target), props, SkGpuDevice::kUninit_InitContents));
+        SkGpuDevice::Make(sk_ref_sp(target), std::move(colorSpace), props,
+                          SkGpuDevice::kUninit_InitContents));
     if (!device) {
         return nullptr;
     }
@@ -154,6 +156,7 @@
 
 sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
                                                    const GrBackendTextureDesc& desc,
+                                                   sk_sp<SkColorSpace> colorSpace,
                                                    const SkSurfaceProps* props) {
     if (nullptr == context) {
         return nullptr;
@@ -166,7 +169,8 @@
     if (!surface) {
         return nullptr;
     }
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(sk_ref_sp(surface->asRenderTarget()), props,
+    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(sk_ref_sp(surface->asRenderTarget()),
+                                                std::move(colorSpace), props,
                                                 SkGpuDevice::kUninit_InitContents));
     if (!device) {
         return nullptr;
@@ -176,6 +180,7 @@
 
 sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
                                                         const GrBackendRenderTargetDesc& desc,
+                                                        sk_sp<SkColorSpace> colorSpace,
                                                         const SkSurfaceProps* props) {
     if (!context) {
         return nullptr;
@@ -184,7 +189,7 @@
     if (!rt) {
         return nullptr;
     }
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props,
+    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSpace), props,
                                                 SkGpuDevice::kUninit_InitContents));
     if (!device) {
         return nullptr;
@@ -194,6 +199,7 @@
 
 sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* context,
                                                                  const GrBackendTextureDesc& desc,
+                                                                 sk_sp<SkColorSpace> colorSpace,
                                                                  const SkSurfaceProps* props) {
     if (!context) {
         return nullptr;
@@ -202,7 +208,7 @@
     if (!rt) {
         return nullptr;
     }
-    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), props,
+    sk_sp<SkGpuDevice> device(SkGpuDevice::Make(std::move(rt), std::move(colorSpace), props,
                                                 SkGpuDevice::kUninit_InitContents));
     if (!device) {
         return nullptr;
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 64464aa..4afbaba 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -45,7 +45,7 @@
     }
     context->freeGpuResources();
 
-    *dc = context->newDrawContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig);
+    *dc = context->newDrawContext(SkBackingFit::kExact, w, h, kRGBA_8888_GrPixelConfig, nullptr);
 
     SkASSERT((*dc)->accessRenderTarget()->getUniqueID() != oldID);
 
diff --git a/tests/DFPathRendererTest.cpp b/tests/DFPathRendererTest.cpp
index ad6e022..e1af6ac 100644
--- a/tests/DFPathRendererTest.cpp
+++ b/tests/DFPathRendererTest.cpp
@@ -66,6 +66,7 @@
     sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBackingFit::kApprox,
                                                                          800, 800,
                                                                          kSkia8888_GrPixelConfig,
+                                                                         nullptr,
                                                                          0,
                                                                          kTopLeft_GrSurfaceOrigin));
     if (!drawContext) {
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 16a2592..393de53 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -158,6 +158,7 @@
                                                              kRenderTargetWidth,
                                                              kRenderTargetHeight,
                                                              kRGBA_8888_GrPixelConfig,
+                                                             nullptr,
                                                              sampleCnt,
                                                              origin));
     return drawContext;
@@ -345,7 +346,8 @@
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kExact,
                                                              kRenderTargetWidth,
                                                              kRenderTargetHeight,
-                                                             kRGBA_8888_GrPixelConfig));
+                                                             kRGBA_8888_GrPixelConfig,
+                                                             nullptr));
     if (!drawContext) {
         SkDebugf("Could not allocate a drawContext");
         return false;
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index f46519d..65ea8cf 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -367,7 +367,7 @@
     if (context) {
         return SkSpecialSurface::MakeRenderTarget(context,
                                                   widthHeight, widthHeight,
-                                                  kSkia8888_GrPixelConfig);
+                                                  kSkia8888_GrPixelConfig, nullptr);
     } else
 #endif
     {
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index f121079..acaf9e9 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -105,7 +105,8 @@
     GrContext* context = ctxInfo.grContext();
 
     sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,
-                                                             1, 1, kRGBA_8888_GrPixelConfig));
+                                                             1, 1, kRGBA_8888_GrPixelConfig,
+                                                             nullptr));
     if (!drawContext) {
         ERRORF(reporter, "Could not create draw context.");
         return;
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 6b6778d..6aebe6e 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -397,7 +397,7 @@
         desc.fOrigin = origin;
         SkAutoTUnref<GrTexture> surfaceTexture(
             ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudgeted::kNo));
-        auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderTarget()));
+        auto surface(SkSurface::MakeRenderTargetDirect(surfaceTexture->asRenderTarget(), nullptr));
         desc.fFlags = kNone_GrSurfaceFlags;
         test_readpixels(reporter, surface, kLast_BitmapInit);
     }
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 630924a..16f43ea 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -93,7 +93,8 @@
 
             // Now try writing on the single channel texture (if we could create as a RT).
             if (texture->asRenderTarget()) {
-                sk_sp<SkSurface> surf(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget()));
+                sk_sp<SkSurface> surf(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget(),
+                                                                        nullptr));
                 SkCanvas* canvas = surf->getCanvas();
 
                 SkPaint paint;
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 2fa51e2..b42b3ba 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -90,7 +90,8 @@
                        GrTexture* rectangleTexture) {
     if (rectangleTexture->asRenderTarget()) {
         sk_sp<GrDrawContext> dc(
-                            context->drawContext(sk_ref_sp(rectangleTexture->asRenderTarget())));
+                            context->drawContext(sk_ref_sp(rectangleTexture->asRenderTarget()),
+                                                 nullptr));
         if (!dc) {
             ERRORF(reporter, "Could not get GrDrawContext for rectangle texture.");
             return;
diff --git a/tests/SRGBMipMapTest.cpp b/tests/SRGBMipMapTest.cpp
index 1e62f88..f798119 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -123,12 +123,17 @@
     SkSurfaceProps l32Props(SkSurfaceProps::kLegacyFontHost_InitType);
     SkSurfaceProps s32Props(SkSurfaceProps::kGammaCorrect_Flag,
                             SkSurfaceProps::kLegacyFontHost_InitType);
+    sk_sp<SkColorSpace> srgbColorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
     sk_sp<GrDrawContext> l32DrawContext = context->newDrawContext(SkBackingFit::kExact, rtS, rtS,
-                                                                  kSkia8888_GrPixelConfig, 0,
+                                                                  kSkia8888_GrPixelConfig,
+                                                                  nullptr,
+                                                                  0,
                                                                   kDefault_GrSurfaceOrigin,
                                                                   &l32Props);
     sk_sp<GrDrawContext> s32DrawContext = context->newDrawContext(SkBackingFit::kExact, rtS, rtS,
-                                                                  kSkiaGamma8888_GrPixelConfig, 0,
+                                                                  kSkiaGamma8888_GrPixelConfig,
+                                                                  std::move(srgbColorSpace),
+                                                                  0,
                                                                   kDefault_GrSurfaceOrigin,
                                                                   &s32Props);
 
diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp
index 2bb1005..a0ec317 100644
--- a/tests/SpecialSurfaceTest.cpp
+++ b/tests/SpecialSurfaceTest.cpp
@@ -81,7 +81,8 @@
 DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, ctxInfo) {
     sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(),
                                                                     kSmallerSize, kSmallerSize,
-                                                                    kSkia8888_GrPixelConfig));
+                                                                    kSkia8888_GrPixelConfig,
+                                                                    nullptr));
 
     test_surface(surf, reporter, 0);
 }
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 16db3e3..8d2ba51 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -337,7 +337,7 @@
         desc.fTextureHandle = textureObject;
         GrTexture* texture = context->textureProvider()->wrapBackendTexture(desc);
         {
-            auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget()));
+            auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget(), nullptr));
             test_unique_image_snap(reporter, surface.get(), true, imageBackingStore,
                                    surfaceBackingStore);
         }
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index 80e65cd..5e8d952 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -257,6 +257,7 @@
     sk_sp<GrDrawContext> drawContext(ctxInfo.grContext()->newDrawContext(SkBackingFit::kApprox,
                                                                          800, 800,
                                                                          kSkia8888_GrPixelConfig,
+                                                                         nullptr,
                                                                          0,
                                                                          kTopLeft_GrSurfaceOrigin));
     if (!drawContext) {
diff --git a/tests/WritePixelsTest.cpp b/tests/WritePixelsTest.cpp
index 90f5d80..ec88f03 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -416,7 +416,7 @@
         desc.fOrigin = origin;
         SkAutoTUnref<GrTexture> texture(
             ctxInfo.grContext()->textureProvider()->createTexture(desc, SkBudgeted::kNo));
-        auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget()));
+        auto surface(SkSurface::MakeRenderTargetDirect(texture->asRenderTarget(), nullptr));
         test_write_pixels(reporter, surface.get());
     }
 }