Move makeDeferredRenderTargetContext calls to factory on RTC.

Change-Id: Iaa8f5829d9f8650ff27a60f75fb2216f016ab85e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/262058
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
Greg Daniel 2020-01-07 15:41:53 -05:00 committed by Skia Commit-Bot
parent 511124e5a8
commit 1c16b43033
54 changed files with 350 additions and 598 deletions

View File

@ -282,8 +282,8 @@ public:
const int kDrawsPerLoop = 32; const int kDrawsPerLoop = 32;
for (int i = 0; i < loops; ++i) { for (int i = 0; i < loops; ++i) {
auto rtc = context->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kApprox, 100, 100, GrColorType::kRGBA_8888, p3); context, GrColorType::kRGBA_8888, p3, SkBackingFit::kApprox, {100, 100});
SkASSERT(rtc); SkASSERT(rtc);
for (int j = 0; j < kDrawsPerLoop; ++j) { for (int j = 0; j < kDrawsPerLoop; ++j) {

View File

@ -245,9 +245,10 @@ void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* c
// Draw the test to an off-screen, top-down render target. // Draw the test to an off-screen, top-down render target.
GrColorType rtcColorType = rtc->colorInfo().colorType(); GrColorType rtcColorType = rtc->colorInfo().colorType();
if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext( if (auto topLeftRTC = GrRenderTargetContext::Make(
SkBackingFit::kExact, 100, 200, rtcColorType, nullptr, 1, ctx, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, 1,
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) { GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin, SkBudgeted::kYes,
nullptr)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT, topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes); GrRenderTargetContext::CanClearFullscreen::kYes);
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0)); 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. // Draw the test to an off-screen, bottom-up render target.
if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext( if (auto topLeftRTC = GrRenderTargetContext::Make(
SkBackingFit::kExact, 100, 200, rtcColorType, nullptr, 1, ctx, rtcColorType, nullptr, SkBackingFit::kExact, {100, 200}, 1,
GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) { GrMipMapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin, SkBudgeted::kYes,
nullptr)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT, topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes); GrRenderTargetContext::CanClearFullscreen::kYes);
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0)); topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));

View File

@ -320,9 +320,9 @@ DrawResult SampleLocationsGM::onDraw(
return DrawResult::kSkip; return DrawResult::kSkip;
} }
auto offscreenRTC = ctx->priv().makeDeferredRenderTargetContext( auto offscreenRTC = GrRenderTargetContext::Make(
SkBackingFit::kExact, 200, 200, rtc->colorInfo().colorType(), nullptr, ctx, rtc->colorInfo().colorType(), nullptr, SkBackingFit::kExact, {200, 200},
rtc->numSamples(), GrMipMapped::kNo, fOrigin); rtc->numSamples(), GrMipMapped::kNo, GrProtected::kNo, fOrigin);
if (!offscreenRTC) { if (!offscreenRTC) {
*errorMsg = "Failed to create offscreen render target."; *errorMsg = "Failed to create offscreen render target.";
return DrawResult::kFail; return DrawResult::kFail;

View File

@ -226,9 +226,9 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
const GrReducedClip& reducedClip, GrPaint&& paint) { const GrReducedClip& reducedClip, GrPaint&& paint) {
const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2; const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2;
const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2; const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2;
auto maskRTC(ctx->priv().makeDeferredRenderTargetContextWithFallback( auto maskRTC = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, kCoverRect.width() + padRight, kCoverRect.height() + padBottom, ctx, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact,
GrColorType::kAlpha_8, nullptr)); {kCoverRect.width() + padRight, kCoverRect.height() + padBottom});
if (!maskRTC) { if (!maskRTC) {
return; return;
} }

View File

@ -114,43 +114,6 @@ protected:
*/ */
void addOnFlushCallbackObject(GrOnFlushCallbackObject*); 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<GrRenderTargetContext> makeDeferredRenderTargetContext(
SkBackingFit fit,
int width,
int height,
GrColorType colorType,
sk_sp<SkColorSpace> 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<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
SkBackingFit fit,
int width,
int height,
GrColorType colorType,
sk_sp<SkColorSpace> 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(); } GrAuditTrail* auditTrail() { return fAuditTrail.get(); }
GrRecordingContext* asRecordingContext() override { return this; } GrRecordingContext* asRecordingContext() override { return this; }

View File

@ -183,9 +183,10 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) {
GrOpMemoryPool* pool = ctx->priv().opMemoryPool(); GrOpMemoryPool* pool = ctx->priv().opMemoryPool();
auto ccbuff = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, int width = this->width();
this->width(), this->height(), int height = this->height();
GrColorType::kAlpha_F16, nullptr); auto ccbuff = GrRenderTargetContext::Make(
ctx, GrColorType::kAlpha_F16, nullptr, SkBackingFit::kApprox, {width, height});
SkASSERT(ccbuff); SkASSERT(ccbuff);
ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT, ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes); GrRenderTargetContext::CanClearFullscreen::kYes);

View File

@ -107,19 +107,9 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingCo
int finalH, int finalH,
sk_sp<SkColorSpace> finalCS, sk_sp<SkColorSpace> finalCS,
SkBackingFit dstFit) { SkBackingFit dstFit) {
auto renderTargetContext = GrRenderTargetContext::Make(
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( context, srcColorType, std::move(finalCS), dstFit, {finalW, finalH}, 1,
dstFit, GrMipMapped::kNo, srcProxy->isProtected(), srcProxy->origin());
finalW,
finalH,
srcColorType,
std::move(finalCS),
1,
GrMipMapped::kNo,
srcProxy->origin(),
nullptr,
SkBudgeted::kYes,
srcProxy->isProtected());
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }
@ -167,18 +157,9 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingConte
SkBackingFit fit) { SkBackingFit fit) {
SkASSERT(srcRect.width() <= finalW && srcRect.height() <= finalH); SkASSERT(srcRect.width() <= finalW && srcRect.height() <= finalH);
auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext( auto dstRenderTargetContext = GrRenderTargetContext::Make(
fit, context, srcColorType, std::move(finalCS), fit, srcRect.size(), 1,
srcRect.width(), GrMipMapped::kNo, srcProxy->isProtected(), srcProxy->origin());
srcRect.height(),
srcColorType,
std::move(finalCS),
1,
GrMipMapped::kNo,
srcProxy->origin(),
nullptr,
SkBudgeted::kYes,
srcProxy->isProtected());
if (!dstRenderTargetContext) { if (!dstRenderTargetContext) {
return nullptr; return nullptr;
} }
@ -302,19 +283,10 @@ static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) { for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY); 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 = GrRenderTargetContext::Make(
dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext( context, srcColorType, finalCS, SkBackingFit::kApprox,
SkBackingFit::kApprox, {dstRect.fRight, dstRect.fBottom}, 1, GrMipMapped::kNo, srcProxy->isProtected(),
dstRect.fRight, srcProxy->origin());
dstRect.fBottom,
srcColorType,
finalCS,
1,
GrMipMapped::kNo,
srcProxy->origin(),
nullptr,
SkBudgeted::kYes,
srcProxy->isProtected());
if (!dstRenderTargetContext) { if (!dstRenderTargetContext) {
return nullptr; return nullptr;
} }
@ -392,9 +364,9 @@ static std::unique_ptr<GrRenderTargetContext> reexpand(
srcRenderTargetContext = nullptr; // no longer needed srcRenderTargetContext = nullptr; // no longer needed
auto dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext( auto dstRenderTargetContext = GrRenderTargetContext::Make(
fit, finalW, finalH, srcColorType, std::move(finalCS), 1, GrMipMapped::kNo, context, srcColorType, std::move(finalCS), fit, {finalW, finalH}, 1,
srcProxy->origin()); GrMipMapped::kNo, srcProxy->isProtected(), srcProxy->origin());
if (!dstRenderTargetContext) { if (!dstRenderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -575,18 +575,10 @@ sk_sp<SkSpecialImage> SkImageFilter_Base::DrawWithFP(GrRecordingContext* context
paint.addColorFragmentProcessor(std::move(fp)); paint.addColorFragmentProcessor(std::move(fp));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
auto renderTargetContext = auto renderTargetContext = GrRenderTargetContext::Make(
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, context, SkColorTypeToGrColorType(colorType), sk_ref_sp(colorSpace),
bounds.width(), SkBackingFit::kApprox, bounds.size(), 1, GrMipMapped::kNo, isProtected,
bounds.height(), kBottomLeft_GrSurfaceOrigin);
SkColorTypeToGrColorType(colorType),
sk_ref_sp(colorSpace),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
nullptr,
SkBudgeted::kYes,
isProtected);
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -169,9 +169,10 @@ sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrRecordingContext* c
if (!context) { if (!context) {
return nullptr; return nullptr;
} }
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( auto renderTargetContext = GrRenderTargetContext::Make(
SkBackingFit::kApprox, width, height, colorType, std::move(colorSpace), 1, context, colorType, std::move(colorSpace), SkBackingFit::kApprox, {width, height}, 1,
GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props); GrMipMapped::kNo, GrProtected::kNo, kBottomLeft_GrSurfaceOrigin, SkBudgeted::kYes,
props);
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -103,8 +103,8 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context, sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context,
const SkMatrix& inMatrix, const SkMatrix& inMatrix,
const SkIRect& bounds) const { const SkIRect& bounds) const {
auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback( auto rtContext = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kApprox, bounds.width(), bounds.height(), GrColorType::kAlpha_8, nullptr); context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox, bounds.size());
if (!rtContext) { if (!rtContext) {
return nullptr; return nullptr;
} }

View File

@ -403,18 +403,9 @@ sk_sp<SkSpecialImage> ArithmeticImageFilterImpl::filterImageGPU(
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
auto renderTargetContext = auto renderTargetContext = GrRenderTargetContext::Make(
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox, bounds.size(),
bounds.width(), 1, GrMipMapped::kNo, isProtected, kBottomLeft_GrSurfaceOrigin);
bounds.height(),
ctx.grColorType(),
ctx.refColorSpace(),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
nullptr,
SkBudgeted::kYes,
isProtected);
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -363,18 +363,9 @@ sk_sp<SkSpecialImage> SkDisplacementMapEffectImpl::onFilterImage(const Context&
SkMatrix matrix; SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y())); matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
auto renderTargetContext = auto renderTargetContext = GrRenderTargetContext::Make(
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox,
bounds.width(), bounds.size(), 1, GrMipMapped::kNo, isProtected, kBottomLeft_GrSurfaceOrigin);
bounds.height(),
ctx.grColorType(),
ctx.refColorSpace(),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
nullptr,
SkBudgeted::kYes,
isProtected);
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -488,18 +488,10 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context)); sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy); SkASSERT(inputProxy);
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( auto renderTargetContext = GrRenderTargetContext::Make(
SkBackingFit::kApprox, context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox,
offsetBounds.width(), offsetBounds.size(), 1, GrMipMapped::kNo, inputProxy->isProtected(),
offsetBounds.height(), kBottomLeft_GrSurfaceOrigin);
ctx.grColorType(),
ctx.refColorSpace(),
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
nullptr,
SkBudgeted::kYes,
inputProxy->isProtected());
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -567,18 +567,9 @@ static sk_sp<SkSpecialImage> apply_morphology(
SkASSERT(radius.width() > 0 || radius.height() > 0); SkASSERT(radius.width() > 0 || radius.height() > 0);
if (radius.fWidth > 0) { if (radius.fWidth > 0) {
auto dstRTContext = context->priv().makeDeferredRenderTargetContext( auto dstRTContext = GrRenderTargetContext::Make(
SkBackingFit::kApprox, context, colorType, colorSpace, SkBackingFit::kApprox, rect.size(), 1,
rect.width(), GrMipMapped::kNo, srcTexture->isProtected(), kBottomLeft_GrSurfaceOrigin);
rect.height(),
colorType,
colorSpace,
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
nullptr,
SkBudgeted::kYes,
srcTexture->isProtected());
if (!dstRTContext) { if (!dstRTContext) {
return nullptr; return nullptr;
} }
@ -596,18 +587,9 @@ static sk_sp<SkSpecialImage> apply_morphology(
srcRect = dstRect; srcRect = dstRect;
} }
if (radius.fHeight > 0) { if (radius.fHeight > 0) {
auto dstRTContext = context->priv().makeDeferredRenderTargetContext( auto dstRTContext = GrRenderTargetContext::Make(
SkBackingFit::kApprox, context, colorType, colorSpace, SkBackingFit::kApprox, rect.size(), 1,
rect.width(), GrMipMapped::kNo, srcTexture->isProtected(), kBottomLeft_GrSurfaceOrigin);
rect.height(),
colorType,
colorSpace,
1,
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
nullptr,
SkBudgeted::kYes,
srcTexture->isProtected());
if (!dstRTContext) { if (!dstRTContext) {
return nullptr; return nullptr;
} }

View File

@ -310,9 +310,8 @@ sk_sp<SkSpecialImage> SkXfermodeImageFilterImpl::filterImageGPU(
paint.setPorterDuffXPFactory(SkBlendMode::kSrc); paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( auto renderTargetContext = GrRenderTargetContext::Make(
SkBackingFit::kApprox, bounds.width(), bounds.height(), ctx.grColorType(), context, ctx.grColorType(), ctx.refColorSpace(), SkBackingFit::kApprox, bounds.size());
ctx.refColorSpace());
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -185,9 +185,9 @@ static std::unique_ptr<GrRenderTargetContext> create_mask_GPU(GrRecordingContext
// the same. We should offset our filter within the render target and expand the size as needed // 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. // to guarantee at least 1px of padding on all sides.
auto approxSize = GrResourceProvider::MakeApprox(maskRect.size()); auto approxSize = GrResourceProvider::MakeApprox(maskRect.size());
auto rtContext = context->priv().makeDeferredRenderTargetContextWithFallback( auto rtContext = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, approxSize.width(), approxSize.height(), GrColorType::kAlpha_8, context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, approxSize, sampleCnt,
nullptr, sampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!rtContext) { if (!rtContext) {
return nullptr; return nullptr;
} }

View File

@ -354,18 +354,10 @@ sk_sp<GrTextureProxy> GrClipStackClip::createAlphaClipMask(GrRecordingContext* c
return proxy; return proxy;
} }
auto isProtected = proxy->isProtected(); auto rtc = GrRenderTargetContext::MakeWithFallback(
auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox, context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kApprox,
reducedClip.width(), {reducedClip.width(), reducedClip.height()}, 1, GrMipMapped::kNo, proxy->isProtected(),
reducedClip.height(), kTopLeft_GrSurfaceOrigin);
GrColorType::kAlpha_8,
nullptr,
1,
GrMipMapped::kNo,
kTopLeft_GrSurfaceOrigin,
nullptr,
SkBudgeted::kYes,
isProtected);
if (!rtc) { if (!rtc) {
return nullptr; return nullptr;
} }

View File

@ -40,33 +40,6 @@ void GrContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBO
fContext->addOnFlushCallbackObject(onFlushCBObject); fContext->addOnFlushCallbackObject(onFlushCBObject);
} }
std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
SkBackingFit fit,
int width,
int height,
GrColorType colorType,
sk_sp<SkColorSpace> 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<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
SkBackingFit fit, int width, int height, GrColorType colorType,
sk_sp<SkColorSpace> 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<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext( std::unique_ptr<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
const GrBackendTexture& tex, const GrBackendTexture& tex,
GrSurfaceOrigin origin, GrSurfaceOrigin origin,

View File

@ -69,43 +69,6 @@ public:
*/ */
void addOnFlushCallbackObject(GrOnFlushCallbackObject*); 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<GrRenderTargetContext> makeDeferredRenderTargetContext(
SkBackingFit fit,
int width,
int height,
GrColorType,
sk_sp<SkColorSpace> 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<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
SkBackingFit fit,
int width,
int height,
GrColorType,
sk_sp<SkColorSpace> 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(); } GrAuditTrail* auditTrail() { return fContext->auditTrail(); }
/** /**

View File

@ -167,101 +167,6 @@ void GrRecordingContext::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlu
this->drawingManager()->addOnFlushCallbackObject(onFlushCBObject); this->drawingManager()->addOnFlushCallbackObject(onFlushCBObject);
} }
std::unique_ptr<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
SkBackingFit fit,
int width,
int height,
GrColorType colorType,
sk_sp<SkColorSpace> 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<GrTextureProxy> 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<GrRenderTargetContext>
GrRecordingContext::makeDeferredRenderTargetContextWithFallback(SkBackingFit fit,
int width,
int height,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt,
GrMipMapped mipMapped,
GrSurfaceOrigin origin,
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted,
GrProtected isProtected) {
SkASSERT(sampleCnt > 0);
std::unique_ptr<GrRenderTargetContext> 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<const GrCaps> GrRecordingContextPriv::refCaps() const { sk_sp<const GrCaps> GrRecordingContextPriv::refCaps() const {
return fContext->refCaps(); return fContext->refCaps();
@ -271,49 +176,6 @@ void GrRecordingContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* o
fContext->addOnFlushCallbackObject(onFlushCBObject); fContext->addOnFlushCallbackObject(onFlushCBObject);
} }
std::unique_ptr<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
SkBackingFit fit,
int width,
int height,
GrColorType colorType,
sk_sp<SkColorSpace> 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<GrRenderTargetContext>
GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback(
SkBackingFit fit,
int width,
int height,
GrColorType colorType,
sk_sp<SkColorSpace> 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() { GrContext* GrRecordingContextPriv::backdoor() {
return (GrContext*) fContext; return (GrContext*) fContext;
} }

View File

@ -66,43 +66,6 @@ public:
*/ */
void addOnFlushCallbackObject(GrOnFlushCallbackObject*); 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<GrRenderTargetContext> makeDeferredRenderTargetContext(
SkBackingFit fit,
int width,
int height,
GrColorType,
sk_sp<SkColorSpace> 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<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
SkBackingFit fit,
int width,
int height,
GrColorType,
sk_sp<SkColorSpace> 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(); } GrAuditTrail* auditTrail() { return fContext->auditTrail(); }
// CONTEXT TODO: remove this backdoor // CONTEXT TODO: remove this backdoor

View File

@ -137,6 +137,115 @@ private:
GrDrawingManager* fDrawingManager; GrDrawingManager* fDrawingManager;
}; };
std::unique_ptr<GrRenderTargetContext> GrRenderTargetContext::Make(
GrRecordingContext* context,
GrColorType colorType,
sk_sp<SkColorSpace> 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<GrTextureProxy> 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<GrRenderTargetContext>(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> GrRenderTargetContext::Make(
GrRecordingContext* context,
GrColorType colorType,
sk_sp<SkColorSpace> 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> GrRenderTargetContext::MakeWithFallback(
GrRecordingContext* context,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
SkBackingFit fit,
const SkISize& dimensions,
int sampleCnt,
GrMipMapped mipMapped,
GrProtected isProtected,
GrSurfaceOrigin origin,
SkBudgeted budgeted,
const SkSurfaceProps* surfaceProps) {
std::unique_ptr<GrRenderTargetContext> 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 // 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 // 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 // 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()); srcRectToDraw = SkRect::MakeWH(srcRect.width(), srcRect.height());
} }
tempRTC = direct->priv().makeDeferredRenderTargetContext( tempRTC = GrRenderTargetContext::Make(
SkBackingFit::kApprox, srcRect.width(), srcRect.height(), direct, this->colorInfo().colorType(), info.refColorSpace(),
this->colorInfo().colorType(), info.refColorSpace(), 1, GrMipMapped::kNo, SkBackingFit::kApprox, srcRect.size(), 1, GrMipMapped::kNo, GrProtected::kNo,
kTopLeft_GrSurfaceOrigin); kTopLeft_GrSurfaceOrigin);
if (!tempRTC) { if (!tempRTC) {
callback(context, nullptr); callback(context, nullptr);
@ -1757,10 +1866,9 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
return; return;
} }
SkRect srcRectToDraw = SkRect::Make(srcRect); SkRect srcRectToDraw = SkRect::Make(srcRect);
tempRTC = direct->priv().makeDeferredRenderTargetContext( tempRTC = GrRenderTargetContext::Make(
SkBackingFit::kApprox, dstSize.width(), dstSize.height(), direct, this->colorInfo().colorType(), dstColorSpace, SkBackingFit::kApprox,
this->colorInfo().colorType(), dstColorSpace, 1, GrMipMapped::kNo, dstSize, 1, GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
kTopLeft_GrSurfaceOrigin);
if (!tempRTC) { if (!tempRTC) {
callback(context, nullptr); callback(context, nullptr);
return; return;
@ -1781,17 +1889,17 @@ void GrRenderTargetContext::asyncRescaleAndReadPixelsYUV420(SkYUVColorSpace yuvC
return; return;
} }
auto yRTC = direct->priv().makeDeferredRenderTargetContextWithFallback( auto yRTC = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kApprox, dstSize.width(), dstSize.height(), GrColorType::kAlpha_8, direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, dstSize, 1,
dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
int halfW = dstSize.width()/2; int halfW = dstSize.width()/2;
int halfH = dstSize.height()/2; int halfH = dstSize.height()/2;
auto uRTC = direct->priv().makeDeferredRenderTargetContextWithFallback( auto uRTC = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kApprox, halfW, halfH, GrColorType::kAlpha_8, dstColorSpace, 1, direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH}, 1,
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
auto vRTC = direct->priv().makeDeferredRenderTargetContextWithFallback( auto vRTC = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kApprox, halfW, halfH, GrColorType::kAlpha_8, dstColorSpace, 1, direct, GrColorType::kAlpha_8, dstColorSpace, SkBackingFit::kApprox, {halfW, halfH}, 1,
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!yRTC || !uRTC || !vRTC) { if (!yRTC || !uRTC || !vRTC) {
callback(context, nullptr); callback(context, nullptr);
return; return;

View File

@ -57,6 +57,28 @@ class SkVertices;
*/ */
class GrRenderTargetContext : public GrSurfaceContext { class GrRenderTargetContext : public GrSurfaceContext {
public: public:
static std::unique_ptr<GrRenderTargetContext> Make(
GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, 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<GrRenderTargetContext> Make(
GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, 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<GrRenderTargetContext> MakeWithFallback(
GrRecordingContext*, GrColorType, sk_sp<SkColorSpace>, 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<GrRenderTargetProxy>, GrColorType, GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>, GrColorType,
GrSurfaceOrigin, GrSwizzle readSwizzle, GrSwizzle outSwizzle, GrSurfaceOrigin, GrSwizzle readSwizzle, GrSwizzle outSwizzle,
sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpsTask = true); sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpsTask = true);

View File

@ -56,10 +56,18 @@ std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(GrRecordingContext* con
} }
std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make( std::unique_ptr<GrSurfaceContext> GrSurfaceContext::Make(
GrRecordingContext* context, const SkISize& dimensions, const GrBackendFormat& format, GrRecordingContext* context,
GrRenderable renderable, int renderTargetSampleCnt, GrMipMapped mipMapped, const SkISize& dimensions,
GrProtected isProtected, GrSurfaceOrigin origin, GrColorType colorType, const GrBackendFormat& format,
SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace, SkBackingFit fit, GrRenderable renderable,
int renderTargetSampleCnt,
GrMipMapped mipMapped,
GrProtected isProtected,
GrSurfaceOrigin origin,
GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
SkBackingFit fit,
SkBudgeted budgeted) { SkBudgeted budgeted) {
auto config = context->priv().caps()->getConfigFromBackendFormat(format, colorType); auto config = context->priv().caps()->getConfigFromBackendFormat(format, colorType);
if (config == kUnknown_GrPixelConfig) { if (config == kUnknown_GrPixelConfig) {
@ -193,9 +201,9 @@ bool GrSurfaceContext::readPixels(const GrImageInfo& origDstInfo, void* dst, siz
canvas2DFastPath ? GrColorType::kRGBA_8888 : this->colorInfo().colorType(); canvas2DFastPath ? GrColorType::kRGBA_8888 : this->colorInfo().colorType();
sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr : this->colorInfo().refColorSpace(); sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr : this->colorInfo().refColorSpace();
auto tempCtx = direct->priv().makeDeferredRenderTargetContext( auto tempCtx = GrRenderTargetContext::Make(
SkBackingFit::kApprox, dstInfo.width(), dstInfo.height(), colorType, std::move(cs), direct, colorType, std::move(cs), SkBackingFit::kApprox, dstInfo.dimensions(),
1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes); 1, GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!tempCtx) { if (!tempCtx) {
return false; return false;
} }
@ -550,9 +558,9 @@ std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(
auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(), srcAlphaType, cs.get(), auto xform = GrColorSpaceXform::Make(this->colorInfo().colorSpace(), srcAlphaType, cs.get(),
kPremul_SkAlphaType); kPremul_SkAlphaType);
// We'll fall back to kRGBA_8888 if half float not supported. // We'll fall back to kRGBA_8888 if half float not supported.
auto linearRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback( auto linearRTC = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, srcW, srcH, GrColorType::kRGBA_F16, cs, 1, GrMipMapped::kNo, fContext, GrColorType::kRGBA_F16, cs, SkBackingFit::kExact, {srcW, srcH}, 1,
kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!linearRTC) { if (!linearRTC) {
return nullptr; return nullptr;
} }
@ -601,9 +609,9 @@ std::unique_ptr<GrRenderTargetContext> GrSurfaceContext::rescale(
input->colorInfo().alphaType(), cs.get(), input->colorInfo().alphaType(), cs.get(),
info.alphaType()); info.alphaType());
} }
tempB = fContext->priv().makeDeferredRenderTargetContextWithFallback( tempB = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, nextW, nextH, colorType, std::move(cs), 1, GrMipMapped::kNo, fContext, colorType, std::move(cs), SkBackingFit::kExact, {nextW, nextH}, 1,
kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!tempB) { if (!tempB) {
return nullptr; return nullptr;
} }

View File

@ -19,6 +19,7 @@
#include "src/gpu/GrOpsTask.h" #include "src/gpu/GrOpsTask.h"
#include "src/gpu/GrProxyProvider.h" #include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRecordingContextPriv.h" #include "src/gpu/GrRecordingContextPriv.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrStencilAttachment.h" #include "src/gpu/GrStencilAttachment.h"
#include "src/gpu/GrSurfacePriv.h" #include "src/gpu/GrSurfacePriv.h"
#include "src/gpu/GrTexturePriv.h" #include "src/gpu/GrTexturePriv.h"
@ -329,10 +330,10 @@ sk_sp<GrTextureProxy> GrSurfaceProxy::Copy(GrRecordingContext* context,
} }
} }
if (src->asTextureProxy()) { if (src->asTextureProxy()) {
auto dstContext = context->priv().makeDeferredRenderTargetContext( auto dstContext = GrRenderTargetContext::Make(context, colorType, nullptr, fit,
fit, width, height, colorType, nullptr, 1, mipMapped, src->origin(), nullptr, {width, height}, format, 1,
budgeted); mipMapped, src->isProtected(), origin,
budgeted, nullptr);
if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) { if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) {
return dstContext->asTextureProxyRef(); return dstContext->asTextureProxyRef();
} }

View File

@ -50,9 +50,9 @@ sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrRecordingContext* context,
} }
} }
auto copyRTC = context->priv().makeDeferredRenderTargetContextWithFallback( auto copyRTC = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, dstRect.width(), dstRect.height(), colorType, nullptr, 1, context, colorType, nullptr, SkBackingFit::kExact, copyParams.fDimensions, 1,
mipMapped, inputProxy->origin()); mipMapped, inputProxy->isProtected(), inputProxy->origin());
if (!copyRTC) { if (!copyRTC) {
return nullptr; return nullptr;
} }

View File

@ -157,9 +157,9 @@ sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrRecordingContext* ctx,
} }
// TODO: investigate preallocating mip maps here // TODO: investigate preallocating mip maps here
auto renderTargetContext = ctx->priv().makeDeferredRenderTargetContext( auto renderTargetContext = GrRenderTargetContext::Make(
SkBackingFit::kExact, desc.fWidth, desc.fHeight, colorType, nullptr, 1, ctx, colorType, nullptr, SkBackingFit::kExact, {desc.fWidth, desc.fHeight}, 1,
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -148,10 +148,10 @@ std::unique_ptr<GrRenderTargetContext> SkGpuDevice::MakeRenderTargetContext(
// This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case // This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case
// they need to be exact. // they need to be exact.
return context->priv().makeDeferredRenderTargetContext( return GrRenderTargetContext::Make(
SkBackingFit::kExact, origInfo.width(), origInfo.height(), context, SkColorTypeToGrColorType(origInfo.colorType()), origInfo.refColorSpace(),
SkColorTypeToGrColorType(origInfo.colorType()), origInfo.refColorSpace(), sampleCount, SkBackingFit::kExact, origInfo.dimensions(), sampleCount, mipMapped, GrProtected::kNo,
mipMapped, origin, surfaceProps, budgeted); origin, budgeted, surfaceProps);
} }
sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg, sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg,
@ -1627,18 +1627,12 @@ SkBaseDevice* SkGpuDevice::onCreateDevice(const CreateInfo& cinfo, const SkPaint
SkASSERT(cinfo.fInfo.colorType() != kRGBA_1010102_SkColorType); SkASSERT(cinfo.fInfo.colorType() != kRGBA_1010102_SkColorType);
auto rtc = fContext->priv().makeDeferredRenderTargetContextWithFallback( auto rtc = GrRenderTargetContext::MakeWithFallback(
fit, fContext.get(), SkColorTypeToGrColorType(cinfo.fInfo.colorType()),
cinfo.fInfo.width(), fRenderTargetContext->colorInfo().refColorSpace(), fit, cinfo.fInfo.dimensions(),
cinfo.fInfo.height(), fRenderTargetContext->numSamples(), GrMipMapped::kNo,
SkColorTypeToGrColorType(cinfo.fInfo.colorType()), fRenderTargetContext->asSurfaceProxy()->isProtected(), kBottomLeft_GrSurfaceOrigin,
fRenderTargetContext->colorInfo().refColorSpace(), SkBudgeted::kYes, &props);
fRenderTargetContext->numSamples(),
GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin,
&props,
SkBudgeted::kYes,
fRenderTargetContext->asSurfaceProxy()->isProtected());
if (!rtc) { if (!rtc) {
return nullptr; return nullptr;
} }

View File

@ -41,14 +41,10 @@
const SkImageInfo ii = SkImageInfo::Make(kSize, kSize, const SkImageInfo ii = SkImageInfo::Make(kSize, kSize,
kRGBA_8888_SkColorType, kPremul_SkAlphaType); kRGBA_8888_SkColorType, kPremul_SkAlphaType);
auto readRTC = auto readRTC = GrRenderTargetContext::Make(
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, context, kColorType, nullptr, SkBackingFit::kExact, {kSize, kSize});
kSize, kSize, auto tempRTC = GrRenderTargetContext::Make(
kColorType, nullptr); context, kColorType, nullptr, SkBackingFit::kExact, {kSize, kSize});
auto tempRTC =
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
kSize, kSize,
kColorType, nullptr);
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) { if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
return false; return false;
} }

View File

@ -55,9 +55,8 @@ uniform half blurRadius;
// TODO: this could be SkBackingFit::kApprox, but: // TODO: this could be SkBackingFit::kApprox, but:
// 1) The texture coords would need to be updated. // 1) The texture coords would need to be updated.
// 2) We would have to use GrTextureDomain::kClamp_Mode for the GaussianBlur. // 2) We would have to use GrTextureDomain::kClamp_Mode for the GaussianBlur.
auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback( auto rtc = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, dimensions.fWidth, dimensions.fHeight, context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions);
GrColorType::kAlpha_8, nullptr);
if (!rtc) { if (!rtc) {
return nullptr; return nullptr;
} }

View File

@ -49,10 +49,10 @@ public:
const SkImageInfo ii = const SkImageInfo ii =
SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType); SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
auto readRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, auto readRTC = GrRenderTargetContext::Make(context, kColorType, nullptr,
kSize, kColorType, nullptr); SkBackingFit::kExact, {kSize, kSize});
auto tempRTC = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, auto tempRTC = GrRenderTargetContext::Make(context, kColorType, nullptr,
kSize, kColorType, nullptr); SkBackingFit::kExact, {kSize, kSize});
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) { if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
return false; return false;
} }

View File

@ -56,9 +56,8 @@ public:
// TODO: this could be SkBackingFit::kApprox, but: // TODO: this could be SkBackingFit::kApprox, but:
// 1) The texture coords would need to be updated. // 1) The texture coords would need to be updated.
// 2) We would have to use GrTextureDomain::kClamp_Mode for the GaussianBlur. // 2) We would have to use GrTextureDomain::kClamp_Mode for the GaussianBlur.
auto rtc = context->priv().makeDeferredRenderTargetContextWithFallback( auto rtc = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, dimensions.fWidth, dimensions.fHeight, context, GrColorType::kAlpha_8, nullptr, SkBackingFit::kExact, dimensions);
GrColorType::kAlpha_8, nullptr);
if (!rtc) { if (!rtc) {
return nullptr; return nullptr;
} }

View File

@ -253,8 +253,8 @@ GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) {
} }
// Setup dummy SkPaint / GrPaint / GrRenderTargetContext // Setup dummy SkPaint / GrPaint / GrRenderTargetContext
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1024, 1024, auto rtc = GrRenderTargetContext::Make(
GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {1024, 1024});
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);

View File

@ -81,9 +81,9 @@ sk_sp<SkImage> SkImage_Gpu::onMakeColorTypeAndColorSpace(GrRecordingContext* con
targetCS.get(), this->alphaType()); targetCS.get(), this->alphaType());
SkASSERT(xform || targetCT != this->colorType()); SkASSERT(xform || targetCT != this->colorType());
auto renderTargetContext = context->priv().makeDeferredRenderTargetContextWithFallback( auto renderTargetContext = GrRenderTargetContext::MakeWithFallback(
SkBackingFit::kExact, this->width(), this->height(), SkColorTypeToGrColorType(targetCT), context, SkColorTypeToGrColorType(targetCT), nullptr, SkBackingFit::kExact,
nullptr); this->dimensions());
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }
@ -272,13 +272,9 @@ sk_sp<SkImage> SkImage::MakeFromYUVATexturesCopy(GrContext* ctx,
SkISize imageSize, SkISize imageSize,
GrSurfaceOrigin imageOrigin, GrSurfaceOrigin imageOrigin,
sk_sp<SkColorSpace> imageColorSpace) { sk_sp<SkColorSpace> imageColorSpace) {
const int width = imageSize.width(); auto renderTargetContext = GrRenderTargetContext::Make(
const int height = imageSize.height(); ctx, GrColorType::kRGBA_8888, std::move(imageColorSpace), SkBackingFit::kExact,
imageSize, 1, GrMipMapped::kNo, GrProtected::kNo, imageOrigin);
// 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);
if (!renderTargetContext) { if (!renderTargetContext) {
return nullptr; return nullptr;
} }

View File

@ -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. // Needs to create a render target in order to draw to it for the yuv->rgb conversion.
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( auto renderTargetContext = GrRenderTargetContext::Make(
SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888, context, GrColorType::kRGBA_8888, this->refColorSpace(), SkBackingFit::kExact,
this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin); this->dimensions(), 1, GrMipMapped::kNo, GrProtected::kNo, fOrigin);
if (!renderTargetContext) { if (!renderTargetContext) {
return; return;
} }

View File

@ -357,17 +357,10 @@ sk_sp<SkSurface> SkSurface::MakeRenderTarget(GrRecordingContext* context,
GrColorType grColorType = SkColorTypeToGrColorType(c.colorType()); GrColorType grColorType = SkColorTypeToGrColorType(c.colorType());
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, auto rtc = GrRenderTargetContext::Make(
c.width(), context, grColorType, c.refColorSpace(), SkBackingFit::kExact,
c.height(), {c.width(), c.height()}, c.sampleCount(), GrMipMapped(c.isMipMapped()), c.isProtected(),
grColorType, c.origin(), budgeted, &c.surfaceProps());
c.refColorSpace(),
c.sampleCount(),
GrMipMapped(c.isMipMapped()),
c.origin(),
&c.surfaceProps(),
budgeted,
c.isProtected());
if (!rtc) { if (!rtc) {
return nullptr; return nullptr;
} }

View File

@ -13,8 +13,8 @@
#include "tests/Test.h" #include "tests/Test.h"
static std::unique_ptr<GrRenderTargetContext> new_RTC(GrContext* context) { static std::unique_ptr<GrRenderTargetContext> new_RTC(GrContext* context) {
return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 128, 128, return GrRenderTargetContext::Make(
GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {128, 128});
} }
sk_sp<GrSurfaceProxy> create_proxy(GrContext* context) { sk_sp<GrSurfaceProxy> create_proxy(GrContext* context) {

View File

@ -61,8 +61,8 @@ static bool check_rect(GrRenderTargetContext* rtc, const SkIRect& rect, uint32_t
} }
std::unique_ptr<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) { std::unique_ptr<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h, return GrRenderTargetContext::Make(
GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {w, h});
} }
static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) { static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {

View File

@ -84,9 +84,9 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
GrStyle style(SkStrokeRec::kFill_InitStyle); GrStyle style(SkStrokeRec::kFill_InitStyle);
{ {
auto rtc = ctx->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kApprox, kBigSize/2 + 1, kBigSize/2 + 1, ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
GrColorType::kRGBA_8888, nullptr); {kBigSize/2 + 1, kBigSize/2 + 1});
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); 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( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kExact, kBigSize, kBigSize, GrColorType::kRGBA_8888, nullptr); ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kBigSize, kBigSize});
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);

View File

@ -192,8 +192,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrAtlasTextOpPreparation, reporter, ctxInfo)
auto textContext = drawingManager->getTextContext(); auto textContext = drawingManager->getTextContext();
auto opMemoryPool = context->priv().opMemoryPool(); auto opMemoryPool = context->priv().opMemoryPool();
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 32, 32, auto rtc = GrRenderTargetContext::Make(
GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {32, 32});
SkPaint paint; SkPaint paint;
paint.setColor(SK_ColorRED); paint.setColor(SK_ColorRED);

View File

@ -64,9 +64,9 @@ public:
CCPRPathDrawer(sk_sp<GrContext> ctx, skiatest::Reporter* reporter, DoStroke doStroke) CCPRPathDrawer(sk_sp<GrContext> ctx, skiatest::Reporter* reporter, DoStroke doStroke)
: fCtx(ctx) : fCtx(ctx)
, fCCPR(fCtx->priv().drawingManager()->getCoverageCountingPathRenderer()) , fCCPR(fCtx->priv().drawingManager()->getCoverageCountingPathRenderer())
, fRTC(fCtx->priv().makeDeferredRenderTargetContext( , fRTC(GrRenderTargetContext::Make(
SkBackingFit::kExact, kCanvasSize, kCanvasSize, GrColorType::kRGBA_8888, fCtx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
nullptr)) {kCanvasSize, kCanvasSize}))
, fDoStroke(DoStroke::kYes == doStroke) { , fDoStroke(DoStroke::kYes == doStroke) {
if (!fCCPR) { if (!fCCPR) {
ERRORF(reporter, "ccpr not enabled in GrContext for ccpr tests"); ERRORF(reporter, "ccpr not enabled in GrContext for ccpr tests");

View File

@ -90,8 +90,9 @@ static void run_test(GrContext* context, const char* testName, skiatest::Reporte
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) { DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext(); GrContext* context = ctxInfo.grContext();
auto rtc = context->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kExact, kImageWidth, kImageHeight, GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kImageWidth, kImageHeight});
if (!rtc) { if (!rtc) {
ERRORF(reporter, "could not create render target context."); ERRORF(reporter, "could not create render target context.");
return; return;

View File

@ -183,8 +183,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo
GrContext* context = ctxInfo.grContext(); GrContext* context = ctxInfo.grContext();
GrResourceProvider* rp = context->priv().resourceProvider(); GrResourceProvider* rp = context->priv().resourceProvider();
auto rtc = context->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kExact, kScreenSize, kScreenSize, GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kScreenSize, kScreenSize});
if (!rtc) { if (!rtc) {
ERRORF(reporter, "could not create render target context."); ERRORF(reporter, "could not create render target context.");
return; return;

View File

@ -323,9 +323,10 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
{ {
std::unique_ptr<GrSurfaceContext> surfCtx; std::unique_ptr<GrSurfaceContext> surfCtx;
if (renderable == GrRenderable::kYes) { if (renderable == GrRenderable::kYes) {
surfCtx = context->priv().makeDeferredRenderTargetContext( surfCtx = GrRenderTargetContext::Make(
fit, desc.fWidth, desc.fHeight, combo.fColorType, nullptr, context, combo.fColorType, nullptr, fit,
1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr); {desc.fWidth, desc.fHeight}, 1, GrMipMapped::kNo,
GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
} else { } else {
surfCtx = GrSurfaceContext::Make( surfCtx = GrSurfaceContext::Make(
context, {desc.fWidth, desc.fHeight}, combo.fFormat, context, {desc.fWidth, desc.fHeight}, combo.fFormat,

View File

@ -211,11 +211,11 @@ DEF_GPUTEST(LazyProxyTest, reporter, /* options */) {
for (bool nullTexture : {false, true}) { for (bool nullTexture : {false, true}) {
LazyProxyTest test(reporter); LazyProxyTest test(reporter);
ctx->priv().addOnFlushCallbackObject(&test); ctx->priv().addOnFlushCallbackObject(&test);
auto rtc = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100, auto rtc = GrRenderTargetContext::Make(
GrColorType::kRGBA_8888, nullptr); ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {100, 100});
REPORTER_ASSERT(reporter, rtc); REPORTER_ASSERT(reporter, rtc);
auto mockAtlas = ctx->priv().makeDeferredRenderTargetContext( auto mockAtlas = GrRenderTargetContext::Make(
SkBackingFit::kExact, 10, 10, GrColorType::kAlpha_F16, nullptr); ctx.get(), GrColorType::kAlpha_F16, nullptr, SkBackingFit::kExact, {10, 10});
REPORTER_ASSERT(reporter, mockAtlas); REPORTER_ASSERT(reporter, mockAtlas);
rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()), rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()),
LazyProxyTest::Op::Make(ctx.get(), proxyProvider, &test, nullTexture)); LazyProxyTest::Op::Make(ctx.get(), proxyProvider, &test, nullTexture));
@ -386,8 +386,8 @@ DEF_GPUTEST(LazyProxyFailedInstantiationTest, reporter, /* options */) {
sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions()); sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider(); GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
for (bool failInstantiation : {false, true}) { for (bool failInstantiation : {false, true}) {
auto rtc = ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, 100, 100, auto rtc = GrRenderTargetContext::Make(
GrColorType::kRGBA_8888, nullptr); ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {100, 100});
REPORTER_ASSERT(reporter, rtc); REPORTER_ASSERT(reporter, rtc);
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad), rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),

View File

@ -440,11 +440,9 @@ private:
static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start, static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
sk_sp<GrTextureProxy> atlasProxy, sk_sp<GrTextureProxy> atlasProxy,
SkAlphaType atlasAlphaType) { SkAlphaType atlasAlphaType) {
auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, auto rtc = GrRenderTargetContext::Make(
3* kDrawnTileSize, context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
kDrawnTileSize, {3 * kDrawnTileSize, kDrawnTileSize});
GrColorType::kRGBA_8888,
nullptr);
rtc->clear(nullptr, { 1, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes); 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 kFinalWidth = 6*kDrawnTileSize;
static const int kFinalHeight = kDrawnTileSize; static const int kFinalHeight = kDrawnTileSize;
auto rtc = context->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kApprox, kFinalWidth, kFinalHeight, GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
{kFinalWidth, kFinalHeight});
rtc->clear(nullptr, SK_PMColor4fWHITE, GrRenderTargetContext::CanClearFullscreen::kYes); rtc->clear(nullptr, SK_PMColor4fWHITE, GrRenderTargetContext::CanClearFullscreen::kYes);

View File

@ -79,9 +79,9 @@ static void test_path(skiatest::Reporter* reporter,
ctx->setResourceCacheLimit(8000000); ctx->setResourceCacheLimit(8000000);
GrResourceCache* cache = ctx->priv().getResourceCache(); GrResourceCache* cache = ctx->priv().getResourceCache();
auto rtc = ctx->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {800, 800}, 1,
kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!rtc) { if (!rtc) {
return; return;
} }

View File

@ -144,8 +144,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
GrGpu* gpu = context->priv().getGpu(); GrGpu* gpu = context->priv().getGpu();
#endif #endif
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( auto renderTargetContext = GrRenderTargetContext::Make(
SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {1, 1});
if (!renderTargetContext) { if (!renderTargetContext) {
ERRORF(reporter, "Could not create render target context."); ERRORF(reporter, "Could not create render target context.");
return; return;

View File

@ -159,8 +159,8 @@ DEF_GPUTEST_FOR_ALL_CONTEXTS(ProcessorRefTest, reporter, ctxInfo) {
for (bool makeClone : {false, true}) { for (bool makeClone : {false, true}) {
for (int parentCnt = 0; parentCnt < 2; parentCnt++) { for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
auto renderTargetContext = context->priv().makeDeferredRenderTargetContext( auto renderTargetContext = GrRenderTargetContext::Make(
SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {1, 1});
{ {
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy( sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
format, desc, GrRenderable::kNo, 1, kTopLeft_GrSurfaceOrigin, 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. // Make the destination context for the test.
static constexpr int kRenderSize = 256; static constexpr int kRenderSize = 256;
auto rtc = context->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kRenderSize, kRenderSize});
GrProcessorTestData::ProxyInfo proxies[2]; GrProcessorTestData::ProxyInfo proxies[2];
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) { 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. // Make the destination context for the test.
static constexpr int kRenderSize = 1024; static constexpr int kRenderSize = 1024;
auto rtc = context->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr); context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
{kRenderSize, kRenderSize});
GrProcessorTestData::ProxyInfo proxies[2]; GrProcessorTestData::ProxyInfo proxies[2];
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) { if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {

View File

@ -155,14 +155,10 @@ static std::unique_ptr<GrRenderTargetContext> random_render_target_context(GrCon
// Above could be 0 if msaa isn't supported. // Above could be 0 if msaa isn't supported.
sampleCnt = SkTMax(1, sampleCnt); sampleCnt = SkTMax(1, sampleCnt);
return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, return GrRenderTargetContext::Make(
kRenderTargetWidth, context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
kRenderTargetHeight, {kRenderTargetWidth, kRenderTargetHeight}, sampleCnt, GrMipMapped::kNo,
GrColorType::kRGBA_8888, GrProtected::kNo, origin);
nullptr,
sampleCnt,
GrMipMapped::kNo,
origin);
} }
#if GR_TEST_UTILS #if GR_TEST_UTILS
@ -324,12 +320,9 @@ bool GrDrawingManager::ProgramUnitTest(GrContext* context, int maxStages, int ma
GrPrepareForExternalIORequests()); GrPrepareForExternalIORequests());
// Validate that GrFPs work correctly without an input. // Validate that GrFPs work correctly without an input.
auto renderTargetContext = auto renderTargetContext = GrRenderTargetContext::Make(
context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact,
kRenderTargetWidth, {kRenderTargetWidth, kRenderTargetHeight});
kRenderTargetHeight,
GrColorType::kRGBA_8888,
nullptr);
if (!renderTargetContext) { if (!renderTargetContext) {
SkDebugf("Could not allocate a renderTargetContext"); SkDebugf("Could not allocate a renderTargetContext");
return false; return false;

View File

@ -30,8 +30,8 @@
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context, static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
sk_sp<GrTextureProxy> rectProxy, GrColorType colorType, sk_sp<GrTextureProxy> rectProxy, GrColorType colorType,
SkAlphaType alphaType, uint32_t expectedPixelValues[]) { SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
auto rtContext = context->priv().makeDeferredRenderTargetContext( auto rtContext = GrRenderTargetContext::Make(
SkBackingFit::kExact, rectProxy->width(), rectProxy->height(), colorType, nullptr); context, colorType, nullptr, SkBackingFit::kExact, rectProxy->dimensions());
for (auto filter : {GrSamplerState::Filter::kNearest, for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kBilerp, GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) { GrSamplerState::Filter::kMipMap}) {

View File

@ -17,8 +17,8 @@
static const int kSize = 64; static const int kSize = 64;
static std::unique_ptr<GrRenderTargetContext> get_rtc(GrContext* ctx) { static std::unique_ptr<GrRenderTargetContext> get_rtc(GrContext* ctx) {
return ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, kSize, return GrRenderTargetContext::Make(
GrColorType::kRGBA_8888, nullptr); ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kSize, kSize});
} }
static void check_instantiation_status(skiatest::Reporter* reporter, static void check_instantiation_status(skiatest::Reporter* reporter,

View File

@ -190,10 +190,10 @@ static std::unique_ptr<uint32_t[]> make_data() {
static std::unique_ptr<GrSurfaceContext> make_surface_context(Encoding contextEncoding, static std::unique_ptr<GrSurfaceContext> make_surface_context(Encoding contextEncoding,
GrContext* context, GrContext* context,
skiatest::Reporter* reporter) { skiatest::Reporter* reporter) {
auto surfaceContext = context->priv().makeDeferredRenderTargetContext( auto surfaceContext = GrRenderTargetContext::Make(
SkBackingFit::kExact, kW, kH, GrColorType::kRGBA_8888, context, GrColorType::kRGBA_8888, encoding_as_color_space(contextEncoding),
encoding_as_color_space(contextEncoding), 1, GrMipMapped::kNo, SkBackingFit::kExact, {kW, kH}, 1, GrMipMapped::kNo, GrProtected::kNo,
kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kNo, GrProtected::kNo); kBottomLeft_GrSurfaceOrigin, SkBudgeted::kNo);
if (!surfaceContext) { if (!surfaceContext) {
ERRORF(reporter, "Could not create %s surface context.", encoding_as_str(contextEncoding)); ERRORF(reporter, "Could not create %s surface context.", encoding_as_str(contextEncoding));
} }

View File

@ -733,9 +733,9 @@ static void test_path(GrContext* ctx,
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) { DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
GrContext* ctx = ctxInfo.grContext(); GrContext* ctx = ctxInfo.grContext();
auto rtc = ctx->priv().makeDeferredRenderTargetContext( auto rtc = GrRenderTargetContext::Make(
SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox, {800, 800}, 1,
kTopLeft_GrSurfaceOrigin); GrMipMapped::kNo, GrProtected::kNo, kTopLeft_GrSurfaceOrigin);
if (!rtc) { if (!rtc) {
return; return;
} }