diff options
author | brianosman <brianosman@google.com> | 2016-07-21 13:28:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-21 13:28:36 -0700 |
commit | dfe4f2e4fe5b162d4adb4486fe751f1e3b30bea7 (patch) | |
tree | aa6ff74a25306386a0c5b5586a4843b470d80101 /src/gpu | |
parent | 8602ede5fdfa721dcad4dcb11db028c1c24265f1 (diff) |
Add SkColorSpace to GrDrawContext
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2164363002
Review-Url: https://codereview.chromium.org/2164363002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrBlurUtils.cpp | 1 | ||||
-rw-r--r-- | src/gpu/GrClipMaskManager.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 20 | ||||
-rw-r--r-- | src/gpu/GrDrawContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrDrawingManager.cpp | 8 | ||||
-rw-r--r-- | src/gpu/GrDrawingManager.h | 3 | ||||
-rw-r--r-- | src/gpu/GrPathRenderingDrawContext.h | 6 | ||||
-rw-r--r-- | src/gpu/GrRenderTarget.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureParamsAdjuster.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrTextureToYUVPlanes.cpp | 10 | ||||
-rw-r--r-- | src/gpu/GrYUVProvider.cpp | 4 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 10 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.h | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 4 |
14 files changed, 49 insertions, 28 deletions
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; } |