aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar brianosman <brianosman@google.com>2016-07-21 13:28:36 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-07-21 13:28:36 -0700
commitdfe4f2e4fe5b162d4adb4486fe751f1e3b30bea7 (patch)
treeaa6ff74a25306386a0c5b5586a4843b470d80101
parent8602ede5fdfa721dcad4dcb11db028c1c24265f1 (diff)
Add SkColorSpace to GrDrawContext
-rw-r--r--example/HelloWorld.h2
-rw-r--r--include/core/SkSurface.h30
-rw-r--r--include/gpu/GrContext.h4
-rw-r--r--include/gpu/GrDrawContext.h4
-rw-r--r--samplecode/SampleApp.cpp4
-rw-r--r--src/core/SkImageFilter.cpp7
-rw-r--r--src/core/SkSpecialImage.cpp2
-rw-r--r--src/core/SkSpecialSurface.cpp6
-rw-r--r--src/core/SkSpecialSurface.h3
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp2
-rw-r--r--src/effects/SkBlurImageFilter.cpp15
-rw-r--r--src/effects/SkBlurMaskFilter.cpp2
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp9
-rw-r--r--src/effects/SkGpuBlurUtils.cpp5
-rw-r--r--src/effects/SkGpuBlurUtils.h2
-rw-r--r--src/effects/SkLightingImageFilter.cpp6
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp10
-rw-r--r--src/effects/SkXfermodeImageFilter.cpp6
-rw-r--r--src/gpu/GrBlurUtils.cpp1
-rw-r--r--src/gpu/GrClipMaskManager.cpp2
-rw-r--r--src/gpu/GrContext.cpp20
-rw-r--r--src/gpu/GrDrawContext.cpp2
-rw-r--r--src/gpu/GrDrawingManager.cpp8
-rw-r--r--src/gpu/GrDrawingManager.h3
-rw-r--r--src/gpu/GrPathRenderingDrawContext.h6
-rw-r--r--src/gpu/GrRenderTarget.cpp2
-rw-r--r--src/gpu/GrTextureParamsAdjuster.cpp2
-rw-r--r--src/gpu/GrTextureToYUVPlanes.cpp10
-rw-r--r--src/gpu/GrYUVProvider.cpp4
-rw-r--r--src/gpu/SkGpuDevice.cpp10
-rw-r--r--src/gpu/SkGpuDevice.h3
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp4
-rw-r--r--src/image/SkImage_Gpu.cpp3
-rw-r--r--src/image/SkSurface.cpp8
-rw-r--r--src/image/SkSurface_Gpu.cpp14
-rw-r--r--tests/ClearTest.cpp2
-rw-r--r--tests/DFPathRendererTest.cpp1
-rw-r--r--tests/GLProgramsTest.cpp4
-rw-r--r--tests/ImageFilterTest.cpp2
-rw-r--r--tests/PrimitiveProcessorTest.cpp3
-rw-r--r--tests/ReadPixelsTest.cpp2
-rw-r--r--tests/ReadWriteAlphaTest.cpp3
-rw-r--r--tests/RectangleTextureTest.cpp3
-rw-r--r--tests/SRGBMipMapTest.cpp9
-rw-r--r--tests/SpecialSurfaceTest.cpp3
-rw-r--r--tests/SurfaceTest.cpp2
-rw-r--r--tests/TessellatingPathRendererTests.cpp1
-rw-r--r--tests/WritePixelsTest.cpp2
48 files changed, 169 insertions, 89 deletions
diff --git a/example/HelloWorld.h b/example/HelloWorld.h
index 619ee7cb4d..deb56ba699 100644
--- a/example/HelloWorld.h
+++ b/example/HelloWorld.h
@@ -36,7 +36,7 @@ protected:
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 6c85be04bb..4d38d300c9 100644
--- a/include/core/SkSurface.h
+++ b/include/core/SkSurface.h
@@ -82,7 +82,7 @@ public:
/**
* 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 @@ public:
* 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 @@ public:
*/
static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext*,
const GrBackendRenderTargetDesc&,
+ sk_sp<SkColorSpace>,
const SkSurfaceProps*);
/**
@@ -112,7 +113,28 @@ public:
* 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 @@ public:
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 3a57cd8e28..b156ba6173 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -189,7 +189,8 @@ public:
*
* @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 @@ public:
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 bf9a2fd476..9be0f3ccca 100644
--- a/include/gpu/GrDrawContext.h
+++ b/include/gpu/GrDrawContext.h
@@ -272,6 +272,7 @@ public:
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 @@ public:
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 @@ private:
GrContext* fContext;
GrInstancedPipelineInfo fInstancedPipelineInfo;
+ sk_sp<SkColorSpace> fColorSpace;
SkSurfaceProps fSurfaceProps;
GrAuditTrail* fAuditTrail;
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 7afaa96972..a02a360be7 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -297,7 +297,9 @@ public:
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 18ebcc8e14..49278254c2 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -283,7 +283,8 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
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 @@ sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrContext* context,
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 d6fbd2ad2f..d01e485e83 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -391,7 +391,7 @@ public:
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 b339c27476..02f54d8eac 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -155,13 +155,15 @@ private:
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 d971648202..2aa03dd4de 100644
--- a/src/core/SkSpecialSurface.h
+++ b/src/core/SkSpecialSurface.h
@@ -57,7 +57,8 @@ public:
*/
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 67ede53b43..f2b74300db 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -104,7 +104,7 @@ sk_sp<GrTexture> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* contex
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 d98f105518..23fb2cb53d 100644
--- a/src/effects/SkBlurImageFilter.cpp
+++ b/src/effects/SkBlurImageFilter.cpp
@@ -121,13 +121,14 @@ sk_sp<SkSpecialImage> SkBlurImageFilter::onFilterImage(SkSpecialImage* source,
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 b7893c50b4..76f446c2c2 100644
--- a/src/effects/SkBlurMaskFilter.cpp
+++ b/src/effects/SkBlurMaskFilter.cpp
@@ -1248,7 +1248,7 @@ bool SkBlurMaskFilterImpl::filterMaskGPU(GrTexture* src,
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 392ac43cce..9370a9fc93 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -335,9 +335,9 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
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 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffect::onFilterImage(SkSpecialImage* sou
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 f0f684dc2d..02629f7087 100644
--- a/src/effects/SkGpuBlurUtils.cpp
+++ b/src/effects/SkGpuBlurUtils.cpp
@@ -182,6 +182,7 @@ namespace SkGpuBlurUtils {
sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
GrTexture* origSrc,
+ sk_sp<SkColorSpace> colorSpace,
bool gammaCorrect,
const SkIRect& dstBounds,
const SkIRect* srcBounds,
@@ -230,7 +231,7 @@ sk_sp<GrDrawContext> GaussianBlur(GrContext* context,
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> GaussianBlur(GrContext* context,
}
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 4f80fc3114..550f3b8d6f 100644
--- a/src/effects/SkGpuBlurUtils.h
+++ b/src/effects/SkGpuBlurUtils.h
@@ -23,6 +23,7 @@ namespace SkGpuBlurUtils {
* 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 @@ namespace SkGpuBlurUtils {
*/
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 7de86fb9c3..ebe80b0c2c 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -411,7 +411,8 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(SkSpecialIma
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 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(SkSpecialIma
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 5d4b58c880..7e27249a13 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -474,6 +474,7 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
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 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
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 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
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 @@ static sk_sp<SkSpecialImage> apply_morphology(GrContext* context,
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 010253861d..6c3298d31c 100644
--- a/src/effects/SkXfermodeImageFilter.cpp
+++ b/src/effects/SkXfermodeImageFilter.cpp
@@ -243,7 +243,8 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
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 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilter::filterImageGPU(SkSpecialImage* sour
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 3ad225bfff..f6d6fc21ca 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -113,6 +113,7 @@ static sk_sp<GrTexture> create_mask_GPU(GrContext* context,
maskRect.width(),
maskRect.height(),
config,
+ nullptr,
sampleCnt));
if (!drawContext) {
return nullptr;
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 77d5ea1d03..6e2a303844 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -474,7 +474,7 @@ sk_sp<GrTexture> GrClipMaskManager::CreateAlphaClipMask(GrContext* context,
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 4cb90c658e..6bb3ea6a2c 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -357,7 +357,10 @@ bool GrContext::writeSurfacePixels(GrSurface* surface,
}
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 @@ bool GrContext::readSurfacePixels(GrSurface* src,
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 @@ bool GrContext::applyGamma(GrRenderTarget* dst, GrTexture* src, SkScalar gamma){
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 @@ bool GrContext::copySurface(GrSurface* dst, GrSurface* src, const SkIRect& srcRe
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 @@ int GrContext::getRecommendedSampleCount(GrPixelConfig config,
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> GrContext::newDrawContext(SkBackingFit fit,
}
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 52f7fc0a35..9a647c0eab 100644
--- a/src/gpu/GrDrawContext.cpp
+++ b/src/gpu/GrDrawContext.cpp
@@ -69,6 +69,7 @@ bool GrDrawContext::wasAbandoned() const {
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 @@ GrDrawContext::GrDrawContext(GrContext* context,
, 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 75ee0db7c8..5dc07dd960 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -175,6 +175,7 @@ GrPathRenderer* GrDrawingManager::getPathRenderer(const GrPathRenderer::CanDrawP
}
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 @@ sk_sp<GrDrawContext> GrDrawingManager::drawContext(sk_sp<GrRenderTarget> rt,
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 fa644b5286..d77724265c 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -31,7 +31,8 @@ public:
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 5d1893cf90..5c1a968b17 100644
--- a/src/gpu/GrPathRenderingDrawContext.h
+++ b/src/gpu/GrPathRenderingDrawContext.h
@@ -27,9 +27,9 @@ public:
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 6a9d48997e..9eba1806c0 100644
--- a/src/gpu/GrRenderTarget.cpp
+++ b/src/gpu/GrRenderTarget.cpp
@@ -29,7 +29,7 @@ void GrRenderTarget::discard() {
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 fe81beacd6..e077fee55e 100644
--- a/src/gpu/GrTextureParamsAdjuster.cpp
+++ b/src/gpu/GrTextureParamsAdjuster.cpp
@@ -61,7 +61,7 @@ static GrTexture* copy_on_gpu(GrTexture* inputTexture, const SkIRect* subset,
}
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 da98547d97..25a79e42f3 100644
--- a/src/gpu/GrTextureToYUVPlanes.cpp
+++ b/src/gpu/GrTextureToYUVPlanes.cpp
@@ -71,14 +71,14 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
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 @@ bool GrTextureToYUVPlanes(GrTexture* texture, const SkISize sizes[3], void* cons
// 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 c35f57a68f..e9b2ef5bf6 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -113,9 +113,11 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx,
}
}
+ // 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 2b4c0842a0..20e5afef9f 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -126,8 +126,8 @@ bool SkGpuDevice::CheckAlphaTypeAndGetFlags(
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 @@ sk_sp<SkGpuDevice> SkGpuDevice::Make(sk_sp<GrRenderTarget> rt, const SkSurfacePr
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 @@ sk_sp<GrDrawContext> SkGpuDevice::CreateDrawContext(GrContext* context,
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 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
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 d341b39ed6..811175937c 100644
--- a/src/gpu/SkGpuDevice.h
+++ b/src/gpu/SkGpuDevice.h
@@ -42,7 +42,8 @@ public:
* 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 5294492e55..f41e154556 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -174,9 +174,9 @@ void GrConfigConversionEffect::TestForPreservingPMConversions(GrContext* context
}
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 9e10dab4a7..fa697cd4b9 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -245,6 +245,7 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(SkBackingFit::kExact,
width, height,
kRGBA_8888_GrPixelConfig,
+ std::move(imageColorSpace),
0,
origin));
if (!drawContext) {
@@ -262,7 +263,7 @@ static sk_sp<SkImage> make_from_yuv_textures_copy(GrContext* ctx, SkYUVColorSpac
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 8f6e308976..2035e4cc8a 100644
--- a/src/image/SkSurface.cpp
+++ b/src/image/SkSurface.cpp
@@ -223,7 +223,8 @@ void SkSurface::prepareForExternalIO() {
#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::MakeRenderTarget(GrContext*, SkBudgeted, const SkIma
}
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 8d5601d01c..ef8dd5f06e 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -132,9 +132,11 @@ void SkSurface_Gpu::onPrepareForExternalIO() {
///////////////////////////////////////////////////////////////////////////////
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::MakeRenderTarget(GrContext* ctx, SkBudgeted budgeted
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 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTexture(GrContext* context,
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::MakeFromBackendTexture(GrContext* context,
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 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendRenderTarget(GrContext* context,
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::MakeFromBackendRenderTarget(GrContext* context,
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 @@ sk_sp<SkSurface> SkSurface::MakeFromBackendTextureAsRenderTarget(GrContext* cont
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 64464aa18b..4afbabaa56 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -45,7 +45,7 @@ static bool reset_dc(sk_sp<GrDrawContext>* dc, GrContext* context, int w, int h)
}
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 ad6e022332..e1af6acd93 100644
--- a/tests/DFPathRendererTest.cpp
+++ b/tests/DFPathRendererTest.cpp
@@ -66,6 +66,7 @@ DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(AADistanceFieldPathRenderer, reporter, ctxInfo)
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 16a2592078..393de53b74 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -158,6 +158,7 @@ static sk_sp<GrDrawContext> random_draw_context(GrContext* context,
kRenderTargetWidth,
kRenderTargetHeight,
kRGBA_8888_GrPixelConfig,
+ nullptr,
sampleCnt,
origin));
return drawContext;
@@ -345,7 +346,8 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages) {
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 f46519d94e..65ea8cf6b2 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -367,7 +367,7 @@ static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context,
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 f121079153..acaf9e98af 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -105,7 +105,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
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 6b6778d1ac..6aebe6effa 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -397,7 +397,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadPixels_Gpu, reporter, ctxInfo) {
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 630924aca6..16f43ea310 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -93,7 +93,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) {
// 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 2fa51e2ba2..b42b3bac6c 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -90,7 +90,8 @@ static void test_clear(skiatest::Reporter* reporter, GrContext* context,
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 1e62f88be8..f798119ad5 100644
--- a/tests/SRGBMipMapTest.cpp
+++ b/tests/SRGBMipMapTest.cpp
@@ -123,12 +123,17 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SRGBMipMaps, reporter, ctxInfo) {
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 2bb1005e2a..a0ec317651 100644
--- a/tests/SpecialSurfaceTest.cpp
+++ b/tests/SpecialSurfaceTest.cpp
@@ -81,7 +81,8 @@ DEF_TEST(SpecialSurface_Raster2, reporter) {
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 16db3e3c4e..8d2ba51e19 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -337,7 +337,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(UniqueImageSnapshot_Gpu, reporter, ctxInfo) {
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 80e65cd3f0..5e8d952f32 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -257,6 +257,7 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
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 90f5d805f1..ec88f03c2b 100644
--- a/tests/WritePixelsTest.cpp
+++ b/tests/WritePixelsTest.cpp
@@ -416,7 +416,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(WritePixels_Gpu, reporter, ctxInfo) {
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());
}
}