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/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;