From a219419c9d76432dca74494b611ff1f59086d139 Mon Sep 17 00:00:00 2001 From: Brian Salomon Date: Mon, 2 Jul 2018 09:00:27 -0400 Subject: Some scissor state cleanup. Separate flushing the enablement of scissor from the rect in GrGLGpu. Move GrPipeline::ScissorState to a global enum and use more broadly. Rename to GrScissorTest to avoid name conflict with existing GrScissorState. Change-Id: Ib32160b3300bc12de2d2e1761d152fd1bba8b683 Reviewed-on: https://skia-review.googlesource.com/137395 Commit-Queue: Brian Salomon Reviewed-by: Chris Dalton --- src/gpu/ops/GrClearOp.cpp | 11 +++++++---- src/gpu/ops/GrClearOp.h | 10 ++++++---- src/gpu/ops/GrClearStencilClipOp.h | 8 ++++---- src/gpu/ops/GrStencilAndCoverPathRenderer.cpp | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src/gpu/ops') diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp index 612ff2085d..52360dbe93 100644 --- a/src/gpu/ops/GrClearOp.cpp +++ b/src/gpu/ops/GrClearOp.cpp @@ -17,7 +17,8 @@ std::unique_ptr GrClearOp::Make(GrContext* context, GrColor color, GrSurfaceProxy* dstProxy) { const SkIRect rect = SkIRect::MakeWH(dstProxy->width(), dstProxy->height()); - if (clip.scissorEnabled() && !SkIRect::Intersects(clip.scissorRect(), rect)) { + if (clip.scissorTest() == GrScissorTest::kEnabled && + !SkIRect::Intersects(clip.scissorRect(), rect)) { return nullptr; } @@ -42,7 +43,7 @@ GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* pro , fClip(clip) , fColor(color) { const SkIRect rtRect = SkIRect::MakeWH(proxy->width(), proxy->height()); - if (fClip.scissorEnabled()) { + if (fClip.scissorTest() == GrScissorTest::kEnabled) { // Don't let scissors extend outside the RT. This may improve op combining. if (!fClip.intersect(rtRect)) { SkASSERT(0); // should be caught upstream @@ -53,8 +54,10 @@ GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* pro fClip.disableScissor(); } } - this->setBounds(SkRect::Make(fClip.scissorEnabled() ? fClip.scissorRect() : rtRect), - HasAABloat::kNo, IsZeroArea::kNo); + this->setBounds( + SkRect::Make(fClip.scissorTest() == GrScissorTest::kEnabled ? fClip.scissorRect() + : rtRect), + HasAABloat::kNo, IsZeroArea::kNo); } void GrClearOp::onExecute(GrOpFlushState* state) { diff --git a/src/gpu/ops/GrClearOp.h b/src/gpu/ops/GrClearOp.h index 6e76191dff..59929b269a 100644 --- a/src/gpu/ops/GrClearOp.h +++ b/src/gpu/ops/GrClearOp.h @@ -33,7 +33,7 @@ public: SkString string; string.append(INHERITED::dumpInfo()); string.appendf("Scissor [ "); - if (fClip.scissorEnabled()) { + if (fClip.scissorTest() == GrScissorTest::kEnabled) { const SkIRect& r = fClip.scissorRect(); string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom); } else { @@ -83,9 +83,11 @@ private: 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())); + if (fClip.scissorTest() == GrScissorTest::kDisabled) { + return true; + } + return that->fClip.scissorTest() == GrScissorTest::kEnabled && + fClip.scissorRect().contains(that->fClip.scissorRect()); } void onPrepare(GrOpFlushState*) override {} diff --git a/src/gpu/ops/GrClearStencilClipOp.h b/src/gpu/ops/GrClearStencilClipOp.h index 3e7ad5070f..09c05e1ceb 100644 --- a/src/gpu/ops/GrClearStencilClipOp.h +++ b/src/gpu/ops/GrClearStencilClipOp.h @@ -27,7 +27,7 @@ public: SkString dumpInfo() const override { SkString string("Scissor ["); - if (fClip.scissorEnabled()) { + if (fClip.scissorTest() == GrScissorTest::kEnabled) { const SkIRect& r = fClip.scissorRect(); string.appendf("L: %d, T: %d, R: %d, B: %d", r.fLeft, r.fTop, r.fRight, r.fBottom); } else { @@ -46,9 +46,9 @@ private: : INHERITED(ClassID()) , fClip(clip) , fInsideStencilMask(insideStencilMask) { - const SkRect& bounds = fClip.scissorEnabled() - ? SkRect::Make(fClip.scissorRect()) - : SkRect::MakeIWH(proxy->width(), proxy->height()); + const SkRect& bounds = fClip.scissorTest() == GrScissorTest::kEnabled + ? SkRect::Make(fClip.scissorRect()) + : SkRect::MakeIWH(proxy->width(), proxy->height()); this->setBounds(bounds, HasAABloat::kNo, IsZeroArea::kNo); } diff --git a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp index f395927b63..6b56183752 100644 --- a/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp +++ b/src/gpu/ops/GrStencilAndCoverPathRenderer.cpp @@ -109,7 +109,7 @@ bool GrStencilAndCoverPathRenderer::onDrawPath(const DrawPathArgs& args) { return true; } GrStencilClip stencilClip(appliedClip.stencilStackID()); - if (appliedClip.scissorState().enabled()) { + if (appliedClip.scissorState().scissorTest() == GrScissorTest::kEnabled) { stencilClip.fixedClip().setScissor(appliedClip.scissorState().rect()); } if (appliedClip.windowRectsState().enabled()) { -- cgit v1.2.3