diff --git a/bench/VertexColorSpaceBench.cpp b/bench/VertexColorSpaceBench.cpp index db2dfa409a..6c2001d490 100644 --- a/bench/VertexColorSpaceBench.cpp +++ b/bench/VertexColorSpaceBench.cpp @@ -282,8 +282,8 @@ public: const int kDrawsPerLoop = 32; for (int i = 0; i < loops; ++i) { - auto rtc = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, 100, 100, GrColorType::kRGBA_8888, p3); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, p3, SkBackingFit::kApprox, {100, 100}); SkASSERT(rtc); for (int j = 0; j < kDrawsPerLoop; ++j) { diff --git a/gm/clockwise.cpp b/gm/clockwise.cpp index c52cc3af51..b8f6f683f2 100644 --- a/gm/clockwise.cpp +++ b/gm/clockwise.cpp @@ -245,9 +245,10 @@ void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* c // Draw the test to an off-screen, top-down render target. GrColorType rtcColorType = rtc->colorInfo().colorType(); - if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, 100, 200, rtcColorType, nullptr, 1, - GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) { + if (auto topLeftRTC = GrRenderTargetContext::Make( + ctx, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin, SkBudgeted::kYes, + nullptr)) { topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT, GrRenderTargetContext::CanClearFullscreen::kYes); topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0)); @@ -261,9 +262,10 @@ void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* c } // Draw the test to an off-screen, bottom-up render target. - if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, 100, 200, rtcColorType, nullptr, 1, - GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) { + if (auto topLeftRTC = GrRenderTargetContext::Make( + ctx, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, 1, + GrMipMapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin, SkBudgeted::kYes, + nullptr)) { topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT, GrRenderTargetContext::CanClearFullscreen::kYes); topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0)); diff --git a/gm/samplelocations.cpp b/gm/samplelocations.cpp index e1b1a1279b..282e13faa2 100644 --- a/gm/samplelocations.cpp +++ b/gm/samplelocations.cpp @@ -320,9 +320,9 @@ DrawResult SampleLocationsGM::onDraw( return DrawResult::kSkip; } - auto offscreenRTC = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, 200, 200, rtc->colorInfo().colorType(), nullptr, - rtc->numSamples(), GrMipMapped::kNo, fOrigin); + auto offscreenRTC = GrRenderTargetContext::Make( + ctx, rtc->colorInfo().colorType(), nullptr, SkBackingFit::kExact, {200, 200}, + rtc->numSamples(), GrMipMapped::kNo, GrProtected::kNo, fOrigin); if (!offscreenRTC) { *errorMsg = "Failed to create offscreen render target."; return DrawResult::kFail; diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp index f1528f5653..5720efed3a 100644 --- a/gm/windowrectangles.cpp +++ b/gm/windowrectangles.cpp @@ -226,9 +226,9 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo const GrReducedClip& reducedClip, GrPaint&& paint) { const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2; const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2; - auto maskRTC(ctx->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, kCoverRect.width() + padRight, kCoverRect.height() + padBottom, - GrColorType::kAlpha_8, nullptr)); + auto maskRTC = GrRenderTargetContext::MakeWithFallback( + ctx, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, + {kCoverRect.width() + padRight, kCoverRect.height() + padBottom}); if (!maskRTC) { return; } diff --git a/include/private/GrRecordingContext.h b/include/private/GrRecordingContext.h index 7d732f1206..cd0f80dc21 100644 --- a/include/private/GrRecordingContext.h +++ b/include/private/GrRecordingContext.h @@ -114,43 +114,6 @@ protected: */ void addOnFlushCallbackObject(GrOnFlushCallbackObject*); - /* - * Create a new render target context backed by a deferred-style - * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for - * renderTargetContexts created via this entry point. - */ - std::unique_ptr makeDeferredRenderTargetContext( - SkBackingFit fit, - int width, - int height, - GrColorType colorType, - sk_sp colorSpace, - int sampleCnt = 1, - GrMipMapped = GrMipMapped::kNo, - GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, - const SkSurfaceProps* surfaceProps = nullptr, - SkBudgeted = SkBudgeted::kYes, - GrProtected isProtected = GrProtected::kNo); - - /* - * This method will attempt to create a renderTargetContext that has, at least, the number of - * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be - * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA). - * SRGB-ness will be preserved. - */ - std::unique_ptr makeDeferredRenderTargetContextWithFallback( - SkBackingFit fit, - int width, - int height, - GrColorType colorType, - sk_sp colorSpace, - int sampleCnt = 1, - GrMipMapped = GrMipMapped::kNo, - GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, - const SkSurfaceProps* surfaceProps = nullptr, - SkBudgeted budgeted = SkBudgeted::kYes, - GrProtected isProtected = GrProtected::kNo); - GrAuditTrail* auditTrail() { return fAuditTrail.get(); } GrRecordingContext* asRecordingContext() override { return this; } diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp index b6e270d8c0..213345ea76 100644 --- a/samplecode/SampleCCPRGeometry.cpp +++ b/samplecode/SampleCCPRGeometry.cpp @@ -183,9 +183,10 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) { GrOpMemoryPool* pool = ctx->priv().opMemoryPool(); - auto ccbuff = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, - this->width(), this->height(), - GrColorType::kAlpha_F16, nullptr); + int width = this->width(); + int height = this->height(); + auto ccbuff = GrRenderTargetContext::Make( + ctx, GrColorType::kAlpha_F16, nullptr, SkBackingFit::kApprox, {width, height}); SkASSERT(ccbuff); ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT, GrRenderTargetContext::CanClearFullscreen::kYes); diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp index e78c2e4b67..b4d265b6e5 100644 --- a/src/core/SkGpuBlurUtils.cpp +++ b/src/core/SkGpuBlurUtils.cpp @@ -107,19 +107,9 @@ static std::unique_ptr convolve_gaussian_2d(GrRecordingCo int finalH, sk_sp finalCS, SkBackingFit dstFit) { - - auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( - dstFit, - finalW, - finalH, - srcColorType, - std::move(finalCS), - 1, - GrMipMapped::kNo, - srcProxy->origin(), - nullptr, - SkBudgeted::kYes, - srcProxy->isProtected()); + auto renderTargetContext = GrRenderTargetContext::Make( + context, srcColorType, std::move(finalCS), dstFit, {finalW, finalH}, 1, + GrMipMapped::kNo, srcProxy->isProtected(), srcProxy->origin()); if (!renderTargetContext) { return nullptr; } @@ -167,18 +157,9 @@ static std::unique_ptr convolve_gaussian(GrRecordingConte SkBackingFit fit) { SkASSERT(srcRect.width() <= finalW && srcRect.height() <= finalH); - auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext( - fit, - srcRect.width(), - srcRect.height(), - srcColorType, - std::move(finalCS), - 1, - GrMipMapped::kNo, - srcProxy->origin(), - nullptr, - SkBudgeted::kYes, - srcProxy->isProtected()); + auto dstRenderTargetContext = GrRenderTargetContext::Make( + context, srcColorType, std::move(finalCS), fit, srcRect.size(), 1, + GrMipMapped::kNo, srcProxy->isProtected(), srcProxy->origin()); if (!dstRenderTargetContext) { return nullptr; } @@ -302,19 +283,10 @@ static sk_sp decimate(GrRecordingContext* context, for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY); - // We know this will not be the final draw so we are free to make it an approx match. - dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, - dstRect.fRight, - dstRect.fBottom, - srcColorType, - finalCS, - 1, - GrMipMapped::kNo, - srcProxy->origin(), - nullptr, - SkBudgeted::kYes, - srcProxy->isProtected()); + dstRenderTargetContext = GrRenderTargetContext::Make( + context, srcColorType, finalCS, SkBackingFit::kApprox, + {dstRect.fRight, dstRect.fBottom}, 1, GrMipMapped::kNo, srcProxy->isProtected(), + srcProxy->origin()); if (!dstRenderTargetContext) { return nullptr; } @@ -392,9 +364,9 @@ static std::unique_ptr reexpand( srcRenderTargetContext = nullptr; // no longer needed - auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext( - fit, finalW, finalH, srcColorType, std::move(finalCS), 1, GrMipMapped::kNo, - srcProxy->origin()); + auto dstRenderTargetContext = GrRenderTargetContext::Make( + context, srcColorType, std::move(finalCS), fit, {finalW, finalH}, 1, + GrMipMapped::kNo, srcProxy->isProtected(), srcProxy->origin()); if (!dstRenderTargetContext) { return nullptr; } diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 107566459b..ff6c6dfbd8 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -575,18 +575,10 @@ sk_sp SkImageFilter_Base::DrawWithFP(GrRecordingContext* context paint.addColorFragmentProcessor(std::move(fp)); paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - auto renderTargetContext = - context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, - bounds.width(), - bounds.height(), - SkColorTypeToGrColorType(colorType), - sk_ref_sp(colorSpace), - 1, - GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, - nullptr, - SkBudgeted::kYes, - isProtected); + auto renderTargetContext = GrRenderTargetContext::Make( + context, SkColorTypeToGrColorType(colorType), sk_ref_sp(colorSpace), + SkBackingFit::kApprox, bounds.size(), 1, GrMipMapped::kNo, isProtected, + kBottomLeft_GrSurfaceOrigin); if (!renderTargetContext) { return nullptr; } diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp index 6deca8c688..41511c03a7 100644 --- a/src/core/SkSpecialSurface.cpp +++ b/src/core/SkSpecialSurface.cpp @@ -169,9 +169,10 @@ sk_sp SkSpecialSurface::MakeRenderTarget(GrRecordingContext* c if (!context) { return nullptr; } - auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, width, height, colorType, std::move(colorSpace), 1, - GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props); + auto renderTargetContext = GrRenderTargetContext::Make( + context, colorType, std::move(colorSpace), SkBackingFit::kApprox, {width, height}, 1, + GrMipMapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin, SkBudgeted::kYes, + props); if (!renderTargetContext) { return nullptr; } diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp index 1367fba64f..3dade7fb43 100644 --- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp +++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp @@ -103,8 +103,8 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const { sk_sp SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context, const SkMatrix& inMatrix, const SkIRect& bounds) const { - auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kApprox, bounds.width(), bounds.height(), GrColorType::kAlpha_8, nullptr); + auto rtContext = GrRenderTargetContext::MakeWithFallback( + context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, bounds.size()); if (!rtContext) { return nullptr; } diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp index 8b5e2d2398..8a08602f9e 100644 --- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp +++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp @@ -403,18 +403,9 @@ sk_sp ArithmeticImageFilterImpl::filterImageGPU( paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - auto renderTargetContext = - context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, - bounds.width(), - bounds.height(), - ctx.grColorType(), - ctx.refColorSpace(), - 1, - GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, - nullptr, - SkBudgeted::kYes, - isProtected); + auto renderTargetContext = GrRenderTargetContext::Make( + context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox, bounds.size(), + 1, GrMipMapped::kNo, isProtected, kBottomLeft_GrSurfaceOrigin); if (!renderTargetContext) { return nullptr; } diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp index e64782111b..656a76c749 100644 --- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp +++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp @@ -363,18 +363,9 @@ sk_sp SkDisplacementMapEffectImpl::onFilterImage(const Context& SkMatrix matrix; matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y())); - auto renderTargetContext = - context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, - bounds.width(), - bounds.height(), - ctx.grColorType(), - ctx.refColorSpace(), - 1, - GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, - nullptr, - SkBudgeted::kYes, - isProtected); + auto renderTargetContext = GrRenderTargetContext::Make( + context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox, + bounds.size(), 1, GrMipMapped::kNo, isProtected, kBottomLeft_GrSurfaceOrigin); if (!renderTargetContext) { return nullptr; } diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp index 82199bda38..b0a47cb31f 100644 --- a/src/effects/imagefilters/SkLightingImageFilter.cpp +++ b/src/effects/imagefilters/SkLightingImageFilter.cpp @@ -488,18 +488,10 @@ sk_sp SkLightingImageFilterInternal::filterImageGPU( sk_sp inputProxy(input->asTextureProxyRef(context)); SkASSERT(inputProxy); - auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, - offsetBounds.width(), - offsetBounds.height(), - ctx.grColorType(), - ctx.refColorSpace(), - 1, - GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, - nullptr, - SkBudgeted::kYes, - inputProxy->isProtected()); + auto renderTargetContext = GrRenderTargetContext::Make( + context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox, + offsetBounds.size(), 1, GrMipMapped::kNo, inputProxy->isProtected(), + kBottomLeft_GrSurfaceOrigin); if (!renderTargetContext) { return nullptr; } diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp index 182d73adc7..2e8742e8db 100644 --- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp +++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp @@ -567,18 +567,9 @@ static sk_sp apply_morphology( SkASSERT(radius.width() > 0 || radius.height() > 0); if (radius.fWidth > 0) { - auto dstRTContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, - rect.width(), - rect.height(), - colorType, - colorSpace, - 1, - GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, - nullptr, - SkBudgeted::kYes, - srcTexture->isProtected()); + auto dstRTContext = GrRenderTargetContext::Make( + context, colorType, colorSpace, SkBackingFit::kApprox, rect.size(), 1, + GrMipMapped::kNo, srcTexture->isProtected(), kBottomLeft_GrSurfaceOrigin); if (!dstRTContext) { return nullptr; } @@ -596,18 +587,9 @@ static sk_sp apply_morphology( srcRect = dstRect; } if (radius.fHeight > 0) { - auto dstRTContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, - rect.width(), - rect.height(), - colorType, - colorSpace, - 1, - GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, - nullptr, - SkBudgeted::kYes, - srcTexture->isProtected()); + auto dstRTContext = GrRenderTargetContext::Make( + context, colorType, colorSpace, SkBackingFit::kApprox, rect.size(), 1, + GrMipMapped::kNo, srcTexture->isProtected(), kBottomLeft_GrSurfaceOrigin); if (!dstRTContext) { return nullptr; } diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp index c36d226466..89244566f5 100644 --- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp +++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp @@ -310,9 +310,8 @@ sk_sp SkXfermodeImageFilterImpl::filterImageGPU( paint.setPorterDuffXPFactory(SkBlendMode::kSrc); - auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, bounds.width(), bounds.height(), ctx.grColorType(), - ctx.refColorSpace()); + auto renderTargetContext = GrRenderTargetContext::Make( + context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox, bounds.size()); if (!renderTargetContext) { return nullptr; } diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp index f7fae0237c..b2a7f65cce 100644 --- a/src/gpu/GrBlurUtils.cpp +++ b/src/gpu/GrBlurUtils.cpp @@ -185,9 +185,9 @@ static std::unique_ptr create_mask_GPU(GrRecordingContext // the same. We should offset our filter within the render target and expand the size as needed // to guarantee at least 1px of padding on all sides. auto approxSize = GrResourceProvider::MakeApprox(maskRect.size()); - auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, approxSize.width(), approxSize.height(), GrColorType::kAlpha_8, - nullptr, sampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); + auto rtContext = GrRenderTargetContext::MakeWithFallback( + context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, approxSize, sampleCnt, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!rtContext) { return nullptr; } diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp index 5d2b7deb2a..40a993182a 100644 --- a/src/gpu/GrClipStackClip.cpp +++ b/src/gpu/GrClipStackClip.cpp @@ -354,18 +354,10 @@ sk_sp GrClipStackClip::createAlphaClipMask(GrRecordingContext* c return proxy; } - auto isProtected = proxy->isProtected(); - auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox, - reducedClip.width(), - reducedClip.height(), - GrColorType::kAlpha_8, - nullptr, - 1, - GrMipMapped::kNo, - kTopLeft_GrSurfaceOrigin, - nullptr, - SkBudgeted::kYes, - isProtected); + auto rtc = GrRenderTargetContext::MakeWithFallback( + context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, + {reducedClip.width(), reducedClip.height()}, 1, GrMipMapped::kNo, proxy->isProtected(), + kTopLeft_GrSurfaceOrigin); if (!rtc) { return nullptr; } diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp index a0f5d49379..0efe6eaaa6 100644 --- a/src/gpu/GrContextPriv.cpp +++ b/src/gpu/GrContextPriv.cpp @@ -40,33 +40,6 @@ void GrContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBO fContext->addOnFlushCallbackObject(onFlushCBObject); } -std::unique_ptr GrContextPriv::makeDeferredRenderTargetContext( - SkBackingFit fit, - int width, - int height, - GrColorType colorType, - sk_sp colorSpace, - int sampleCnt, - GrMipMapped mipMapped, - GrSurfaceOrigin origin, - const SkSurfaceProps* surfaceProps, - SkBudgeted budgeted, - GrProtected isProtected) { - return fContext->makeDeferredRenderTargetContext(fit, width, height, colorType, - std::move(colorSpace), sampleCnt, mipMapped, - origin, surfaceProps, budgeted, isProtected); -} - -std::unique_ptr GrContextPriv::makeDeferredRenderTargetContextWithFallback( - SkBackingFit fit, int width, int height, GrColorType colorType, - sk_sp colorSpace, int sampleCnt, GrMipMapped mipMapped, - GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted, - GrProtected isProtected) { - return fContext->makeDeferredRenderTargetContextWithFallback( - fit, width, height, colorType, std::move(colorSpace), sampleCnt, mipMapped, origin, - surfaceProps, budgeted, isProtected); -} - std::unique_ptr GrContextPriv::makeBackendTextureRenderTargetContext( const GrBackendTexture& tex, GrSurfaceOrigin origin, diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h index 95dfcfb427..03cab66341 100644 --- a/src/gpu/GrContextPriv.h +++ b/src/gpu/GrContextPriv.h @@ -69,43 +69,6 @@ public: */ void addOnFlushCallbackObject(GrOnFlushCallbackObject*); - /* - * Create a new render target context backed by a deferred-style - * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for - * renderTargetContexts created via this entry point. - */ - std::unique_ptr makeDeferredRenderTargetContext( - SkBackingFit fit, - int width, - int height, - GrColorType, - sk_sp colorSpace, - int sampleCnt = 1, - GrMipMapped = GrMipMapped::kNo, - GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, - const SkSurfaceProps* surfaceProps = nullptr, - SkBudgeted = SkBudgeted::kYes, - GrProtected isProtected = GrProtected::kNo); - - /* - * This method will attempt to create a renderTargetContext that has, at least, the number of - * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be - * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA). - * SRGB-ness will be preserved. - */ - std::unique_ptr makeDeferredRenderTargetContextWithFallback( - SkBackingFit fit, - int width, - int height, - GrColorType, - sk_sp colorSpace, - int sampleCnt = 1, - GrMipMapped = GrMipMapped::kNo, - GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, - const SkSurfaceProps* surfaceProps = nullptr, - SkBudgeted budgeted = SkBudgeted::kYes, - GrProtected isProtected = GrProtected::kNo); - GrAuditTrail* auditTrail() { return fContext->auditTrail(); } /** diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp index ecc16e6357..02359c3975 100644 --- a/src/gpu/GrRecordingContext.cpp +++ b/src/gpu/GrRecordingContext.cpp @@ -167,101 +167,6 @@ void GrRecordingContext::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlu this->drawingManager()->addOnFlushCallbackObject(onFlushCBObject); } -std::unique_ptr GrRecordingContext::makeDeferredRenderTargetContext( - SkBackingFit fit, - int width, - int height, - GrColorType colorType, - sk_sp colorSpace, - int sampleCnt, - GrMipMapped mipMapped, - GrSurfaceOrigin origin, - const SkSurfaceProps* surfaceProps, - SkBudgeted budgeted, - GrProtected isProtected) { - SkASSERT(sampleCnt > 0); - if (this->abandoned()) { - return nullptr; - } - - auto format = this->caps()->getDefaultBackendFormat(colorType, GrRenderable::kYes); - if (!format.isValid()) { - return nullptr; - } - auto config = this->caps()->getConfigFromBackendFormat(format, colorType); - if (config == kUnknown_GrPixelConfig) { - return nullptr; - } - - GrSurfaceDesc desc; - desc.fWidth = width; - desc.fHeight = height; - desc.fConfig = config; - - sk_sp rtp = - this->proxyProvider()->createProxy(format, desc, GrRenderable::kYes, sampleCnt, origin, - mipMapped, fit, budgeted, isProtected); - if (!rtp) { - return nullptr; - } - - auto drawingManager = this->drawingManager(); - - auto renderTargetContext = drawingManager->makeRenderTargetContext( - std::move(rtp), colorType, std::move(colorSpace), surfaceProps); - if (!renderTargetContext) { - return nullptr; - } - - renderTargetContext->discard(); - - return renderTargetContext; -} - -static inline GrColorType color_type_fallback(GrColorType ct) { - switch (ct) { - // kRGBA_8888 is our default fallback for many color types that may not have renderable - // backend formats. - case GrColorType::kAlpha_8: - case GrColorType::kBGR_565: - case GrColorType::kABGR_4444: - case GrColorType::kBGRA_8888: - case GrColorType::kRGBA_1010102: - case GrColorType::kRGBA_F16: - case GrColorType::kRGBA_F16_Clamped: - return GrColorType::kRGBA_8888; - case GrColorType::kAlpha_F16: - return GrColorType::kRGBA_F16; - case GrColorType::kGray_8: - return GrColorType::kRGB_888x; - default: - return GrColorType::kUnknown; - } -} - -std::unique_ptr -GrRecordingContext::makeDeferredRenderTargetContextWithFallback(SkBackingFit fit, - int width, - int height, - GrColorType colorType, - sk_sp colorSpace, - int sampleCnt, - GrMipMapped mipMapped, - GrSurfaceOrigin origin, - const SkSurfaceProps* surfaceProps, - SkBudgeted budgeted, - GrProtected isProtected) { - SkASSERT(sampleCnt > 0); - std::unique_ptr rtc; - do { - rtc = this->makeDeferredRenderTargetContext(fit, width, height, colorType, colorSpace, - sampleCnt, mipMapped, origin, surfaceProps, - budgeted, isProtected); - colorType = color_type_fallback(colorType); - } while (!rtc && colorType != GrColorType::kUnknown); - return rtc; -} - /////////////////////////////////////////////////////////////////////////////////////////////////// sk_sp GrRecordingContextPriv::refCaps() const { return fContext->refCaps(); @@ -271,49 +176,6 @@ void GrRecordingContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* o fContext->addOnFlushCallbackObject(onFlushCBObject); } -std::unique_ptr GrRecordingContextPriv::makeDeferredRenderTargetContext( - SkBackingFit fit, - int width, - int height, - GrColorType colorType, - sk_sp colorSpace, - int sampleCnt, - GrMipMapped mipMapped, - GrSurfaceOrigin origin, - const SkSurfaceProps* surfaceProps, - SkBudgeted budgeted, - GrProtected isProtected) { - return fContext->makeDeferredRenderTargetContext(fit, width, height, colorType, - std::move(colorSpace), sampleCnt, mipMapped, - origin, surfaceProps, budgeted, isProtected); -} - -std::unique_ptr -GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback( - SkBackingFit fit, - int width, - int height, - GrColorType colorType, - sk_sp colorSpace, - int sampleCnt, - GrMipMapped mipMapped, - GrSurfaceOrigin origin, - const SkSurfaceProps* surfaceProps, - SkBudgeted budgeted, - GrProtected isProtected) { - return fContext->makeDeferredRenderTargetContextWithFallback(fit, - width, - height, - colorType, - std::move(colorSpace), - sampleCnt, - mipMapped, - origin, - surfaceProps, - budgeted, - isProtected); -} - GrContext* GrRecordingContextPriv::backdoor() { return (GrContext*) fContext; } diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h index 6ec2468fa4..9b64ed0a23 100644 --- a/src/gpu/GrRecordingContextPriv.h +++ b/src/gpu/GrRecordingContextPriv.h @@ -66,43 +66,6 @@ public: */ void addOnFlushCallbackObject(GrOnFlushCallbackObject*); - /* - * Create a new render target context backed by a deferred-style - * GrRenderTargetProxy. We guarantee that "asTextureProxy" will succeed for - * renderTargetContexts created via this entry point. - */ - std::unique_ptr makeDeferredRenderTargetContext( - SkBackingFit fit, - int width, - int height, - GrColorType, - sk_sp colorSpace, - int sampleCnt = 1, - GrMipMapped = GrMipMapped::kNo, - GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, - const SkSurfaceProps* surfaceProps = nullptr, - SkBudgeted = SkBudgeted::kYes, - GrProtected isProtected = GrProtected::kNo); - - /* - * This method will attempt to create a renderTargetContext that has, at least, the number of - * channels and precision per channel as requested in 'config' (e.g., A8 and 888 can be - * converted to 8888). It may also swizzle the channels (e.g., BGRA -> RGBA). - * SRGB-ness will be preserved. - */ - std::unique_ptr makeDeferredRenderTargetContextWithFallback( - SkBackingFit fit, - int width, - int height, - GrColorType, - sk_sp colorSpace, - int sampleCnt = 1, - GrMipMapped = GrMipMapped::kNo, - GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin, - const SkSurfaceProps* surfaceProps = nullptr, - SkBudgeted budgeted = SkBudgeted::kYes, - GrProtected isProtected = GrProtected::kNo); - GrAuditTrail* auditTrail() { return fContext->auditTrail(); } // CONTEXT TODO: remove this backdoor diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 00fb78f126..fc6df9e3c5 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -137,6 +137,115 @@ private: GrDrawingManager* fDrawingManager; }; +std::unique_ptr GrRenderTargetContext::Make( + GrRecordingContext* context, + GrColorType colorType, + sk_sp colorSpace, + SkBackingFit fit, + const SkISize& dimensions, + const GrBackendFormat& format, + int sampleCnt, + GrMipMapped mipMapped, + GrProtected isProtected, + GrSurfaceOrigin origin, + SkBudgeted budgeted, + const SkSurfaceProps* surfaceProps) { + auto config = context->priv().caps()->getConfigFromBackendFormat(format, colorType); + if (config == kUnknown_GrPixelConfig) { + return nullptr; + } + GrSurfaceDesc desc; + desc.fWidth = dimensions.width(); + desc.fHeight = dimensions.height(); + desc.fConfig = config; + + GrSwizzle readSwizzle = context->priv().caps()->getReadSwizzle(format, colorType); + GrSwizzle outSwizzle = context->priv().caps()->getOutputSwizzle(format, colorType); + + sk_sp proxy = context->priv().proxyProvider()->createProxy( + format, desc, GrRenderable::kYes, sampleCnt, origin, mipMapped, fit, budgeted, + isProtected); + if (!proxy) { + return nullptr; + } + GrRenderTargetProxy* rtp = proxy->asRenderTargetProxy(); + SkASSERT(rtp); + + auto rtc = std::make_unique(context, sk_ref_sp(rtp), colorType, origin, + readSwizzle, outSwizzle, + std::move(colorSpace), surfaceProps, true); + if (!rtc) { + return nullptr; + } + rtc->discard(); + return rtc; +} + +std::unique_ptr GrRenderTargetContext::Make( + GrRecordingContext* context, + GrColorType colorType, + sk_sp colorSpace, + SkBackingFit fit, + const SkISize& dimensions, + int sampleCnt, + GrMipMapped mipMapped, + GrProtected isProtected, + GrSurfaceOrigin origin, + SkBudgeted budgeted, + const SkSurfaceProps* surfaceProps) { + auto format = context->priv().caps()->getDefaultBackendFormat(colorType, GrRenderable::kYes); + if (!format.isValid()) { + return nullptr; + } + + return GrRenderTargetContext::Make(context, colorType, std::move(colorSpace), fit, dimensions, + format, sampleCnt, mipMapped, isProtected, origin, budgeted, + surfaceProps); +} + +static inline GrColorType color_type_fallback(GrColorType ct) { + switch (ct) { + // kRGBA_8888 is our default fallback for many color types that may not have renderable + // backend formats. + case GrColorType::kAlpha_8: + case GrColorType::kBGR_565: + case GrColorType::kABGR_4444: + case GrColorType::kBGRA_8888: + case GrColorType::kRGBA_1010102: + case GrColorType::kRGBA_F16: + case GrColorType::kRGBA_F16_Clamped: + return GrColorType::kRGBA_8888; + case GrColorType::kAlpha_F16: + return GrColorType::kRGBA_F16; + case GrColorType::kGray_8: + return GrColorType::kRGB_888x; + default: + return GrColorType::kUnknown; + } +} + +std::unique_ptr GrRenderTargetContext::MakeWithFallback( + GrRecordingContext* context, + GrColorType colorType, + sk_sp colorSpace, + SkBackingFit fit, + const SkISize& dimensions, + int sampleCnt, + GrMipMapped mipMapped, + GrProtected isProtected, + GrSurfaceOrigin origin, + SkBudgeted budgeted, + const SkSurfaceProps* surfaceProps) { + std::unique_ptr rtc; + do { + rtc = GrRenderTargetContext::Make(context, colorType, colorSpace, fit, dimensions, + sampleCnt, mipMapped, isProtected, origin, budgeted, + surfaceProps); + colorType = color_type_fallback(colorType); + } while (!rtc && colorType != GrColorType::kUnknown); + return rtc; +} + // In MDB mode the reffing of the 'getLastOpsTask' call's result allows in-progress // GrOpsTask to be picked up and added to by renderTargetContexts lower in the call // stack. When this occurs with a closed GrOpsTask, a new one will be allocated @@ -1546,9 +1655,9 @@ void GrRenderTargetContext::asyncRescaleAndReadPixels( } srcRectToDraw = SkRect::MakeWH(srcRect.width(), srcRect.height()); } - tempRTC = direct->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, srcRect.width(), srcRect.height(), - this->colorInfo().colorType(), info.refColorSpace(), 1, GrMipMapped::kNo, + tempRTC = GrRenderTargetContext::Make( + direct, this->colorInfo().colorType(), info.refColorSpace(), + SkBackingFit::kApprox, srcRect.size(), 1, GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!tempRTC) { callback(context, nullptr); @@ -1757,10 +1866,9 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC return; } SkRect srcRectToDraw = SkRect::Make(srcRect); - tempRTC = direct->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, dstSize.width(), dstSize.height(), - this->colorInfo().colorType(), dstColorSpace, 1, GrMipMapped::kNo, - kTopLeft_GrSurfaceOrigin); + tempRTC = GrRenderTargetContext::Make( + direct, this->colorInfo().colorType(), dstColorSpace, SkBackingFit::kApprox, + dstSize, 1, GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!tempRTC) { callback(context, nullptr); return; @@ -1781,17 +1889,17 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC return; } - auto yRTC = direct->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kApprox, dstSize.width(), dstSize.height(), GrColorType::kAlpha_8, - dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); + auto yRTC = GrRenderTargetContext::MakeWithFallback( + direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, dstSize, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); int halfW = dstSize.width()/2; int halfH = dstSize.height()/2; - auto uRTC = direct->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kApprox, halfW, halfH, GrColorType::kAlpha_8, dstColorSpace, 1, - GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); - auto vRTC = direct->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kApprox, halfW, halfH, GrColorType::kAlpha_8, dstColorSpace, 1, - GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); + auto uRTC = GrRenderTargetContext::MakeWithFallback( + direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); + auto vRTC = GrRenderTargetContext::MakeWithFallback( + direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!yRTC || !uRTC || !vRTC) { callback(context, nullptr); return; diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h index 58e2aaec54..fa08494965 100644 --- a/src/gpu/GrRenderTargetContext.h +++ b/src/gpu/GrRenderTargetContext.h @@ -57,6 +57,28 @@ class SkVertices; */ class GrRenderTargetContext : public GrSurfaceContext { public: + static std::unique_ptr Make( + GrRecordingContext*, GrColorType, sk_sp, SkBackingFit, + const SkISize& dimensions, const GrBackendFormat&, int sampleCnt, GrMipMapped, + GrProtected, GrSurfaceOrigin, SkBudgeted, const SkSurfaceProps*); + + // Same as above but will use the default GrBackendFormat for the given GrColorType + static std::unique_ptr Make( + GrRecordingContext*, GrColorType, sk_sp, SkBackingFit, + const SkISize& dimensions, int sampleCnt = 1, GrMipMapped = GrMipMapped::kNo, + GrProtected = GrProtected::kNo, GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin, + SkBudgeted = SkBudgeted::kYes, const SkSurfaceProps* = nullptr); + + // Same as previous factory but will try to use fallback GrColorTypes if the one passed in + // fails. The fallback GrColorType will have at least the number of channels and precision per + // channel as the passed in GrColorType. It may also swizzle the changes (e.g., BGRA -> RGBA). + // SRGB-ness will be preserved. + static std::unique_ptr MakeWithFallback( + GrRecordingContext*, GrColorType, sk_sp, SkBackingFit, + const SkISize& dimensions, int sampleCnt = 1, GrMipMapped = GrMipMapped::kNo, + GrProtected = GrProtected::kNo, GrSurfaceOrigin = kBottomLeft_GrSurfaceOrigin, + SkBudgeted = SkBudgeted::kYes, const SkSurfaceProps* = nullptr); + GrRenderTargetContext(GrRecordingContext*, sk_sp, GrColorType, GrSurfaceOrigin, GrSwizzle readSwizzle, GrSwizzle outSwizzle, sk_sp, const SkSurfaceProps*, bool managedOpsTask = true); diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp index ca042392ec..2e31129de6 100644 --- a/src/gpu/GrSurfaceContext.cpp +++ b/src/gpu/GrSurfaceContext.cpp @@ -56,10 +56,18 @@ std::unique_ptr GrSurfaceContext::Make(GrRecordingContext* con } std::unique_ptr GrSurfaceContext::Make( - GrRecordingContext* context, const SkISize& dimensions, const GrBackendFormat& format, - GrRenderable renderable, int renderTargetSampleCnt, GrMipMapped mipMapped, - GrProtected isProtected, GrSurfaceOrigin origin, GrColorType colorType, - SkAlphaType alphaType, sk_sp colorSpace, SkBackingFit fit, + GrRecordingContext* context, + const SkISize& dimensions, + const GrBackendFormat& format, + GrRenderable renderable, + int renderTargetSampleCnt, + GrMipMapped mipMapped, + GrProtected isProtected, + GrSurfaceOrigin origin, + GrColorType colorType, + SkAlphaType alphaType, + sk_sp colorSpace, + SkBackingFit fit, SkBudgeted budgeted) { auto config = context->priv().caps()->getConfigFromBackendFormat(format, colorType); if (config == kUnknown_GrPixelConfig) { @@ -193,9 +201,9 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz canvas2DFastPath ? GrColorType::kRGBA_8888 : this->colorInfo().colorType(); sk_sp cs = canvas2DFastPath ? nullptr : this->colorInfo().refColorSpace(); - auto tempCtx = direct->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, dstInfo.width(), dstInfo.height(), colorType, std::move(cs), - 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes); + auto tempCtx = GrRenderTargetContext::Make( + direct, colorType, std::move(cs), SkBackingFit::kApprox, dstInfo.dimensions(), + 1, GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!tempCtx) { return false; } @@ -550,9 +558,9 @@ std::unique_ptr GrSurfaceContext::rescale( auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(), srcAlphaType, cs.get(), kPremul_SkAlphaType); // We'll fall back to kRGBA_8888 if half float not supported. - auto linearRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, srcW, srcH, GrColorType::kRGBA_F16, cs, 1, GrMipMapped::kNo, - kTopLeft_GrSurfaceOrigin); + auto linearRTC = GrRenderTargetContext::MakeWithFallback( + fContext, GrColorType::kRGBA_F16, cs, SkBackingFit::kExact, {srcW, srcH}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!linearRTC) { return nullptr; } @@ -601,9 +609,9 @@ std::unique_ptr GrSurfaceContext::rescale( input->colorInfo().alphaType(), cs.get(), info.alphaType()); } - tempB = fContext->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, nextW, nextH, colorType, std::move(cs), 1, GrMipMapped::kNo, - kTopLeft_GrSurfaceOrigin); + tempB = GrRenderTargetContext::MakeWithFallback( + fContext, colorType, std::move(cs), SkBackingFit::kExact, {nextW, nextH}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!tempB) { return nullptr; } diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp index 944f979b47..c62f651aba 100644 --- a/src/gpu/GrSurfaceProxy.cpp +++ b/src/gpu/GrSurfaceProxy.cpp @@ -19,6 +19,7 @@ #include "src/gpu/GrOpsTask.h" #include "src/gpu/GrProxyProvider.h" #include "src/gpu/GrRecordingContextPriv.h" +#include "src/gpu/GrRenderTargetContext.h" #include "src/gpu/GrStencilAttachment.h" #include "src/gpu/GrSurfacePriv.h" #include "src/gpu/GrTexturePriv.h" @@ -329,10 +330,10 @@ sk_sp GrSurfaceProxy::Copy(GrRecordingContext* context, } } if (src->asTextureProxy()) { - auto dstContext = context->priv().makeDeferredRenderTargetContext( - fit, width, height, colorType, nullptr, 1, mipMapped, src->origin(), nullptr, - budgeted); - + auto dstContext = GrRenderTargetContext::Make(context, colorType, nullptr, fit, + {width, height}, format, 1, + mipMapped, src->isProtected(), origin, + budgeted, nullptr); if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) { return dstContext->asTextureProxyRef(); } diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp index 1bf649d008..d6a4a0846c 100644 --- a/src/gpu/GrTextureProducer.cpp +++ b/src/gpu/GrTextureProducer.cpp @@ -50,9 +50,9 @@ sk_sp GrTextureProducer::CopyOnGpu(GrRecordingContext* context, } } - auto copyRTC = context->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, dstRect.width(), dstRect.height(), colorType, nullptr, 1, - mipMapped, inputProxy->origin()); + auto copyRTC = GrRenderTargetContext::MakeWithFallback( + context, colorType, nullptr, SkBackingFit::kExact, copyParams.fDimensions, 1, + mipMapped, inputProxy->isProtected(), inputProxy->origin()); if (!copyRTC) { return nullptr; } diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp index e6003bfbd7..6f861da8e5 100644 --- a/src/gpu/GrYUVProvider.cpp +++ b/src/gpu/GrYUVProvider.cpp @@ -157,9 +157,9 @@ sk_sp GrYUVProvider::refAsTextureProxy(GrRecordingContext* ctx, } // TODO: investigate preallocating mip maps here - auto renderTargetContext = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, desc.fWidth, desc.fHeight, colorType, nullptr, 1, - GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); + auto renderTargetContext = GrRenderTargetContext::Make( + ctx, colorType, nullptr, SkBackingFit::kExact, {desc.fWidth, desc.fHeight}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!renderTargetContext) { return nullptr; } diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 9e114f31db..020d123734 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -148,10 +148,10 @@ std::unique_ptr SkGpuDevice::MakeRenderTargetContext( // This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case // they need to be exact. - return context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, origInfo.width(), origInfo.height(), - SkColorTypeToGrColorType(origInfo.colorType()), origInfo.refColorSpace(), sampleCount, - mipMapped, origin, surfaceProps, budgeted); + return GrRenderTargetContext::Make( + context, SkColorTypeToGrColorType(origInfo.colorType()), origInfo.refColorSpace(), + SkBackingFit::kExact, origInfo.dimensions(), sampleCount, mipMapped, GrProtected::kNo, + origin, budgeted, surfaceProps); } sk_sp SkGpuDevice::filterTexture(SkSpecialImage* srcImg, @@ -1627,18 +1627,12 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint SkASSERT(cinfo.fInfo.colorType() != kRGBA_1010102_SkColorType); - auto rtc = fContext->priv().makeDeferredRenderTargetContextWithFallback( - fit, - cinfo.fInfo.width(), - cinfo.fInfo.height(), - SkColorTypeToGrColorType(cinfo.fInfo.colorType()), - fRenderTargetContext->colorInfo().refColorSpace(), - fRenderTargetContext->numSamples(), - GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, - &props, - SkBudgeted::kYes, - fRenderTargetContext->asSurfaceProxy()->isProtected()); + auto rtc = GrRenderTargetContext::MakeWithFallback( + fContext.get(), SkColorTypeToGrColorType(cinfo.fInfo.colorType()), + fRenderTargetContext->colorInfo().refColorSpace(), fit, cinfo.fInfo.dimensions(), + fRenderTargetContext->numSamples(), GrMipMapped::kNo, + fRenderTargetContext->asSurfaceProxy()->isProtected(), kBottomLeft_GrSurfaceOrigin, + SkBudgeted::kYes, &props); if (!rtc) { return nullptr; } diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp index 7338b7d242..8978efeac0 100644 --- a/src/gpu/effects/GrConfigConversionEffect.fp +++ b/src/gpu/effects/GrConfigConversionEffect.fp @@ -41,14 +41,10 @@ const SkImageInfo ii = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType); - auto readRTC = - context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, - kSize, kSize, - kColorType, nullptr); - auto tempRTC = - context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, - kSize, kSize, - kColorType, nullptr); + auto readRTC = GrRenderTargetContext::Make( + context, kColorType, nullptr, SkBackingFit::kExact, {kSize, kSize}); + auto tempRTC = GrRenderTargetContext::Make( + context, kColorType, nullptr, SkBackingFit::kExact, {kSize, kSize}); if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) { return false; } diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp index f13707da07..290295b067 100644 --- a/src/gpu/effects/GrRRectBlurEffect.fp +++ b/src/gpu/effects/GrRRectBlurEffect.fp @@ -55,9 +55,8 @@ uniform half blurRadius; // TODO: this could be SkBackingFit::kApprox, but: // 1) The texture coords would need to be updated. // 2) We would have to use GrTextureDomain::kClamp_Mode for the GaussianBlur. - auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, dimensions.fWidth, dimensions.fHeight, - GrColorType::kAlpha_8, nullptr); + auto rtc = GrRenderTargetContext::MakeWithFallback( + context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions); if (!rtc) { return nullptr; } diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h index a7825c3841..6260b35230 100644 --- a/src/gpu/effects/generated/GrConfigConversionEffect.h +++ b/src/gpu/effects/generated/GrConfigConversionEffect.h @@ -49,10 +49,10 @@ public: const SkImageInfo ii = SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType); - auto readRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, - kSize, kColorType, nullptr); - auto tempRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, - kSize, kColorType, nullptr); + auto readRTC = GrRenderTargetContext::Make(context, kColorType, nullptr, + SkBackingFit::kExact, {kSize, kSize}); + auto tempRTC = GrRenderTargetContext::Make(context, kColorType, nullptr, + SkBackingFit::kExact, {kSize, kSize}); if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) { return false; } diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.h b/src/gpu/effects/generated/GrRRectBlurEffect.h index 5238abb8df..94b6ca1485 100644 --- a/src/gpu/effects/generated/GrRRectBlurEffect.h +++ b/src/gpu/effects/generated/GrRRectBlurEffect.h @@ -56,9 +56,8 @@ public: // TODO: this could be SkBackingFit::kApprox, but: // 1) The texture coords would need to be updated. // 2) We would have to use GrTextureDomain::kClamp_Mode for the GaussianBlur. - auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, dimensions.fWidth, dimensions.fHeight, - GrColorType::kAlpha_8, nullptr); + auto rtc = GrRenderTargetContext::MakeWithFallback( + context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions); if (!rtc) { return nullptr; } diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp index 909ace84f5..0b305e69bc 100644 --- a/src/gpu/text/GrTextContext.cpp +++ b/src/gpu/text/GrTextContext.cpp @@ -253,8 +253,8 @@ GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) { } // Setup dummy SkPaint / GrPaint / GrRenderTargetContext - auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1024, 1024, - GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {1024, 1024}); SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp index 1a561af05c..5800ca6e3a 100644 --- a/src/image/SkImage_Gpu.cpp +++ b/src/image/SkImage_Gpu.cpp @@ -81,9 +81,9 @@ sk_sp SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con targetCS.get(), this->alphaType()); SkASSERT(xform || targetCT != this->colorType()); - auto renderTargetContext = context->priv().makeDeferredRenderTargetContextWithFallback( - SkBackingFit::kExact, this->width(), this->height(), SkColorTypeToGrColorType(targetCT), - nullptr); + auto renderTargetContext = GrRenderTargetContext::MakeWithFallback( + context, SkColorTypeToGrColorType(targetCT), nullptr, SkBackingFit::kExact, + this->dimensions()); if (!renderTargetContext) { return nullptr; } @@ -272,13 +272,9 @@ sk_sp SkImage::MakeFromYUVATexturesCopy(GrContext* ctx, SkISize imageSize, GrSurfaceOrigin imageOrigin, sk_sp imageColorSpace) { - const int width = imageSize.width(); - const int height = imageSize.height(); - - // Needs to create a render target in order to draw to it for the yuv->rgb conversion. - auto renderTargetContext = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, width, height, GrColorType::kRGBA_8888, - std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin); + auto renderTargetContext = GrRenderTargetContext::Make( + ctx, GrColorType::kRGBA_8888, std::move(imageColorSpace), SkBackingFit::kExact, + imageSize, 1, GrMipMapped::kNo, GrProtected::kNo, imageOrigin); if (!renderTargetContext) { return nullptr; } diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp index 12ed864fe4..f134477505 100644 --- a/src/image/SkImage_GpuYUVA.cpp +++ b/src/image/SkImage_GpuYUVA.cpp @@ -142,9 +142,9 @@ void SkImage_GpuYUVA::flattenToRGB(GrRecordingContext* context) const { } // Needs to create a render target in order to draw to it for the yuv->rgb conversion. - auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888, - this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin); + auto renderTargetContext = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, this->refColorSpace(), SkBackingFit::kExact, + this->dimensions(), 1, GrMipMapped::kNo, GrProtected::kNo, fOrigin); if (!renderTargetContext) { return; } diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp index 6f620a1b73..d1fc8fe23b 100644 --- a/src/image/SkSurface_Gpu.cpp +++ b/src/image/SkSurface_Gpu.cpp @@ -357,17 +357,10 @@ sk_sp SkSurface::MakeRenderTarget(GrRecordingContext* context, GrColorType grColorType = SkColorTypeToGrColorType(c.colorType()); - auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, - c.width(), - c.height(), - grColorType, - c.refColorSpace(), - c.sampleCount(), - GrMipMapped(c.isMipMapped()), - c.origin(), - &c.surfaceProps(), - budgeted, - c.isProtected()); + auto rtc = GrRenderTargetContext::Make( + context, grColorType, c.refColorSpace(), SkBackingFit::kExact, + {c.width(), c.height()}, c.sampleCount(), GrMipMapped(c.isMipMapped()), c.isProtected(), + c.origin(), budgeted, &c.surfaceProps()); if (!rtc) { return nullptr; } diff --git a/tests/BulkRectTest.cpp b/tests/BulkRectTest.cpp index 9dbf81261e..3e6d741fe2 100644 --- a/tests/BulkRectTest.cpp +++ b/tests/BulkRectTest.cpp @@ -13,8 +13,8 @@ #include "tests/Test.h" static std::unique_ptr new_RTC(GrContext* context) { - return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 128, 128, - GrColorType::kRGBA_8888, nullptr); + return GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {128, 128}); } sk_sp create_proxy(GrContext* context) { diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp index d1373d0682..13a696f91f 100644 --- a/tests/ClearTest.cpp +++ b/tests/ClearTest.cpp @@ -61,8 +61,8 @@ static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t } std::unique_ptr newRTC(GrContext* context, int w, int h) { - return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h, - GrColorType::kRGBA_8888, nullptr); + return GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {w, h}); } static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) { diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp index 40a85786ff..ccf54d7395 100644 --- a/tests/DefaultPathRendererTest.cpp +++ b/tests/DefaultPathRendererTest.cpp @@ -84,9 +84,9 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) { GrStyle style(SkStrokeRec::kFill_InitStyle); { - auto rtc = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, kBigSize/2 + 1, kBigSize/2 + 1, - GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, + {kBigSize/2 + 1, kBigSize/2 + 1}); rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); @@ -103,8 +103,8 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) { } { - auto rtc = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, kBigSize, kBigSize, GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kBigSize, kBigSize}); rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); diff --git a/tests/DrawOpAtlasTest.cpp b/tests/DrawOpAtlasTest.cpp index b5c04cb522..f2f1e45499 100644 --- a/tests/DrawOpAtlasTest.cpp +++ b/tests/DrawOpAtlasTest.cpp @@ -192,8 +192,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrAtlasTextOpPreparation, reporter, ctxInfo) auto textContext = drawingManager->getTextContext(); auto opMemoryPool = context->priv().opMemoryPool(); - auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 32, 32, - GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {32, 32}); SkPaint paint; paint.setColor(SK_ColorRED); diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp index db81945634..6af9ba1a16 100644 --- a/tests/GrCCPRTest.cpp +++ b/tests/GrCCPRTest.cpp @@ -64,9 +64,9 @@ public: CCPRPathDrawer(sk_sp ctx, skiatest::Reporter* reporter, DoStroke doStroke) : fCtx(ctx) , fCCPR(fCtx->priv().drawingManager()->getCoverageCountingPathRenderer()) - , fRTC(fCtx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, kCanvasSize, kCanvasSize, GrColorType::kRGBA_8888, - nullptr)) + , fRTC(GrRenderTargetContext::Make( + fCtx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, + {kCanvasSize, kCanvasSize})) , fDoStroke(DoStroke::kYes == doStroke) { if (!fCCPR) { ERRORF(reporter, "ccpr not enabled in GrContext for ccpr tests"); diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp index f88b2f85db..6f04c508d8 100644 --- a/tests/GrMeshTest.cpp +++ b/tests/GrMeshTest.cpp @@ -90,8 +90,9 @@ static void run_test(GrContext* context, const char* testName, skiatest::Reporte DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); - auto rtc = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, kImageWidth, kImageHeight, GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, + {kImageWidth, kImageHeight}); if (!rtc) { ERRORF(reporter, "could not create render target context."); return; diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp index 13c4628cc4..1d8a42a854 100644 --- a/tests/GrPipelineDynamicStateTest.cpp +++ b/tests/GrPipelineDynamicStateTest.cpp @@ -183,8 +183,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo GrContext* context = ctxInfo.grContext(); GrResourceProvider* rp = context->priv().resourceProvider(); - auto rtc = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, kScreenSize, kScreenSize, GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, + {kScreenSize, kScreenSize}); if (!rtc) { ERRORF(reporter, "could not create render target context."); return; diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp index 8d04bfa121..e973dcda03 100644 --- a/tests/GrSurfaceTest.cpp +++ b/tests/GrSurfaceTest.cpp @@ -323,9 +323,10 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) { { std::unique_ptr surfCtx; if (renderable == GrRenderable::kYes) { - surfCtx = context->priv().makeDeferredRenderTargetContext( - fit, desc.fWidth, desc.fHeight, combo.fColorType, nullptr, - 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr); + surfCtx = GrRenderTargetContext::Make( + context, combo.fColorType, nullptr, fit, + {desc.fWidth, desc.fHeight}, 1, GrMipMapped::kNo, + GrProtected::kNo, kTopLeft_GrSurfaceOrigin); } else { surfCtx = GrSurfaceContext::Make( context, {desc.fWidth, desc.fHeight}, combo.fFormat, diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp index 45dbac9816..3d439d844d 100644 --- a/tests/LazyProxyTest.cpp +++ b/tests/LazyProxyTest.cpp @@ -211,11 +211,11 @@ DEF_GPUTEST(LazyProxyTest, reporter, /* options */) { for (bool nullTexture : {false, true}) { LazyProxyTest test(reporter); ctx->priv().addOnFlushCallbackObject(&test); - auto rtc = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100, - GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {100, 100}); REPORTER_ASSERT(reporter, rtc); - auto mockAtlas = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, 10, 10, GrColorType::kAlpha_F16, nullptr); + auto mockAtlas = GrRenderTargetContext::Make( + ctx.get(), GrColorType::kAlpha_F16, nullptr, SkBackingFit::kExact, {10, 10}); REPORTER_ASSERT(reporter, mockAtlas); rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()), LazyProxyTest::Op::Make(ctx.get(), proxyProvider, &test, nullTexture)); @@ -386,8 +386,8 @@ DEF_GPUTEST(LazyProxyFailedInstantiationTest, reporter, /* options */) { sk_sp ctx = GrContext::MakeMock(&mockOptions, GrContextOptions()); GrProxyProvider* proxyProvider = ctx->priv().proxyProvider(); for (bool failInstantiation : {false, true}) { - auto rtc = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100, - GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {100, 100}); REPORTER_ASSERT(reporter, rtc); rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad), diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp index 6480649b77..12f9bc0c71 100644 --- a/tests/OnFlushCallbackTest.cpp +++ b/tests/OnFlushCallbackTest.cpp @@ -440,11 +440,9 @@ private: static sk_sp make_upstream_image(GrContext* context, AtlasObject* object, int start, sk_sp atlasProxy, SkAlphaType atlasAlphaType) { - auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, - 3* kDrawnTileSize, - kDrawnTileSize, - GrColorType::kRGBA_8888, - nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, + {3 * kDrawnTileSize, kDrawnTileSize}); rtc->clear(nullptr, { 1, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); @@ -557,8 +555,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) { static const int kFinalWidth = 6*kDrawnTileSize; static const int kFinalHeight = kDrawnTileSize; - auto rtc = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, kFinalWidth, kFinalHeight, GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, + {kFinalWidth, kFinalHeight}); rtc->clear(nullptr, SK_PMColor4fWHITE, GrRenderTargetContext::CanClearFullscreen::kYes); diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp index 44961d459c..676b8037e9 100644 --- a/tests/PathRendererCacheTests.cpp +++ b/tests/PathRendererCacheTests.cpp @@ -79,9 +79,9 @@ static void test_path(skiatest::Reporter* reporter, ctx->setResourceCacheLimit(8000000); GrResourceCache* cache = ctx->priv().getResourceCache(); - auto rtc = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, - kTopLeft_GrSurfaceOrigin); + auto rtc = GrRenderTargetContext::Make( + ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {800, 800}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!rtc) { return; } diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index acfa54d0a9..305202d9a2 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -144,8 +144,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { GrGpu* gpu = context->priv().getGpu(); #endif - auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr); + auto renderTargetContext = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {1, 1}); if (!renderTargetContext) { ERRORF(reporter, "Could not create render target context."); return; diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index f7c80e2cb8..cfe00d6bda 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -159,8 +159,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) { for (bool makeClone : {false, true}) { for (int parentCnt = 0; parentCnt < 2; parentCnt++) { - auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr); + auto renderTargetContext = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {1, 1}); { sk_sp proxy = proxyProvider->createProxy( format, desc, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin, @@ -482,8 +482,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorOptimizationValidationTest, repor // Make the destination context for the test. static constexpr int kRenderSize = 256; - auto rtc = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, + {kRenderSize, kRenderSize}); GrProcessorTestData::ProxyInfo proxies[2]; if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) { @@ -716,8 +717,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ProcessorCloneTest, reporter, ctxInfo) { // Make the destination context for the test. static constexpr int kRenderSize = 1024; - auto rtc = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr); + auto rtc = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, + {kRenderSize, kRenderSize}); GrProcessorTestData::ProxyInfo proxies[2]; if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) { diff --git a/tests/ProgramsTest.cpp b/tests/ProgramsTest.cpp index fc611aa681..97c00c1bf9 100644 --- a/tests/ProgramsTest.cpp +++ b/tests/ProgramsTest.cpp @@ -155,14 +155,10 @@ static std::unique_ptr random_render_target_context(GrCon // Above could be 0 if msaa isn't supported. sampleCnt = SkTMax(1, sampleCnt); - return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, - kRenderTargetWidth, - kRenderTargetHeight, - GrColorType::kRGBA_8888, - nullptr, - sampleCnt, - GrMipMapped::kNo, - origin); + return GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, + {kRenderTargetWidth, kRenderTargetHeight}, sampleCnt, GrMipMapped::kNo, + GrProtected::kNo, origin); } #if GR_TEST_UTILS @@ -324,12 +320,9 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma GrPrepareForExternalIORequests()); // Validate that GrFPs work correctly without an input. - auto renderTargetContext = - context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, - kRenderTargetWidth, - kRenderTargetHeight, - GrColorType::kRGBA_8888, - nullptr); + auto renderTargetContext = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, + {kRenderTargetWidth, kRenderTargetHeight}); if (!renderTargetContext) { SkDebugf("Could not allocate a renderTargetContext"); return false; diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index 7c66850b23..2eacffe59e 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -30,8 +30,8 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context, sk_sp rectProxy, GrColorType colorType, SkAlphaType alphaType, uint32_t expectedPixelValues[]) { - auto rtContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, rectProxy->width(), rectProxy->height(), colorType, nullptr); + auto rtContext = GrRenderTargetContext::Make( + context, colorType, nullptr, SkBackingFit::kExact, rectProxy->dimensions()); for (auto filter : {GrSamplerState::Filter::kNearest, GrSamplerState::Filter::kBilerp, GrSamplerState::Filter::kMipMap}) { diff --git a/tests/RenderTargetContextTest.cpp b/tests/RenderTargetContextTest.cpp index ce7a39fbef..395a09a384 100644 --- a/tests/RenderTargetContextTest.cpp +++ b/tests/RenderTargetContextTest.cpp @@ -17,8 +17,8 @@ static const int kSize = 64; static std::unique_ptr get_rtc(GrContext* ctx) { - return ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, kSize, - GrColorType::kRGBA_8888, nullptr); + return GrRenderTargetContext::Make( + ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kSize, kSize}); } static void check_instantiation_status(skiatest::Reporter* reporter, diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp index f42bc22a75..b54026bbeb 100644 --- a/tests/SRGBReadWritePixelsTest.cpp +++ b/tests/SRGBReadWritePixelsTest.cpp @@ -190,10 +190,10 @@ static std::unique_ptr make_data() { static std::unique_ptr make_surface_context(Encoding contextEncoding, GrContext* context, skiatest::Reporter* reporter) { - auto surfaceContext = context->priv().makeDeferredRenderTargetContext( - SkBackingFit::kExact, kW, kH, GrColorType::kRGBA_8888, - encoding_as_color_space(contextEncoding), 1, GrMipMapped::kNo, - kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kNo, GrProtected::kNo); + auto surfaceContext = GrRenderTargetContext::Make( + context, GrColorType::kRGBA_8888, encoding_as_color_space(contextEncoding), + SkBackingFit::kExact, {kW, kH}, 1, GrMipMapped::kNo, GrProtected::kNo, + kBottomLeft_GrSurfaceOrigin, SkBudgeted::kNo); if (!surfaceContext) { ERRORF(reporter, "Could not create %s surface context.", encoding_as_str(contextEncoding)); } diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp index 0a382c836d..acd97b17dc 100644 --- a/tests/TessellatingPathRendererTests.cpp +++ b/tests/TessellatingPathRendererTests.cpp @@ -733,9 +733,9 @@ static void test_path(GrContext* ctx, DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { GrContext* ctx = ctxInfo.grContext(); - auto rtc = ctx->priv().makeDeferredRenderTargetContext( - SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, - kTopLeft_GrSurfaceOrigin); + auto rtc = GrRenderTargetContext::Make( + ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {800, 800}, 1, + GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin); if (!rtc) { return; }