Only use scissor state for native clears
This is the first of many CLs that progressively refine the clipping,
scissoring, and clearing APIs.
The series of changes focus on simplifying the clear APIs, consolidating
clip intersection logic, and moving towards a more explicitly sized
render target context (where confusion between approx-fit and exact-fit
is handled externally, although I don't take it that far).
Next step will be to propagate the simpler calls up to GrRTC.
Bug:skia:10205
Change-Id: Idb0c58a63b7a3950a92604dd4c03536d668be7c4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290123
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp
index 28529f4..dc1b939 100644
--- a/src/gpu/ops/GrClearOp.cpp
+++ b/src/gpu/ops/GrClearOp.cpp
@@ -15,17 +15,17 @@
#include "src/gpu/GrRecordingContextPriv.h"
std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
- const GrFixedClip& clip,
+ const GrScissorState& scissor,
const SkPMColor4f& color,
GrSurfaceProxy* dstProxy) {
const SkIRect rect = SkIRect::MakeSize(dstProxy->dimensions());
- if (clip.scissorEnabled() && !SkIRect::Intersects(clip.scissorRect(), rect)) {
+ if (scissor.enabled() && !SkIRect::Intersects(scissor.rect(), rect)) {
return nullptr;
}
GrOpMemoryPool* pool = context->priv().opMemoryPool();
- return pool->allocate<GrClearOp>(clip, color, dstProxy);
+ return pool->allocate<GrClearOp>(scissor, color, dstProxy);
}
std::unique_ptr<GrClearOp> GrClearOp::Make(GrRecordingContext* context,
@@ -39,27 +39,27 @@
return pool->allocate<GrClearOp>(rect, color, fullScreen);
}
-GrClearOp::GrClearOp(const GrFixedClip& clip, const SkPMColor4f& color, GrSurfaceProxy* proxy)
+GrClearOp::GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color, GrSurfaceProxy* proxy)
: INHERITED(ClassID())
- , fClip(clip)
+ , fScissor(scissor)
, fColor(color) {
const SkIRect rtRect = SkIRect::MakeSize(proxy->dimensions());
- if (fClip.scissorEnabled()) {
+ if (fScissor.enabled()) {
// Don't let scissors extend outside the RT. This may improve op combining.
- if (!fClip.intersect(rtRect)) {
+ if (!fScissor.intersect(rtRect)) {
SkASSERT(0); // should be caught upstream
- fClip = GrFixedClip(SkIRect::MakeEmpty());
+ fScissor.set(SkIRect::MakeEmpty());
}
- if (proxy->isFunctionallyExact() && fClip.scissorRect() == rtRect) {
- fClip.disableScissor();
+ if (proxy->isFunctionallyExact() && fScissor.rect() == rtRect) {
+ fScissor.setDisabled();
}
}
- this->setBounds(SkRect::Make(fClip.scissorEnabled() ? fClip.scissorRect() : rtRect),
+ this->setBounds(SkRect::Make(fScissor.enabled() ? fScissor.rect() : rtRect),
HasAABloat::kNo, IsHairline::kNo);
}
void GrClearOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
SkASSERT(state->opsRenderPass());
- state->opsRenderPass()->clear(fClip, fColor);
+ state->opsRenderPass()->clear(fScissor, fColor);
}
diff --git a/src/gpu/ops/GrClearOp.h b/src/gpu/ops/GrClearOp.h
index fbac02f..0857064 100644
--- a/src/gpu/ops/GrClearOp.h
+++ b/src/gpu/ops/GrClearOp.h
@@ -8,7 +8,7 @@
#ifndef GrClearOp_DEFINED
#define GrClearOp_DEFINED
-#include "src/gpu/GrFixedClip.h"
+#include "src/gpu/GrScissorState.h"
#include "src/gpu/ops/GrOp.h"
class GrOpFlushState;
@@ -19,7 +19,7 @@
DEFINE_OP_CLASS_ID
static std::unique_ptr<GrClearOp> Make(GrRecordingContext* context,
- const GrFixedClip& clip,
+ const GrScissorState& scissor,
const SkPMColor4f& color,
GrSurfaceProxy* dstProxy);
@@ -35,8 +35,8 @@
SkString string;
string.append(INHERITED::dumpInfo());
string.appendf("Scissor [ ");
- if (fClip.scissorEnabled()) {
- const SkIRect& r = fClip.scissorRect();
+ if (fScissor.enabled()) {
+ const SkIRect& r = fScissor.rect();
string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
} else {
string.append("disabled");
@@ -52,15 +52,15 @@
private:
friend class GrOpMemoryPool; // for ctors
- GrClearOp(const GrFixedClip& clip, const SkPMColor4f& color, GrSurfaceProxy* proxy);
+ GrClearOp(const GrScissorState& scissor, const SkPMColor4f& color, GrSurfaceProxy* proxy);
GrClearOp(const SkIRect& rect, const SkPMColor4f& color, bool fullScreen)
: INHERITED(ClassID())
- , fClip(GrFixedClip(rect))
+ , fScissor(rect)
, fColor(color) {
if (fullScreen) {
- fClip.disableScissor();
+ fScissor.setDisabled();
}
this->setBounds(SkRect::Make(rect), HasAABloat::kNo, IsHairline::kNo);
}
@@ -71,11 +71,8 @@
// contains the old clear, or when the new clear is a subset of the old clear and is the
// same color.
GrClearOp* cb = t->cast<GrClearOp>();
- if (fClip.windowRectsState() != cb->fClip.windowRectsState()) {
- return CombineResult::kCannotCombine;
- }
if (cb->contains(this)) {
- fClip = cb->fClip;
+ fScissor = cb->fScissor;
fColor = cb->fColor;
return CombineResult::kMerged;
} else if (cb->fColor == fColor && this->contains(cb)) {
@@ -86,9 +83,8 @@
bool contains(const GrClearOp* that) const {
// The constructor ensures that scissor gets disabled on any clip that fills the entire RT.
- return !fClip.scissorEnabled() ||
- (that->fClip.scissorEnabled() &&
- fClip.scissorRect().contains(that->fClip.scissorRect()));
+ return !fScissor.enabled() ||
+ (that->fScissor.enabled() && fScissor.rect().contains(that->fScissor.rect()));
}
void onPrePrepare(GrRecordingContext*,
@@ -100,8 +96,8 @@
void onExecute(GrOpFlushState* state, const SkRect& chainBounds) override;
- GrFixedClip fClip;
- SkPMColor4f fColor;
+ GrScissorState fScissor;
+ SkPMColor4f fColor;
typedef GrOp INHERITED;
};
diff --git a/src/gpu/ops/GrClearStencilClipOp.cpp b/src/gpu/ops/GrClearStencilClipOp.cpp
index 7ca4063..dc26471 100644
--- a/src/gpu/ops/GrClearStencilClipOp.cpp
+++ b/src/gpu/ops/GrClearStencilClipOp.cpp
@@ -14,15 +14,15 @@
#include "src/gpu/GrRecordingContextPriv.h"
std::unique_ptr<GrOp> GrClearStencilClipOp::Make(GrRecordingContext* context,
- const GrFixedClip& clip,
+ const GrScissorState& scissor,
bool insideStencilMask,
GrRenderTargetProxy* proxy) {
GrOpMemoryPool* pool = context->priv().opMemoryPool();
- return pool->allocate<GrClearStencilClipOp>(clip, insideStencilMask, proxy);
+ return pool->allocate<GrClearStencilClipOp>(scissor, insideStencilMask, proxy);
}
void GrClearStencilClipOp::onExecute(GrOpFlushState* state, const SkRect& chainBounds) {
SkASSERT(state->opsRenderPass());
- state->opsRenderPass()->clearStencilClip(fClip, fInsideStencilMask);
+ state->opsRenderPass()->clearStencilClip(fScissor, fInsideStencilMask);
}
diff --git a/src/gpu/ops/GrClearStencilClipOp.h b/src/gpu/ops/GrClearStencilClipOp.h
index 68f825a..f185cde 100644
--- a/src/gpu/ops/GrClearStencilClipOp.h
+++ b/src/gpu/ops/GrClearStencilClipOp.h
@@ -8,8 +8,8 @@
#ifndef GrClearStencilClipOp_DEFINED
#define GrClearStencilClipOp_DEFINED
-#include "src/gpu/GrFixedClip.h"
#include "src/gpu/GrRenderTargetProxy.h"
+#include "src/gpu/GrScissorState.h"
#include "src/gpu/ops/GrOp.h"
class GrOpFlushState;
@@ -20,7 +20,7 @@
DEFINE_OP_CLASS_ID
static std::unique_ptr<GrOp> Make(GrRecordingContext* context,
- const GrFixedClip& clip,
+ const GrScissorState& scissor,
bool insideStencilMask,
GrRenderTargetProxy* proxy);
@@ -29,8 +29,8 @@
#ifdef SK_DEBUG
SkString dumpInfo() const override {
SkString string("Scissor [");
- if (fClip.scissorEnabled()) {
- const SkIRect& r = fClip.scissorRect();
+ if (fScissor.enabled()) {
+ const SkIRect& r = fScissor.rect();
string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom);
} else {
string.append("disabled");
@@ -44,13 +44,13 @@
private:
friend class GrOpMemoryPool; // for ctor
- GrClearStencilClipOp(const GrFixedClip& clip, bool insideStencilMask,
+ GrClearStencilClipOp(const GrScissorState& scissor, bool insideStencilMask,
GrRenderTargetProxy* proxy)
: INHERITED(ClassID())
- , fClip(clip)
+ , fScissor(scissor)
, fInsideStencilMask(insideStencilMask) {
const SkRect& bounds =
- fClip.scissorEnabled() ? SkRect::Make(fClip.scissorRect()) : proxy->getBoundsRect();
+ fScissor.enabled() ? SkRect::Make(fScissor.rect()) : proxy->getBoundsRect();
this->setBounds(bounds, HasAABloat::kNo, IsHairline::kNo);
}
@@ -63,8 +63,8 @@
void onExecute(GrOpFlushState*, const SkRect& chainBounds) override;
- const GrFixedClip fClip;
- const bool fInsideStencilMask;
+ const GrScissorState fScissor;
+ const bool fInsideStencilMask;
typedef GrOp INHERITED;
};