Revert "Improve scissor state tracking in GrRTC"
This reverts commit 3b923a880bc0855772daffd95b5728795f515d5f.
Reason for revert: GrAppliedHardClip isn't tracking scissor state properly
Original change's description:
> Improve scissor state tracking in GrRTC
>
> At a low level, this changes GrScissorState from a rect+bool to a rect+size.
> The scissor test is considered enablebd if the rect does not fill the
> device bounds rect specified by the size. This has a number of benefits:
>
> 1. We can always access the scissor rect and know that it will be
> restricted to the render target dimensions.
> 2. It helps consolidate code that previously had to test the scissor rect
> and render target bounds separately.
> 3. The clear operations can now match the proper backing store dimensions
> of the render target.
> 4. It makes it easier to reason about scissors applying to the logical
> dimensions of the render target vs. its backing store dimensions.
>
> Originally, I was going to have the extra scissor guards for the logical
> dimensions be added in a separate CL (with the cleanup for
> attemptQuadOptimization). However, it became difficult to ensure correct
> behavior respecting the vulkan render pass bounds without applying this
> new logic at the same time.
>
> So now, with this CL, GrAppliedClips are sized to the backing store
> dimensions of the render target. GrOpsTasks also clip bounds to the
> backing store dimensions instead of the logical dimensions (which seems
> more correct since that's where the auto-clipping happens). Then when
> we convert a GrClip to a GrAppliedClip, the GrRTC automatically enforces
> the logical dimensions scissor if we have stencil settings (to ensure
> the padded pixels don't get corrupted). It also may remove the scissor
> if the draw was just a color buffer update.
>
> Change-Id: I75671c9cc921f4696b1dd5231e02486090aa4282
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290654
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com
Change-Id: Ie98d084158e3a537604ab0fecee69bde3e744d1b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/294340
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
index 9dae347..8a0a1b8 100644
--- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp
@@ -1117,7 +1117,7 @@
const GrCaps* caps = context->priv().caps();
// This is equivalent to a GrOpFlushState::detachAppliedClip
- GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip::Disabled();
+ GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip();
// Conservatively predict which programs will be required
fCharacterization = this->predictPrograms(caps);
diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp
index e954083..753f75d 100644
--- a/src/gpu/ops/GrClearOp.cpp
+++ b/src/gpu/ops/GrClearOp.cpp
@@ -16,16 +16,24 @@
std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
const GrScissorState& scissor,
- const SkPMColor4f& color) {
+ const SkPMColor4f& color,
+ 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);
+ return pool->allocate<GrClearOp>(scissor, color, dstProxy);
}
-GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color)
+GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color,
+ const GrSurfaceProxy* proxy)
: INHERITED(ClassID())
, fScissor(scissor)
, fColor(color) {
- this->setBounds(SkRect::Make(scissor.rect()), HasAABloat::kNo, IsHairline::kNo);
+ this->setBounds(scissor.enabled() ? SkRect::Make(scissor.rect()) : proxy->getBoundsRect(),
+ HasAABloat::kNo, IsHairline::kNo);
}
void GrClearOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
diff --git a/src/gpu/ops/GrClearOp.h b/src/gpu/ops/GrClearOp.h
index ad50c7d..770a7de 100644
--- a/src/gpu/ops/GrClearOp.h
+++ b/src/gpu/ops/GrClearOp.h
@@ -18,10 +18,10 @@
public:
DEFINE_OP_CLASS_ID
- // A fullscreen or scissored clear, depending on the clip and proxy dimensions
static std::unique_ptr<GrClearOp> Make(GrRecordingContext* context,
const GrScissorState& scissor,
- const SkPMColor4f& color);
+ const SkPMColor4f& color,
+ const GrSurfaceProxy* dstProxy);
const char* name() const override { return "Clear"; }
@@ -41,10 +41,13 @@
}
#endif
+ const SkPMColor4f& color() const { return fColor; }
+ void setColor(const SkPMColor4f& color) { fColor = color; }
+
private:
friend class GrOpMemoryPool; // for ctors
- GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color);
+ GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color, const GrSurfaceProxy* proxy);
CombineResult onCombineIfPossible(GrOp* t, GrRecordingContext::Arenas*,
const GrCaps& caps) override {
diff --git a/src/gpu/ops/GrClearStencilClipOp.cpp b/src/gpu/ops/GrClearStencilClipOp.cpp
index 4fc0da5..dc26471 100644
--- a/src/gpu/ops/GrClearStencilClipOp.cpp
+++ b/src/gpu/ops/GrClearStencilClipOp.cpp
@@ -15,10 +15,11 @@
std::unique_ptr<GrOp> GrClearStencilClipOp::Make(GrRecordingContext* context,
const GrScissorState& scissor,
- bool insideStencilMask) {
+ bool insideStencilMask,
+ GrRenderTargetProxy* proxy) {
GrOpMemoryPool* pool = context->priv().opMemoryPool();
- return pool->allocate<GrClearStencilClipOp>(scissor, insideStencilMask);
+ return pool->allocate<GrClearStencilClipOp>(scissor, insideStencilMask, proxy);
}
void GrClearStencilClipOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
diff --git a/src/gpu/ops/GrClearStencilClipOp.h b/src/gpu/ops/GrClearStencilClipOp.h
index 69d457e..f185cde 100644
--- a/src/gpu/ops/GrClearStencilClipOp.h
+++ b/src/gpu/ops/GrClearStencilClipOp.h
@@ -21,7 +21,8 @@
static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
const GrScissorState& scissor,
- bool insideStencilMask);
+ bool insideStencilMask,
+ GrRenderTargetProxy* proxy);
const char* name() const override { return "ClearStencilClip"; }
@@ -43,11 +44,14 @@
private:
friend class GrOpMemoryPool; // for ctor
- GrClearStencilClipOp(const GrScissorState& scissor, bool insideStencilMask)
+ GrClearStencilClipOp(const GrScissorState& scissor, bool insideStencilMask,
+ GrRenderTargetProxy* proxy)
: INHERITED(ClassID())
, fScissor(scissor)
, fInsideStencilMask(insideStencilMask) {
- this->setBounds(SkRect::Make(scissor.rect()), HasAABloat::kNo, IsHairline::kNo);
+ const SkRect& bounds =
+ fScissor.enabled() ? SkRect::Make(fScissor.rect()) : proxy->getBoundsRect();
+ this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo);
}
void onPrePrepare(GrRecordingContext*,
diff --git a/src/gpu/ops/GrFillRectOp.cpp b/src/gpu/ops/GrFillRectOp.cpp
index 5d20400..645a0f7 100644
--- a/src/gpu/ops/GrFillRectOp.cpp
+++ b/src/gpu/ops/GrFillRectOp.cpp
@@ -250,7 +250,7 @@
SkArenaAlloc* arena = context->priv().recordTimeAllocator();
// This is equivalent to a GrOpFlushState::detachAppliedClip
- GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip::Disabled();
+ GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip();
this->createProgramInfo(context->priv().caps(), arena, writeView,
std::move(appliedClip), dstProxyView);
diff --git a/src/gpu/ops/GrMeshDrawOp.cpp b/src/gpu/ops/GrMeshDrawOp.cpp
index 809620b..f5a8c04 100644
--- a/src/gpu/ops/GrMeshDrawOp.cpp
+++ b/src/gpu/ops/GrMeshDrawOp.cpp
@@ -33,7 +33,7 @@
SkArenaAlloc* arena = context->priv().recordTimeAllocator();
// This is equivalent to a GrOpFlushState::detachAppliedClip
- GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip::Disabled();
+ GrAppliedClip appliedClip = clip ? std::move(*clip) : GrAppliedClip();
this->createProgramInfo(context->priv().caps(), arena, writeView,
std::move(appliedClip), dstProxyView);
diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
index fb6e45b..61f6a11 100644
--- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp
@@ -125,16 +125,15 @@
args.fRenderTargetContext->height()); // Inverse fill.
// fake inverse with a stencil and cover
- GrAppliedClip appliedClip(args.fRenderTargetContext->dimensions());
+ GrAppliedClip appliedClip;
if (args.fClip && !args.fClip->apply(
args.fContext, args.fRenderTargetContext, doStencilMSAA, true, &appliedClip,
&devBounds)) {
return true;
}
- GrStencilClip stencilClip(args.fRenderTargetContext->dimensions(),
- appliedClip.stencilStackID());
+ GrStencilClip stencilClip(appliedClip.stencilStackID());
if (appliedClip.scissorState().enabled()) {
- SkAssertResult(stencilClip.fixedClip().setScissor(appliedClip.scissorState().rect()));
+ stencilClip.fixedClip().setScissor(appliedClip.scissorState().rect());
}
if (appliedClip.windowRectsState().enabled()) {
stencilClip.fixedClip().setWindowRectangles(appliedClip.windowRectsState().windows(),