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;
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) {

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.
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));

View File

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

View File

@ -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;
}

View File

@ -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<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(); }
GrRecordingContext* asRecordingContext() override { return this; }

View File

@ -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);

View File

@ -107,19 +107,9 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingCo
int finalH,
sk_sp<SkColorSpace> 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<GrRenderTargetContext> 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<GrTextureProxy> 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<GrRenderTargetContext> 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;
}

View File

@ -575,18 +575,10 @@ sk_sp<SkSpecialImage> 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;
}

View File

@ -169,9 +169,10 @@ sk_sp<SkSpecialSurface> 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;
}

View File

@ -103,8 +103,8 @@ void SkAlphaThresholdFilterImpl::flatten(SkWriteBuffer& buffer) const {
sk_sp<GrTextureProxy> 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;
}

View File

@ -403,18 +403,9 @@ sk_sp<SkSpecialImage> 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;
}

View File

@ -363,18 +363,9 @@ sk_sp<SkSpecialImage> 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;
}

View File

@ -488,18 +488,10 @@ sk_sp<SkSpecialImage> SkLightingImageFilterInternal::filterImageGPU(
sk_sp<GrTextureProxy> 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;
}

View File

@ -567,18 +567,9 @@ static sk_sp<SkSpecialImage> 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<SkSpecialImage> 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;
}

View File

@ -310,9 +310,8 @@ sk_sp<SkSpecialImage> 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;
}

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

View File

@ -354,18 +354,10 @@ sk_sp<GrTextureProxy> 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;
}

View File

@ -40,33 +40,6 @@ void GrContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlushCBO
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(
const GrBackendTexture& tex,
GrSurfaceOrigin origin,

View File

@ -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<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(); }
/**

View File

@ -167,101 +167,6 @@ void GrRecordingContext::addOnFlushCallbackObject(GrOnFlushCallbackObject* onFlu
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 {
return fContext->refCaps();
@ -271,49 +176,6 @@ void GrRecordingContextPriv::addOnFlushCallbackObject(GrOnFlushCallbackObject* o
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() {
return (GrContext*) fContext;
}

View File

@ -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<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(); }
// CONTEXT TODO: remove this backdoor

View File

@ -137,6 +137,115 @@ private:
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
// 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;

View File

@ -57,6 +57,28 @@ class SkVertices;
*/
class GrRenderTargetContext : public GrSurfaceContext {
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,
GrSurfaceOrigin, GrSwizzle readSwizzle, GrSwizzle outSwizzle,
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(
GrRecordingContext* context, const SkISize& dimensions, const GrBackendFormat& format,
GrRenderable renderable, int renderTargetSampleCnt, GrMipMapped mipMapped,
GrProtected isProtected, GrSurfaceOrigin origin, GrColorType colorType,
SkAlphaType alphaType, sk_sp<SkColorSpace> 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<SkColorSpace> 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<SkColorSpace> 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<GrRenderTargetContext> 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<GrRenderTargetContext> 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;
}

View File

@ -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<GrTextureProxy> 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();
}

View File

@ -50,9 +50,9 @@ sk_sp<GrTextureProxy> 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;
}

View File

@ -157,9 +157,9 @@ sk_sp<GrTextureProxy> 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;
}

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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -81,9 +81,9 @@ sk_sp<SkImage> 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> SkImage::MakeFromYUVATexturesCopy(GrContext* ctx,
SkISize imageSize,
GrSurfaceOrigin imageOrigin,
sk_sp<SkColorSpace> 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;
}

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.
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;
}

View File

@ -357,17 +357,10 @@ sk_sp<SkSurface> 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;
}

View File

@ -13,8 +13,8 @@
#include "tests/Test.h"
static std::unique_ptr<GrRenderTargetContext> 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<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) {
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) {

View File

@ -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);

View File

@ -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);

View File

@ -64,9 +64,9 @@ public:
CCPRPathDrawer(sk_sp<GrContext> 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");

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) {
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;

View File

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

View File

@ -323,9 +323,10 @@ DEF_GPUTEST(InitialTextureClear, reporter, baseOptions) {
{
std::unique_ptr<GrSurfaceContext> 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,

View File

@ -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<GrContext> 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),

View File

@ -440,11 +440,9 @@ private:
static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
sk_sp<GrTextureProxy> 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);

View File

@ -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;
}

View File

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

View File

@ -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<GrTextureProxy> 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)) {

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

View File

@ -30,8 +30,8 @@
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
sk_sp<GrTextureProxy> 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}) {

View File

@ -17,8 +17,8 @@
static const int kSize = 64;
static std::unique_ptr<GrRenderTargetContext> 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,

View File

@ -190,10 +190,10 @@ static std::unique_ptr<uint32_t[]> make_data() {
static std::unique_ptr<GrSurfaceContext> 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));
}

View File

@ -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;
}