Reland "Simplify GrRTC::clean APIs"

This reverts commit 4730f29993.

Reason for revert: Fix WIP

Original change's description:
> Revert "Simplify GrRTC::clean APIs"
> 
> This reverts commit 6cbd7c2e57.
> 
> Reason for revert: mac/generated files failures
> 
> Original change's description:
> > Simplify GrRTC::clean APIs
> > 
> > The CanClearFullscreen enum type is removed. Most usages of clear() had
> > kYes because a null scissor rect was provided, or had kNo because the
> > scissor was really critical to the behavior. A few places did provide a
> > scissor and kYes (e.g. for initializing the target).
> > 
> > To simplify this, the public GrRTC has two variants of clear(). One with
> > only a color (for fullscreen clears), and one with a rect for partial
> > clears. The private API also adds a clearAtLeast() function that replaces
> > the several cases where we'd have a scissor but could expand to fullscreen.
> > 
> > I find the current control flow in internalClear() to be hard to
> > follow (albeit I was the one to make it that way...), but later CLs
> > will improve it.
> > 
> > Bug: skia:10205
> > Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> 
> TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com
> 
> Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:10205
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>

# Not skipping CQ checks because this is a reland.

Bug: skia:10205
Change-Id: Id5db153d7c2500279cca8478818b66f67a53e143
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291844
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2020-05-26 16:57:38 -04:00 committed by Skia Commit-Bot
parent 55822f17bd
commit 81d4172d86
29 changed files with 147 additions and 204 deletions

View File

@ -242,7 +242,7 @@ private:
// Test.
void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* canvas) {
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SK_PMColor4fBLACK);
// Draw the test directly to the frame buffer.
rtc->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
@ -254,8 +254,7 @@ void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* c
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->clear(SK_PMColor4fTRANSPARENT);
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
rtc->drawTexture(GrNoClip(), topLeftRTC->readSurfaceView(), rtc->colorInfo().alphaType(),
@ -270,8 +269,7 @@ void ClockwiseGM::onDraw(GrContext* ctx, GrRenderTargetContext* rtc, SkCanvas* c
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->clear(SK_PMColor4fTRANSPARENT);
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, true, 100));
rtc->drawTexture(GrNoClip(), topLeftRTC->readSurfaceView(), rtc->colorInfo().alphaType(),

View File

@ -354,7 +354,7 @@ DrawResult SampleLocationsGM::onDraw(
0xffff>()
);
offscreenRTC->clear(nullptr, {0,1,0,1}, GrRenderTargetContext::CanClearFullscreen::kYes);
offscreenRTC->clear({0,1,0,1});
// Stencil.
offscreenRTC->priv().testingOnly_addDrawOp(

View File

@ -238,7 +238,7 @@ void WindowRectanglesMaskGM::visualizeAlphaMask(GrContext* ctx, GrRenderTargetCo
// Draw a checker pattern into the alpha mask so we can visualize the regions left untouched by
// the clip mask generation.
this->stencilCheckerboard(maskRTC.get(), true);
maskRTC->clear(nullptr, SK_PMColor4fWHITE, GrRenderTargetContext::CanClearFullscreen::kYes);
maskRTC->clear(SK_PMColor4fWHITE);
GrPaint stencilPaint;
stencilPaint.setCoverageSetOpXPFactory(SkRegion::kDifference_Op, false);
maskRTC->priv().stencilRect(make_stencil_only_clip(), &GrUserStencilSettings::kUnused,
@ -288,7 +288,7 @@ void WindowRectanglesMaskGM::stencilCheckerboard(GrRenderTargetContext* rtc, boo
0>()
);
rtc->priv().clearStencilClip(GrFixedClip::Disabled(), false);
rtc->priv().clearStencilClip(SkIRect::MakeSize(rtc->dimensions()), false);
for (int y = 0; y < kDeviceRect.height(); y += kMaskCheckerSize) {
for (int x = (y & 1) == flip ? 0 : kMaskCheckerSize;

View File

@ -435,6 +435,7 @@ static inline uint32_t Sk4f_toL32(const Sk4f& px) {
using SkPMColor4f = SkRGBA4f<kPremul_SkAlphaType>;
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT = { 0, 0, 0, 0 };
constexpr SkPMColor4f SK_PMColor4fBLACK = { 0, 0, 0, 1 };
constexpr SkPMColor4f SK_PMColor4fWHITE = { 1, 1, 1, 1 };
constexpr SkPMColor4f SK_PMColor4fILLEGAL = { SK_FloatNegativeInfinity,
SK_FloatNegativeInfinity,

View File

@ -198,8 +198,7 @@ void CCPRGeometryView::onDrawContent(SkCanvas* canvas) {
auto ccbuff = GrRenderTargetContext::Make(
ctx, GrColorType::kAlpha_F16, nullptr, SkBackingFit::kApprox, {width, height});
SkASSERT(ccbuff);
ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
ccbuff->clear(SK_PMColor4fTRANSPARENT);
ccbuff->priv().testingOnly_addDrawOp(pool->allocate<DrawCoverageCountOp>(this));
// Visualize coverage count in main canvas.

View File

@ -191,8 +191,7 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingConte
auto clear = [&](SkIRect rect) {
// Transform rect into the render target's coord system.
rect.offset(-rtcToSrcOffset);
dstRenderTargetContext->clear(&rect, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
dstRenderTargetContext->priv().clearAtLeast(rect, SK_PMColor4fTRANSPARENT);
};
if (!top.isEmpty()) {

View File

@ -242,13 +242,11 @@ static std::unique_ptr<GrRenderTargetContext> convolve_gaussian(GrRecordingConte
contentRect->offset(-rtcToSrcOffset);
if (!top.isEmpty()) {
dstRenderTargetContext->clear(&top, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
dstRenderTargetContext->priv().clearAtLeast(top, SK_PMColor4fTRANSPARENT);
}
if (!bottom.isEmpty()) {
dstRenderTargetContext->clear(&bottom, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
dstRenderTargetContext->priv().clearAtLeast(bottom, SK_PMColor4fTRANSPARENT);
}
if (mid.isEmpty()) {

View File

@ -110,8 +110,7 @@ GrSurfaceProxyView SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingCont
}
SkRegion::Iterator iter(fRegion);
rtContext->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtContext->clear(SK_PMColor4fTRANSPARENT);
GrFixedClip clip(SkIRect::MakeWH(bounds.width(), bounds.height()));
while (!iter.done()) {

View File

@ -589,7 +589,7 @@ static sk_sp<SkSpecialImage> apply_morphology(
dstRect.width(), radius.fHeight);
SkPMColor4f clearColor = MorphType::kErode == morphType
? SK_PMColor4fWHITE : SK_PMColor4fTRANSPARENT;
dstRTContext->clear(&clearRect, clearColor, GrRenderTargetContext::CanClearFullscreen::kNo);
dstRTContext->clear(clearRect, clearColor);
srcView = dstRTContext->readSurfaceView();
srcAlphaType = dstRTContext->colorInfo().alphaType();

View File

@ -13,7 +13,7 @@
#include "src/gpu/GrRectanizerPow2.h"
#include "src/gpu/GrRectanizerSkyline.h"
#include "src/gpu/GrRenderTarget.h"
#include "src/gpu/GrRenderTargetContext.h"
#include "src/gpu/GrRenderTargetContextPriv.h"
// Each Node covers a sub-rectangle of the final atlas. When a GrDynamicAtlas runs out of room, we
// create a new Node the same size as all combined nodes in the atlas as-is, and then place the new
@ -199,7 +199,6 @@ std::unique_ptr<GrRenderTargetContext> GrDynamicAtlas::instantiate(
}
SkIRect clearRect = SkIRect::MakeSize(fDrawBounds);
rtc->clear(&clearRect, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->priv().clearAtLeast(clearRect, SK_PMColor4fTRANSPARENT);
return rtc;
}

View File

@ -753,7 +753,15 @@ bool GrReducedClip::drawAlphaClipMask(GrRenderTargetContext* rtc) const {
// clear the part that we care about.
SkPMColor4f initialCoverage =
InitialState::kAllIn == this->initialState() ? SK_PMColor4fWHITE : SK_PMColor4fTRANSPARENT;
rtc->priv().clear(clip, initialCoverage, GrRenderTargetContext::CanClearFullscreen::kYes);
if (clip.hasWindowRectangles()) {
GrPaint paint;
paint.setColor4f(initialCoverage);
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
rtc->drawRect(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
SkRect::Make(clip.scissorRect()));
} else {
rtc->priv().clearAtLeast(clip.scissorRect(), initialCoverage);
}
// Set the matrix so that rendered clip elements are transformed to mask space from clip space.
SkMatrix translate;

View File

@ -479,32 +479,6 @@ void GrRenderTargetContext::discard() {
this->getOpsTask()->discard();
}
void GrRenderTargetContext::clear(const SkIRect* rect,
const SkPMColor4f& color,
CanClearFullscreen canClearFullscreen) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "clear", fContext);
AutoCheckFlush acf(this->drawingManager());
this->internalClear(rect ? GrFixedClip(*rect) : GrFixedClip::Disabled(), color,
canClearFullscreen);
}
void GrRenderTargetContextPriv::clear(const GrFixedClip& clip,
const SkPMColor4f& color,
CanClearFullscreen canClearFullscreen) {
ASSERT_SINGLE_OWNER_PRIV
RETURN_IF_ABANDONED_PRIV
SkDEBUGCODE(fRenderTargetContext->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContextPriv", "clear",
fRenderTargetContext->fContext);
AutoCheckFlush acf(fRenderTargetContext->drawingManager());
fRenderTargetContext->internalClear(clip, color, canClearFullscreen);
}
static void clear_to_grpaint(const SkPMColor4f& color, GrPaint* paint) {
paint->setColor4f(color);
if (color.isOpaque()) {
@ -517,19 +491,39 @@ static void clear_to_grpaint(const SkPMColor4f& color, GrPaint* paint) {
}
}
void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
// NOTE: We currently pass the premul color unmodified to the gpu, since we assume the GrRTC has a
// premul alpha type. If we ever support different alpha type render targets, this function should
// transform the color as appropriate.
void GrRenderTargetContext::internalClear(const SkIRect* scissor,
const SkPMColor4f& color,
CanClearFullscreen canClearFullscreen) {
bool isFull = false;
if (!clip.hasWindowRectangles()) {
// TODO: wrt the shouldInitializeTextures path, it would be more performant to
// only clear the entire target if we knew it had not been cleared before. As
// is this could end up doing a lot of redundant clears.
isFull = !clip.scissorEnabled() ||
(CanClearFullscreen::kYes == canClearFullscreen &&
(this->caps()->preferFullscreenClears() || this->caps()->shouldInitializeTextures())) ||
clip.scissorRect().contains(SkIRect::MakeWH(this->width(), this->height()));
bool upgradePartialToFull) {
ASSERT_SINGLE_OWNER
RETURN_IF_ABANDONED
SkDEBUGCODE(this->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContext", "clear", fContext);
// The clear will be fullscreen if no scissor is provided, or if the scissor is larger than
// the logical bounds of the render target, or if the special flag was provided that allows
// partial clears to upgrade to full (because it's a scratch resource and the caller knows
// anything outside the scissor doesn't matter, but if full screen clears aren't free, then
// the scissor is still provided so that fewer pixels are written to).
// TODO: wrt the shouldInitializeTextures path, it would be more performant to
// only clear the entire target if we knew it had not been cleared before. As
// is this could end up doing a lot of redundant clears.
GrScissorState scissorState;
if (scissor) {
// TODO(michaelludwig) - This will get simpler when GrScissorState knows the device dims
scissorState.set(*scissor);
if (!scissorState.intersect(SkIRect::MakeWH(this->width(), this->height()))) {
// The clear is offscreen, so skip it (normally this would be handled by addDrawOp,
// except clear ops are not draw ops).
return;
}
}
bool isFull = !scissorState.enabled() ||
scissorState.rect().contains(SkIRect::MakeWH(this->width(), this->height())) ||
(upgradePartialToFull && (this->caps()->preferFullscreenClears() ||
this->caps()->shouldInitializeTextures()));
if (isFull) {
GrOpsTask* opsTask = this->getOpsTask();
@ -554,20 +548,19 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip,
GrFillRectOp::MakeNonAARect(fContext, std::move(paint), SkMatrix::I(),
rtRect));
} else {
this->addOp(GrClearOp::Make(
fContext, SkIRect::MakeEmpty(), color, /* fullscreen */ true));
this->addOp(GrClearOp::Make(fContext, GrScissorState(), color, this->asSurfaceProxy()));
}
} else {
if (this->caps()->performPartialClearsAsDraws() || clip.hasWindowRectangles()) {
if (this->caps()->performPartialClearsAsDraws()) {
// performPartialClearsAsDraws() also returns true if any clear has to be a draw.
GrPaint paint;
clear_to_grpaint(color, &paint);
this->addDrawOp(clip,
this->addDrawOp(GrFixedClip::Disabled(),
GrFillRectOp::MakeNonAARect(fContext, std::move(paint), SkMatrix::I(),
SkRect::Make(clip.scissorRect())));
SkRect::Make(scissorState.rect())));
} else {
std::unique_ptr<GrOp> op(GrClearOp::Make(fContext, clip.scissorState(), color,
std::unique_ptr<GrOp> op(GrClearOp::Make(fContext, scissorState, color,
this->asSurfaceProxy()));
// This version of the clear op factory can return null if the clip doesn't intersect
// with the surface proxy's boundary
@ -717,14 +710,14 @@ GrRenderTargetContext::QuadOptimization GrRenderTargetContext::attemptQuadOptimi
drawBounds = quad->fDevice.bounds();
if (drawBounds.contains(rtRect)) {
// Fullscreen clear
this->clear(nullptr, *constColor, CanClearFullscreen::kYes);
this->clear(*constColor);
return QuadOptimization::kSubmitted;
} else if (GrClip::IsPixelAligned(drawBounds) &&
drawBounds.width() > 256 && drawBounds.height() > 256) {
// Scissor + clear (round shouldn't do anything since we are pixel aligned)
SkIRect scissorRect;
drawBounds.round(&scissorRect);
this->clear(&scissorRect, *constColor, CanClearFullscreen::kNo);
this->clear(scissorRect, *constColor);
return QuadOptimization::kSubmitted;
}
}
@ -956,7 +949,7 @@ void GrRenderTargetContext::setNeedsStencil(bool useMixedSamplesIfNotMSAA) {
if (this->caps()->performStencilClearsAsDraws()) {
// There is a driver bug with clearing stencil. We must use an op to manually clear the
// stencil buffer before the op that required 'setNeedsStencil'.
this->internalStencilClear(GrFixedClip::Disabled(), /* inside mask */ false);
this->internalStencilClear(nullptr, /* inside mask */ false);
} else {
this->getOpsTask()->setInitialStencilContent(
GrOpsTask::StencilContent::kUserBitsCleared);
@ -964,38 +957,30 @@ void GrRenderTargetContext::setNeedsStencil(bool useMixedSamplesIfNotMSAA) {
}
}
void GrRenderTargetContextPriv::clearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
ASSERT_SINGLE_OWNER_PRIV
RETURN_IF_ABANDONED_PRIV
SkDEBUGCODE(fRenderTargetContext->validate();)
GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContextPriv", "clearStencilClip",
fRenderTargetContext->fContext);
AutoCheckFlush acf(fRenderTargetContext->drawingManager());
fRenderTargetContext->internalStencilClear(clip, insideStencilMask);
}
void GrRenderTargetContext::internalStencilClear(const GrFixedClip& clip, bool insideStencilMask) {
void GrRenderTargetContext::internalStencilClear(const SkIRect* scissor, bool insideStencilMask) {
this->setNeedsStencil(/* useMixedSamplesIfNotMSAA = */ false);
bool clearWithDraw = this->caps()->performStencilClearsAsDraws() ||
(clip.scissorEnabled() && this->caps()->performPartialClearsAsDraws());
// TODO(michaelludwig): internalStencilClear will eventually just take a GrScissorState so
// we won't need to check window rectangles here.
if (clearWithDraw || clip.hasWindowRectangles()) {
(scissor && this->caps()->performPartialClearsAsDraws());
if (clearWithDraw) {
const GrUserStencilSettings* ss = GrStencilSettings::SetClipBitSettings(insideStencilMask);
SkRect rect = clip.scissorEnabled() ? SkRect::Make(clip.scissorRect())
: SkRect::MakeWH(this->width(), this->height());
SkRect rect = scissor ? SkRect::Make(*scissor)
: SkRect::MakeWH(this->width(), this->height());
// Configure the paint to have no impact on the color buffer
GrPaint paint;
paint.setXPFactory(GrDisableColorXPFactory::Get());
this->addDrawOp(clip, GrFillRectOp::MakeNonAARect(fContext, std::move(paint), SkMatrix::I(),
rect, ss));
this->addDrawOp(GrFixedClip::Disabled(),
GrFillRectOp::MakeNonAARect(fContext, std::move(paint), SkMatrix::I(),
rect, ss));
} else {
GrScissorState scissorState;
if (scissor) {
scissorState.set(*scissor);
}
std::unique_ptr<GrOp> op(GrClearStencilClipOp::Make(
fContext, clip.scissorState(), insideStencilMask, this->asRenderTargetProxy()));
fContext, scissorState, insideStencilMask, this->asRenderTargetProxy()));
if (!op) {
return;
}

View File

@ -148,22 +148,17 @@ public:
*/
void discard();
enum class CanClearFullscreen : bool {
kNo = false,
kYes = true
};
/**
* Clear the entire or rect of the render target, ignoring any clips.
* @param rect the rect to clear or the whole thing if rect is NULL.
* Clear the rect of the render target to the given color.
* @param rect the rect to clear to
* @param color the color to clear to.
* @param CanClearFullscreen allows partial clears to be converted to fullscreen clears on
* tiling platforms where that is an optimization.
*/
void clear(const SkIRect* rect, const SkPMColor4f& color, CanClearFullscreen);
void clear(const SkIRect& rect, const SkPMColor4f& color) {
this->internalClear(&rect, color);
}
// Clears the entire render target to the color.
void clear(const SkPMColor4f& color) {
return this->clear(nullptr, color, CanClearFullscreen::kYes);
this->internalClear(nullptr, color);
}
/**
@ -622,8 +617,9 @@ private:
GrOpsTask::CanDiscardPreviousOps canDiscardPreviousOpsOnFullClear() const;
void setNeedsStencil(bool useMixedSamplesIfNotMSAA);
void internalClear(const GrFixedClip&, const SkPMColor4f&, CanClearFullscreen);
void internalStencilClear(const GrFixedClip&, bool insideStencilMask);
void internalClear(const SkIRect* scissor, const SkPMColor4f&,
bool upgradePartialToFull = false);
void internalStencilClear(const SkIRect* scissor, bool insideStencilMask);
// Only consumes the GrPaint if successful.
bool drawFilledDRRect(const GrClip& clip,

View File

@ -43,11 +43,15 @@ public:
opsTask->fLastClipNumAnalyticFPs != numClipAnalyticFPs;
}
using CanClearFullscreen = GrRenderTargetContext::CanClearFullscreen;
// Clear at minimum the pixels within 'scissor', but is allowed to clear the full render target
// if that is the more performant option.
void clearAtLeast(const SkIRect& scissor, const SkPMColor4f& color) {
fRenderTargetContext->internalClear(&scissor, color, /* upgrade to full */ true);
}
void clear(const GrFixedClip&, const SkPMColor4f&, CanClearFullscreen);
void clearStencilClip(const GrFixedClip&, bool insideStencilMask);
void clearStencilClip(const SkIRect& scissor, bool insideStencilMask) {
fRenderTargetContext->internalStencilClear(&scissor, insideStencilMask);
}
// While this can take a general clip, since GrReducedClip relies on this function, it must take
// care to only provide hard clips or we could get stuck in a loop. The general clip is needed

View File

@ -462,7 +462,15 @@ bool GrStencilMaskHelper::drawShape(const GrShape& shape,
}
void GrStencilMaskHelper::clear(bool insideStencil) {
fRTC->priv().clearStencilClip(fClip.fixedClip(), insideStencil);
if (fClip.fixedClip().hasWindowRectangles()) {
// Use a draw to benefit from window rectangles when resetting the stencil buffer; for
// large buffers with MSAA this can be significant.
draw_stencil_rect(fRTC, fClip.fixedClip(),
GrStencilSettings::SetClipBitSettings(insideStencil), SkMatrix::I(),
SkRect::Make(fClip.fixedClip().scissorRect()), GrAA::kNo);
} else {
fRTC->priv().clearStencilClip(fClip.fixedClip().scissorRect(), insideStencil);
}
}
void GrStencilMaskHelper::finish() {

View File

@ -209,8 +209,7 @@ void SkGpuDevice::clearAll() {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice", "clearAll", fContext.get());
SkIRect rect = SkIRect::MakeWH(this->width(), this->height());
fRenderTargetContext->clear(&rect, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
fRenderTargetContext->priv().clearAtLeast(rect, SK_PMColor4fTRANSPARENT);
}
void SkGpuDevice::replaceRenderTargetContext(std::unique_ptr<GrRenderTargetContext> rtc,

View File

@ -64,8 +64,7 @@ uniform half blurRadius;
GrPaint paint;
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SK_PMColor4fTRANSPARENT);
rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw,
GrStyle::SimpleFill());

View File

@ -66,8 +66,7 @@ public:
GrPaint paint;
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SK_PMColor4fTRANSPARENT);
rtc->drawRRect(GrNoClip(), std::move(paint), GrAA::kYes, SkMatrix::I(), rrectToDraw,
GrStyle::SimpleFill());

View File

@ -17,45 +17,22 @@
std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
const GrScissorState& scissor,
const SkPMColor4f& color,
GrSurfaceProxy* dstProxy) {
const GrSurfaceProxy* dstProxy) {
const SkIRect rect = SkIRect::MakeSize(dstProxy->dimensions());
if (scissor.enabled() && !SkIRect::Intersects(scissor.rect(), rect)) {
return nullptr;
}
GrOpMemoryPool* pool = context->priv().opMemoryPool();
return pool->allocate<GrClearOp>(scissor, color, dstProxy);
}
std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
const SkIRect& rect,
const SkPMColor4f& color,
bool fullScreen) {
SkASSERT(fullScreen || !rect.isEmpty());
GrOpMemoryPool* pool = context->priv().opMemoryPool();
return pool->allocate<GrClearOp>(rect, color, fullScreen);
}
GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color, GrSurfaceProxy* proxy)
GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color,
const GrSurfaceProxy* proxy)
: INHERITED(ClassID())
, fScissor(scissor)
, fColor(color) {
const SkIRect rtRect = SkIRect::MakeSize(proxy->dimensions());
if (fScissor.enabled()) {
// Don't let scissors extend outside the RT. This may improve op combining.
if (!fScissor.intersect(rtRect)) {
SkASSERT(0); // should be caught upstream
fScissor.set(SkIRect::MakeEmpty());
}
if (proxy->isFunctionallyExact() && fScissor.rect() == rtRect) {
fScissor.setDisabled();
}
}
this->setBounds(SkRect::Make(fScissor.enabled() ? fScissor.rect() : rtRect),
this->setBounds(scissor.enabled() ? SkRect::Make(scissor.rect()) : proxy->getBoundsRect(),
HasAABloat::kNo, IsHairline::kNo);
}

View File

@ -21,12 +21,7 @@ public:
static std::unique_ptr<GrClearOp> Make(GrRecordingContext* context,
const GrScissorState& scissor,
const SkPMColor4f& color,
GrSurfaceProxy* dstProxy);
static std::unique_ptr<GrClearOp> Make(GrRecordingContext* context,
const SkIRect& rect,
const SkPMColor4f& color,
bool fullScreen);
const GrSurfaceProxy* dstProxy);
const char* name() const override { return "Clear"; }
@ -52,18 +47,7 @@ public:
private:
friend class GrOpMemoryPool; // for ctors
GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color, GrSurfaceProxy* proxy);
GrClearOp(const SkIRect& rect, const SkPMColor4f& color, bool fullScreen)
: INHERITED(ClassID())
, fScissor(rect)
, fColor(color) {
if (fullScreen) {
fScissor.setDisabled();
}
this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsHairline::kNo);
}
GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color, const GrSurfaceProxy* proxy);
CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*,
const GrCaps& caps) override {

View File

@ -100,7 +100,7 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Check a full clear
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(fullRect, kColor1f);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY);
@ -110,8 +110,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Check two full clears, same color
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(fullRect, kColor1f);
rtContext->clear(fullRect, kColor1f);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY);
@ -121,8 +121,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Check two full clears, different colors
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor2f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(fullRect, kColor1f);
rtContext->clear(fullRect, kColor2f);
if (!check_rect(rtContext.get(), fullRect, kColor2, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
failX, failY);
@ -132,8 +132,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Test a full clear followed by a same color inset clear
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(fullRect, kColor1f);
rtContext->clear(mid1Rect, kColor1f);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY);
@ -143,8 +143,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Test a inset clear followed by same color full clear
rtContext->clear(&mid1Rect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(mid1Rect, kColor1f);
rtContext->clear(fullRect, kColor1f);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY);
@ -154,8 +154,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Test a full clear followed by a different color inset clear
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor2f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(fullRect, kColor1f);
rtContext->clear(mid1Rect, kColor2f);
if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
failX, failY);
@ -172,8 +172,8 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Test a inset clear followed by a different full clear
rtContext->clear(&mid1Rect, kColor2f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(mid1Rect, kColor2f);
rtContext->clear(fullRect, kColor1f);
if (!check_rect(rtContext.get(), fullRect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY);
@ -184,9 +184,9 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
// Check three nested clears from largest to smallest where outermost and innermost are same
// color.
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor2f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid2Rect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(fullRect, kColor1f);
rtContext->clear(mid1Rect, kColor2f);
rtContext->clear(mid2Rect, kColor1f);
if (!check_rect(rtContext.get(), mid2Rect, kColor1, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor1, actualValue,
failX, failY);
@ -210,9 +210,9 @@ static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
SkASSERT(rtContext);
// Swap the order of the second two clears in the above test.
rtContext->clear(&fullRect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid2Rect, kColor1f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(&mid1Rect, kColor2f, GrRenderTargetContext::CanClearFullscreen::kNo);
rtContext->clear(fullRect, kColor1f);
rtContext->clear(mid2Rect, kColor1f);
rtContext->clear(mid1Rect, kColor2f);
if (!check_rect(rtContext.get(), mid1Rect, kColor2, &actualValue, &failX, &failY)) {
ERRORF(reporter, "Expected 0x%08x but got 0x%08x at (%d, %d).", kColor2, actualValue,
failX, failY);

View File

@ -88,7 +88,7 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
{kBigSize/2 + 1, kBigSize/2 + 1});
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SK_PMColor4fBLACK);
GrPaint paint;
@ -106,7 +106,7 @@ static void run_test(GrContext* ctx, skiatest::Reporter* reporter) {
auto rtc = GrRenderTargetContext::Make(
ctx, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {kBigSize, kBigSize});
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SK_PMColor4fBLACK);
GrPaint paint;

View File

@ -74,8 +74,7 @@ public:
GrCoverageCountingPathRenderer* ccpr() const { return fCCPR; }
bool valid() const { return fCCPR && fRTC; }
void clear() const { fRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes); }
void clear() const { fRTC->clear(SK_PMColor4fTRANSPARENT); }
void destroyGrContext() {
SkASSERT(fCtx->unique());
fRTC.reset();

View File

@ -600,8 +600,7 @@ static void run_test(GrContext* context, const char* testName, skiatest::Reporte
}
SkAutoSTMalloc<kImageHeight * kImageWidth, uint32_t> resultPx(h * rowBytes);
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
rtc->priv().testingOnly_addDrawOp(GrMeshTestOp::Make(context, prepareFn, executeFn));
rtc->readPixels(gold.info(), resultPx, rowBytes, {0, 0});

View File

@ -368,7 +368,6 @@ static std::unique_ptr<GrRenderTargetContext> draw_mipmap_into_new_render_target
// Test that two opsTasks using the same mipmaps both depend on the same GrTextureResolveRenderTask.
DEF_GPUTEST(GrManyDependentsMipMappedTest, reporter, /* options */) {
using CanClearFullscreen = GrRenderTargetContext::CanClearFullscreen;
using Enable = GrContextOptions::Enable;
using Filter = GrSamplerState::Filter;
@ -406,7 +405,7 @@ DEF_GPUTEST(GrManyDependentsMipMappedTest, reporter, /* options */) {
auto mipmapRTC = GrRenderTargetContext::Make(
context.get(), colorType, nullptr, mipmapProxy, kTopLeft_GrSurfaceOrigin, nullptr);
mipmapRTC->clear(nullptr, {.1f,.2f,.3f,.4f}, CanClearFullscreen::kYes);
mipmapRTC->clear({.1f,.2f,.3f,.4f});
REPORTER_ASSERT(reporter, mipmapProxy->getLastRenderTask());
// mipmapProxy's last render task should now just be the opsTask containing the clear.
REPORTER_ASSERT(reporter,
@ -450,7 +449,7 @@ DEF_GPUTEST(GrManyDependentsMipMappedTest, reporter, /* options */) {
REPORTER_ASSERT(reporter, rtc2Task->dependsOn(initialMipmapRegenTask));
// Render something to dirty the mips.
mipmapRTC->clear(nullptr, {.1f,.2f,.3f,.4f}, CanClearFullscreen::kYes);
mipmapRTC->clear({.1f,.2f,.3f,.4f});
auto mipmapRTCTask = sk_ref_sp(mipmapRTC->testingOnly_PeekLastOpsTask());
REPORTER_ASSERT(reporter, mipmapRTCTask);

View File

@ -229,8 +229,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrPipelineDynamicStateTest, reporter, ctxInfo
uint32_t resultPx[kScreenSize * kScreenSize];
for (GrScissorTest scissorTest : {GrScissorTest::kEnabled, GrScissorTest::kDisabled}) {
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
rtc->priv().testingOnly_addDrawOp(
GrPipelineDynamicStateTestOp::Make(context, scissorTest, vbuff));
rtc->readPixels(SkImageInfo::Make(kScreenSize, kScreenSize,

View File

@ -383,8 +383,7 @@ DEF_GPUTEST(LazyProxyFailedInstantiationTest, reporter, /* options */) {
ctx.get(), GrColorType::kRGBA_8888, nullptr, SkBackingFit::kExact, {100, 100});
REPORTER_ASSERT(reporter, rtc);
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SkPMColor4f::FromBytes_RGBA(0xbaaaaaad));
int executeTestValue = 0;
rtc->priv().testingOnly_addDrawOp(LazyFailedInstantiationTestOp::Make(

View File

@ -394,8 +394,7 @@ public:
nullptr);
// clear the atlas
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SK_PMColor4fTRANSPARENT);
int blocksInAtlas = 0;
for (int i = 0; i < lists.count(); ++i) {
@ -405,7 +404,7 @@ public:
// For now, we avoid the resource buffer issues and just use clears
#if 1
rtc->clear(&r, op->color(), GrRenderTargetContext::CanClearFullscreen::kNo);
rtc->clear(r, op->color());
#else
GrPaint paint;
paint.setColor4f(op->color());
@ -470,7 +469,7 @@ static GrSurfaceProxyView make_upstream_image(GrContext* context, AtlasObject* o
context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
{3 * kDrawnTileSize, kDrawnTileSize});
rtc->clear(nullptr, { 1, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear({ 1, 0, 0, 1 });
for (int i = 0; i < 3; ++i) {
SkRect r = SkRect::MakeXYWH(i*kDrawnTileSize, 0, kDrawnTileSize, kDrawnTileSize);
@ -584,7 +583,7 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(OnFlushCallbackTest, reporter, ctxInfo) {
context, GrColorType::kRGBA_8888, nullptr, SkBackingFit::kApprox,
{kFinalWidth, kFinalHeight});
rtc->clear(nullptr, SK_PMColor4fWHITE, GrRenderTargetContext::CanClearFullscreen::kYes);
rtc->clear(SK_PMColor4fWHITE);
// Note that this doesn't include the third texture proxy
for (int i = 0; i < kNumViews - 1; ++i) {

View File

@ -35,8 +35,7 @@ static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* cont
for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) {
rtContext->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA),
GrRenderTargetContext::CanClearFullscreen::kYes);
rtContext->clear(SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA));
auto fp = GrTextureEffect::Make(rectView, alphaType, SkMatrix::I(), filter);
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
@ -51,8 +50,7 @@ static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectConte
if (GrRenderTargetContext* rtc = rectContext->asRenderTargetContext()) {
// Clear the whole thing.
GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD);
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(color0),
GrRenderTargetContext::CanClearFullscreen::kNo);
rtc->clear(SkPMColor4f::FromBytes_RGBA(color0));
int w = rtc->width();
int h = rtc->height();
@ -73,8 +71,7 @@ static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectConte
// Clear the the top to a different color.
GrColor color1 = GrColorPackRGBA(0x1, 0x2, 0x3, 0x4);
SkIRect rect = SkIRect::MakeWH(w, h/2);
rtc->clear(&rect, SkPMColor4f::FromBytes_RGBA(color1),
GrRenderTargetContext::CanClearFullscreen::kNo);
rtc->clear(rect, SkPMColor4f::FromBytes_RGBA(color1));
uint32_t expectedColor1 = 0;
uint8_t* expectedBytes1 = reinterpret_cast<uint8_t*>(&expectedColor1);