diff options
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrAppliedClip.h | 5 | ||||
-rw-r--r-- | src/gpu/GrFixedClip.cpp | 9 | ||||
-rw-r--r-- | src/gpu/GrFixedClip.h | 11 | ||||
-rw-r--r-- | src/gpu/GrGpuCommandBuffer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrPipeline.cpp | 6 | ||||
-rw-r--r-- | src/gpu/GrPipeline.h | 11 | ||||
-rw-r--r-- | src/gpu/GrRenderTargetContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrScissorState.h | 21 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCCPathParser.cpp | 4 | ||||
-rw-r--r-- | src/gpu/ccpr/GrCCPerFlushResources.cpp | 3 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.cpp | 110 | ||||
-rw-r--r-- | src/gpu/gl/GrGLGpu.h | 11 | ||||
-rw-r--r-- | src/gpu/gl/GrGLPathRendering.cpp | 2 | ||||
-rw-r--r-- | src/gpu/ops/GrClearOp.cpp | 11 | ||||
-rw-r--r-- | src/gpu/ops/GrClearOp.h | 10 | ||||
-rw-r--r-- | src/gpu/ops/GrClearStencilClipOp.h | 8 | ||||
-rw-r--r-- | src/gpu/ops/GrStencilAndCoverPathRenderer.cpp | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkGpuCommandBuffer.cpp | 16 |
18 files changed, 123 insertions, 121 deletions
diff --git a/src/gpu/GrAppliedClip.h b/src/gpu/GrAppliedClip.h index 90068669db..bfe3383e16 100644 --- a/src/gpu/GrAppliedClip.h +++ b/src/gpu/GrAppliedClip.h @@ -11,8 +11,10 @@ #include "GrFragmentProcessor.h" #include "GrScissorState.h" #include "GrWindowRectsState.h" + #include "SkClipStack.h" + /** * Produced by GrHardClip. It provides a set of modifications to the hardware drawing state that * implement the clip. @@ -53,8 +55,7 @@ public: } bool doesClip() const { - return fScissorState.scissorTest() == GrScissorTest::kEnabled || this->hasStencilClip() || - fWindowRectsState.enabled(); + return fScissorState.enabled() || this->hasStencilClip() || fWindowRectsState.enabled(); } bool operator==(const GrAppliedHardClip& that) const { diff --git a/src/gpu/GrFixedClip.cpp b/src/gpu/GrFixedClip.cpp index 7eee3941f2..94a89fd034 100644 --- a/src/gpu/GrFixedClip.cpp +++ b/src/gpu/GrFixedClip.cpp @@ -14,13 +14,12 @@ bool GrFixedClip::quickContains(const SkRect& rect) const { if (fWindowRectsState.enabled()) { return false; } - return fScissorState.scissorTest() == GrScissorTest::kDisabled || - GrClip::IsInsideClip(fScissorState.rect(), rect); + return !fScissorState.enabled() || GrClip::IsInsideClip(fScissorState.rect(), rect); } void GrFixedClip::getConservativeBounds(int w, int h, SkIRect* devResult, bool* iior) const { devResult->setXYWH(0, 0, w, h); - if (fScissorState.scissorTest() == GrScissorTest::kEnabled) { + if (fScissorState.enabled()) { if (!devResult->intersect(fScissorState.rect())) { devResult->setEmpty(); } @@ -34,7 +33,7 @@ bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const { if (fWindowRectsState.enabled()) { return false; } - if (fScissorState.scissorTest() == GrScissorTest::kEnabled) { + if (fScissorState.enabled()) { SkRect rect = SkRect::Make(fScissorState.rect()); if (!rect.intersects(rtBounds)) { return false; @@ -47,7 +46,7 @@ bool GrFixedClip::isRRect(const SkRect& rtBounds, SkRRect* rr, GrAA* aa) const { }; bool GrFixedClip::apply(int rtWidth, int rtHeight, GrAppliedHardClip* out, SkRect* bounds) const { - if (fScissorState.scissorTest() == GrScissorTest::kEnabled) { + if (fScissorState.enabled()) { SkIRect tightScissor = SkIRect::MakeWH(rtWidth, rtHeight); if (!tightScissor.intersect(fScissorState.rect())) { return false; diff --git a/src/gpu/GrFixedClip.h b/src/gpu/GrFixedClip.h index 2e466aff67..d44c1e84e4 100644 --- a/src/gpu/GrFixedClip.h +++ b/src/gpu/GrFixedClip.h @@ -21,15 +21,14 @@ public: explicit GrFixedClip(const SkIRect& scissorRect) : fScissorState(scissorRect) {} const GrScissorState& scissorState() const { return fScissorState; } - GrScissorTest scissorTest() const { return fScissorState.scissorTest(); } - const SkIRect& scissorRect() const { - SkASSERT(this->scissorTest() == GrScissorTest::kEnabled); - return fScissorState.rect(); - } + bool scissorEnabled() const { return fScissorState.enabled(); } + const SkIRect& scissorRect() const { SkASSERT(scissorEnabled()); return fScissorState.rect(); } void disableScissor() { fScissorState.setDisabled(); } - void setScissor(const SkIRect& irect) { fScissorState = GrScissorState(irect); } + void setScissor(const SkIRect& irect) { + fScissorState.set(irect); + } bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& irect) { return fScissorState.intersect(irect); } diff --git a/src/gpu/GrGpuCommandBuffer.cpp b/src/gpu/GrGpuCommandBuffer.cpp index 1cedd0cdb8..42e00f355f 100644 --- a/src/gpu/GrGpuCommandBuffer.cpp +++ b/src/gpu/GrGpuCommandBuffer.cpp @@ -39,7 +39,7 @@ bool GrGpuRTCommandBuffer::draw(const GrPrimitiveProcessor& primProc, const GrPi SkASSERT(primProc.hasInstanceAttributes() == meshes[i].isInstanced()); } #endif - SkASSERT(pipeline.scissorTest() == GrScissorTest::kDisabled || fixedDynamicState || + SkASSERT(!pipeline.isScissorEnabled() || fixedDynamicState || (dynamicStateArrays && dynamicStateArrays->fScissorRects)); auto resourceProvider = this->gpu()->getContext()->contextPriv().resourceProvider(); diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 3f68fe088c..6608d7c7d2 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -28,7 +28,7 @@ GrPipeline::GrPipeline(const InitArgs& args, if (appliedClip.hasStencilClip()) { fFlags |= kHasStencilClip_Flag; } - if (appliedClip.scissorState().scissorTest() == GrScissorTest::kEnabled) { + if (appliedClip.scissorState().enabled()) { fFlags |= kScissorEnabled_Flag; } @@ -99,7 +99,7 @@ GrXferBarrierType GrPipeline::xferBarrierType(const GrCaps& caps) const { return this->getXferProcessor().xferBarrierType(caps); } -GrPipeline::GrPipeline(GrRenderTargetProxy* proxy, GrScissorTest scissorTest, SkBlendMode blendmode) +GrPipeline::GrPipeline(GrRenderTargetProxy* proxy, ScissorState scissorState, SkBlendMode blendmode) : fProxy(proxy) , fWindowRectsState() , fUserStencilSettings(&GrUserStencilSettings::kUnused) @@ -108,7 +108,7 @@ GrPipeline::GrPipeline(GrRenderTargetProxy* proxy, GrScissorTest scissorTest, Sk , fFragmentProcessors() , fNumColorProcessors(0) { SkASSERT(proxy); - if (scissorTest == GrScissorTest::kEnabled) { + if (scissorState) { fFlags |= kScissorEnabled_Flag; } } diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 23255287ae..f60a6d410b 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -64,6 +64,11 @@ public: return flags; } + enum ScissorState : bool { + kEnabled = true, + kDisabled = false + }; + struct InitArgs { uint32_t fFlags = 0; const GrUserStencilSettings* fUserStencil = &GrUserStencilSettings::kUnused; @@ -98,7 +103,7 @@ public: * must be "Porter Duff" (<= kLastCoeffMode). If using ScissorState::kEnabled, the caller must * specify a scissor rectangle through the DynamicState struct. **/ - GrPipeline(GrRenderTargetProxy*, GrScissorTest, SkBlendMode); + GrPipeline(GrRenderTargetProxy*, ScissorState, SkBlendMode); GrPipeline(const InitArgs&, GrProcessorSet&&, GrAppliedClip&&); @@ -174,8 +179,8 @@ public: const GrUserStencilSettings* getUserStencil() const { return fUserStencilSettings; } - GrScissorTest scissorTest() const { - return GrScissorTest(SkToBool(fFlags & kScissorEnabled_Flag)); + ScissorState isScissorEnabled() const { + return ScissorState(SkToBool(fFlags & kScissorEnabled_Flag)); } const GrWindowRectsState& getWindowRectsState() const { return fWindowRectsState; } diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp index 9e52558768..1dbde17575 100644 --- a/src/gpu/GrRenderTargetContext.cpp +++ b/src/gpu/GrRenderTargetContext.cpp @@ -329,7 +329,7 @@ void GrRenderTargetContext::internalClear(const GrFixedClip& clip, CanClearFullscreen canClearFullscreen) { bool isFull = false; if (!clip.hasWindowRectangles()) { - isFull = clip.scissorTest() == GrScissorTest::kDisabled || + isFull = !clip.scissorEnabled() || (CanClearFullscreen::kYes == canClearFullscreen && this->caps()->preferFullscreenClears()) || clip.scissorRect().contains(SkIRect::MakeWH(this->width(), this->height())); diff --git a/src/gpu/GrScissorState.h b/src/gpu/GrScissorState.h index a395aef7ac..59ea088078 100644 --- a/src/gpu/GrScissorState.h +++ b/src/gpu/GrScissorState.h @@ -8,29 +8,32 @@ #ifndef GrScissorState_DEFINED #define GrScissorState_DEFINED +#include "SkRect.h" + class GrScissorState { public: - GrScissorState() = default; - GrScissorState(const SkIRect& rect) : fScissorTest(GrScissorTest::kEnabled), fRect(rect) {} - void setDisabled() { fScissorTest = GrScissorTest::kDisabled; } + GrScissorState() : fEnabled(false) {} + GrScissorState(const SkIRect& rect) : fEnabled(true), fRect(rect) {} + void setDisabled() { fEnabled = false; } + void set(const SkIRect& rect) { fRect = rect; fEnabled = true; } bool SK_WARN_UNUSED_RESULT intersect(const SkIRect& rect) { - if (fScissorTest == GrScissorTest::kDisabled) { - *this = GrScissorState(rect); + if (!fEnabled) { + this->set(rect); return true; } return fRect.intersect(rect); } bool operator==(const GrScissorState& other) const { - return fScissorTest == other.fScissorTest && - (fScissorTest == GrScissorTest::kDisabled || fRect == other.fRect); + return fEnabled == other.fEnabled && + (false == fEnabled || fRect == other.fRect); } bool operator!=(const GrScissorState& other) const { return !(*this == other); } - GrScissorTest scissorTest() const { return fScissorTest; } + bool enabled() const { return fEnabled; } const SkIRect& rect() const { return fRect; } private: - GrScissorTest fScissorTest = GrScissorTest::kDisabled; + bool fEnabled; SkIRect fRect; }; diff --git a/src/gpu/ccpr/GrCCPathParser.cpp b/src/gpu/ccpr/GrCCPathParser.cpp index d013b5766e..1935385eeb 100644 --- a/src/gpu/ccpr/GrCCPathParser.cpp +++ b/src/gpu/ccpr/GrCCPathParser.cpp @@ -530,7 +530,7 @@ void GrCCPathParser::drawCoverageCount(GrOpFlushState* flushState, CoverageCount const PrimitiveTallies& batchTotalCounts = fCoverageCountBatches[batchID].fTotalPrimitiveCounts; - GrPipeline pipeline(flushState->drawOpArgs().fProxy, GrScissorTest::kEnabled, + GrPipeline pipeline(flushState->drawOpArgs().fProxy, GrPipeline::ScissorState::kEnabled, SkBlendMode::kPlus); if (batchTotalCounts.fTriangles) { @@ -564,7 +564,7 @@ void GrCCPathParser::drawPrimitives(GrOpFlushState* flushState, const GrPipeline GrCCCoverageProcessor::PrimitiveType primitiveType, int PrimitiveTallies::*instanceType, const SkIRect& drawBounds) const { - SkASSERT(pipeline.scissorTest() == GrScissorTest::kEnabled); + SkASSERT(pipeline.isScissorEnabled()); // Don't call reset(), as that also resets the reserve count. fMeshesScratchBuffer.pop_back_n(fMeshesScratchBuffer.count()); diff --git a/src/gpu/ccpr/GrCCPerFlushResources.cpp b/src/gpu/ccpr/GrCCPerFlushResources.cpp index c4e2861b47..dd0bf1b473 100644 --- a/src/gpu/ccpr/GrCCPerFlushResources.cpp +++ b/src/gpu/ccpr/GrCCPerFlushResources.cpp @@ -64,7 +64,8 @@ public: void onExecute(GrOpFlushState* flushState) override { SkASSERT(fStashedAtlasProxy); - GrPipeline pipeline(flushState->proxy(), GrScissorTest::kDisabled, SkBlendMode::kSrc); + GrPipeline pipeline(flushState->proxy(), GrPipeline::ScissorState::kDisabled, + SkBlendMode::kSrc); GrCCPathProcessor pathProc(flushState->resourceProvider(), std::move(fStashedAtlasProxy)); pathProc.drawPaths(flushState, pipeline, nullptr, *fResources, fBaseInstance, fEndInstance, this->bounds()); diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp index 02f2f37c6c..40915a3dcb 100644 --- a/src/gpu/gl/GrGLGpu.cpp +++ b/src/gpu/gl/GrGLGpu.cpp @@ -1358,7 +1358,7 @@ sk_sp<GrTexture> GrGLGpu::onCreateTexture(const GrSurfaceDesc& desc, GrGLIRect viewport; this->bindSurfaceFBOForPixelOps(tex.get(), GR_GL_FRAMEBUFFER, &viewport, kDst_TempFBOTarget); - this->flushScissorTest(GrScissorTest::kDisabled); + this->disableScissor(); this->disableWindowRectangles(); GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); fHWWriteToColor = kYes_TriState; @@ -1605,45 +1605,29 @@ GrBuffer* GrGLGpu::onCreateBuffer(size_t size, GrBufferType intendedType, return GrGLBuffer::Create(this, size, intendedType, accessPattern, data); } -void GrGLGpu::flushScissorTest(GrScissorTest test) { - if (test == GrScissorTest::kEnabled) { - if (kYes_TriState != fHWScissorSettings.fEnabled) { - GL_CALL(Enable(GR_GL_SCISSOR_TEST)); - fHWScissorSettings.fEnabled = kYes_TriState; - } - } else { - if (kNo_TriState != fHWScissorSettings.fEnabled) { - GL_CALL(Disable(GR_GL_SCISSOR_TEST)); - fHWScissorSettings.fEnabled = kNo_TriState; - } - } -} - -void GrGLGpu::flushScissorRect(const SkIRect& scissorRect, const GrGLIRect& viewport, - GrSurfaceOrigin origin) { - GrGLIRect scissor; - scissor.setRelativeTo(viewport, scissorRect, origin); - if (fHWScissorSettings.fRect != scissor) { - scissor.pushToGLScissor(this->glInterface()); - fHWScissorSettings.fRect = scissor; - } -} - -void GrGLGpu::flushScissorState(const GrScissorState& clipScissor, const GrGLIRect& viewport, - GrSurfaceOrigin origin) { - if (clipScissor.scissorTest() == GrScissorTest::kEnabled) { - GrGLIRect scissorRect; - scissorRect.setRelativeTo(viewport, clipScissor.rect(), origin); - if (!scissorRect.contains(viewport)) { - this->flushScissorTest(GrScissorTest::kEnabled); - if (fHWScissorSettings.fRect != scissorRect) { - scissorRect.pushToGLScissor(this->glInterface()); - fHWScissorSettings.fRect = scissorRect; +void GrGLGpu::flushScissor(const GrScissorState& scissorState, + const GrGLIRect& rtViewport, + GrSurfaceOrigin rtOrigin) { + if (scissorState.enabled()) { + GrGLIRect scissor; + scissor.setRelativeTo(rtViewport, scissorState.rect(), rtOrigin); + // if the scissor fully contains the viewport then we fall through and + // disable the scissor test. + if (!scissor.contains(rtViewport)) { + if (fHWScissorSettings.fRect != scissor) { + scissor.pushToGLScissor(this->glInterface()); + fHWScissorSettings.fRect = scissor; + } + if (kYes_TriState != fHWScissorSettings.fEnabled) { + GL_CALL(Enable(GR_GL_SCISSOR_TEST)); + fHWScissorSettings.fEnabled = kYes_TriState; } return; } } - this->flushScissorTest(GrScissorTest::kDisabled); + + // See fall through note above + this->disableScissor(); } void GrGLGpu::flushWindowRectangles(const GrWindowRectsState& windowState, @@ -1737,10 +1721,12 @@ bool GrGLGpu::flushGLState(const GrPrimitiveProcessor& primProc, glRT->renderTargetPriv().numStencilBits()); } this->flushStencil(stencil); - this->flushScissorTest(pipeline.scissorTest()); - if (pipeline.scissorTest() == GrScissorTest::kEnabled && fixedDynamicState) { - this->flushScissorRect(fixedDynamicState->fScissorRect, glRT->getViewport(), - pipeline.proxy()->origin()); + if (pipeline.isScissorEnabled()) { + static constexpr SkIRect kBogusScissor{0, 0, 1, 1}; + GrScissorState state(fixedDynamicState ? fixedDynamicState->fScissorRect : kBogusScissor); + this->flushScissor(state, glRT->getViewport(), pipeline.proxy()->origin()); + } else { + this->disableScissor(); } this->flushWindowRectangles(pipeline.getWindowRectsState(), glRT, pipeline.proxy()->origin()); this->flushHWAAState(glRT, pipeline.isHWAntialiasState(), !stencil.isDisabled()); @@ -1874,6 +1860,14 @@ void GrGLGpu::notifyBufferReleased(const GrGLBuffer* buffer) { } } +void GrGLGpu::disableScissor() { + if (kNo_TriState != fHWScissorSettings.fEnabled) { + GL_CALL(Disable(GR_GL_SCISSOR_TEST)); + fHWScissorSettings.fEnabled = kNo_TriState; + return; + } +} + void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrRenderTarget* target, GrSurfaceOrigin origin) { // parent class should never let us get here with no RT @@ -1896,12 +1890,12 @@ void GrGLGpu::clear(const GrFixedClip& clip, GrColor color, GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); - if (clip.scissorTest() == GrScissorTest::kEnabled) { + if (clip.scissorEnabled()) { this->flushRenderTarget(glRT, origin, clip.scissorRect()); } else { this->flushRenderTarget(glRT); } - this->flushScissorState(clip.scissorState(), glRT->getViewport(), origin); + this->flushScissor(clip.scissorState(), glRT->getViewport(), origin); this->flushWindowRectangles(clip.windowRectsState(), glRT, origin); GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); @@ -1930,7 +1924,7 @@ void GrGLGpu::clearStencil(GrRenderTarget* target, int clearValue) { GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); this->flushRenderTargetNoColorWrites(glRT); - this->flushScissorTest(GrScissorTest::kDisabled); + this->disableScissor(); this->disableWindowRectangles(); GL_CALL(StencilMask(0xffffffff)); @@ -1978,7 +1972,7 @@ void GrGLGpu::clearStencilClip(const GrFixedClip& clip, GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(target); this->flushRenderTargetNoColorWrites(glRT); - this->flushScissorState(clip.scissorState(), glRT->getViewport(), origin); + this->flushScissor(clip.scissorState(), glRT->getViewport(), origin); this->flushWindowRectangles(clip.windowRectsState(), glRT, origin); GL_CALL(StencilMask((uint32_t) clipStencilMask)); @@ -2260,8 +2254,8 @@ void GrGLGpu::draw(const GrPrimitiveProcessor& primProc, return; } - bool dynamicScissor = pipeline.scissorTest() == GrScissorTest::kEnabled && dynamicStateArrays && - dynamicStateArrays->fScissorRects; + bool dynamicScissor = + pipeline.isScissorEnabled() && dynamicStateArrays && dynamicStateArrays->fScissorRects; for (int i = 0; i < meshCount; ++i) { if (GrXferBarrierType barrierType = pipeline.xferBarrierType(*this->caps())) { this->xferBarrier(pipeline.renderTarget(), barrierType); @@ -2269,8 +2263,8 @@ void GrGLGpu::draw(const GrPrimitiveProcessor& primProc, if (dynamicScissor) { GrGLRenderTarget* glRT = static_cast<GrGLRenderTarget*>(pipeline.renderTarget()); - this->flushScissorRect(dynamicStateArrays->fScissorRects[i], glRT->getViewport(), - pipeline.proxy()->origin()); + this->flushScissor(GrScissorState(dynamicStateArrays->fScissorRects[i]), + glRT->getViewport(), pipeline.proxy()->origin()); } if (this->glCaps().requiresCullFaceEnableDisableWhenDrawingLinesAfterNonLines() && GrIsPrimTypeLines(meshes[i].primitiveType()) && @@ -2414,7 +2408,9 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { static constexpr auto kDirtyRectOrigin = kTopLeft_GrSurfaceOrigin; if (GrGLCaps::kES_Apple_MSFBOType == this->glCaps().msFBOType()) { // Apple's extension uses the scissor as the blit bounds. - this->flushScissorState(GrScissorState(dirtyRect), vp, kDirtyRectOrigin); + GrScissorState scissorState; + scissorState.set(dirtyRect); + this->flushScissor(scissorState, vp, kDirtyRectOrigin); this->disableWindowRectangles(); GL_CALL(ResolveMultisampleFramebuffer()); } else { @@ -2435,7 +2431,7 @@ void GrGLGpu::onResolveRenderTarget(GrRenderTarget* target) { } // BlitFrameBuffer respects the scissor, so disable it. - this->flushScissorTest(GrScissorTest::kDisabled); + this->disableScissor(); this->disableWindowRectangles(); GL_CALL(BlitFramebuffer(l, b, r, t, l, b, r, t, GR_GL_COLOR_BUFFER_BIT, GR_GL_NEAREST)); @@ -3459,7 +3455,7 @@ void GrGLGpu::clearStencilClipAsDraw(const GrFixedClip& clip, bool insideStencil this->flushBlend(blendInfo, GrSwizzle::RGBA()); this->flushColorWrite(false); this->flushHWAAState(glRT, false, false); - this->flushScissorState(clip.scissorState(), glRT->getViewport(), origin); + this->flushScissor(clip.scissorState(), glRT->getViewport(), origin); this->flushWindowRectangles(clip.windowRectsState(), glRT, origin); GrStencilAttachment* sb = rt->renderTargetPriv().getStencilAttachment(); // This should only be called internally when we know we have a stencil buffer. @@ -3567,7 +3563,7 @@ void GrGLGpu::clearColorAsDraw(const GrFixedClip& clip, GrGLfloat r, GrGLfloat g 2 * sizeof(GrGLfloat), 0); GrGLRenderTarget* glrt = static_cast<GrGLRenderTarget*>(dst); - this->flushScissorState(clip.scissorState(), glrt->getViewport(), origin); + this->flushScissor(clip.scissorState(), glrt->getViewport(), origin); this->flushWindowRectangles(clip.windowRectsState(), glrt, origin); GL_CALL(Uniform4f(fClearColorProgram.fColorUniform, r, g, b, a)); @@ -3584,9 +3580,7 @@ void GrGLGpu::clearColorAsDraw(const GrFixedClip& clip, GrGLfloat r, GrGLfloat g GL_CALL(DrawArrays(GR_GL_TRIANGLE_STRIP, 0, 4)); this->unbindTextureFBOForPixelOps(GR_GL_FRAMEBUFFER, dst); - const auto* rect = - clip.scissorTest() == GrScissorTest::kEnabled ? &clip.scissorRect() : nullptr; - this->didWriteToSurface(dst, origin, rect); + this->didWriteToSurface(dst, origin, clip.scissorEnabled() ? &clip.scissorRect() : nullptr); } bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin, @@ -3666,7 +3660,7 @@ bool GrGLGpu::copySurfaceAsDraw(GrSurface* dst, GrSurfaceOrigin dstOrigin, this->flushBlend(blendInfo, GrSwizzle::RGBA()); this->flushColorWrite(true); this->flushHWAAState(nullptr, false, false); - this->flushScissorTest(GrScissorTest::kDisabled); + this->disableScissor(); this->disableWindowRectangles(); this->disableStencil(); if (this->glCaps().srgbWriteControl()) { @@ -3738,7 +3732,7 @@ bool GrGLGpu::copySurfaceAsBlitFramebuffer(GrSurface* dst, GrSurfaceOrigin dstOr dstGLRect.setRelativeTo(dstVP, dstRect, dstOrigin); // BlitFrameBuffer respects the scissor, so disable it. - this->flushScissorTest(GrScissorTest::kDisabled); + this->disableScissor(); this->disableWindowRectangles(); GrGLint srcY0; @@ -3833,7 +3827,7 @@ bool GrGLGpu::onRegenerateMipMapLevels(GrTexture* texture) { this->flushBlend(blendInfo, GrSwizzle::RGBA()); this->flushColorWrite(true); this->flushHWAAState(nullptr, false, false); - this->flushScissorTest(GrScissorTest::kDisabled); + this->disableScissor(); this->disableWindowRectangles(); this->disableStencil(); diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h index 0448f11a45..765d5f67ee 100644 --- a/src/gpu/gl/GrGLGpu.h +++ b/src/gpu/gl/GrGLGpu.h @@ -328,9 +328,14 @@ private: void flushColorWrite(bool writeColor); - void flushScissorTest(GrScissorTest); - void flushScissorRect(const SkIRect& scissorRect, const GrGLIRect& viewport, GrSurfaceOrigin); - void flushScissorState(const GrScissorState&, const GrGLIRect& viewport, GrSurfaceOrigin); + // flushes the scissor. see the note on flushBoundTextureAndParams about + // flushing the scissor after that function is called. + void flushScissor(const GrScissorState&, + const GrGLIRect& rtViewport, + GrSurfaceOrigin rtOrigin); + + // disables the scissor + void disableScissor(); void flushWindowRectangles(const GrWindowRectsState&, const GrGLRenderTarget*, GrSurfaceOrigin); void disableWindowRectangles(); diff --git a/src/gpu/gl/GrGLPathRendering.cpp b/src/gpu/gl/GrGLPathRendering.cpp index dbadd5801e..85c129f8b0 100644 --- a/src/gpu/gl/GrGLPathRendering.cpp +++ b/src/gpu/gl/GrGLPathRendering.cpp @@ -90,7 +90,7 @@ void GrGLPathRendering::onStencilPath(const StencilPathArgs& args, const GrPath* GrGLRenderTarget* rt = static_cast<GrGLRenderTarget*>(args.fProxy->priv().peekRenderTarget()); SkISize size = SkISize::Make(rt->width(), rt->height()); this->setProjectionMatrix(*args.fViewMatrix, size, args.fProxy->origin()); - gpu->flushScissorState(*args.fScissor, rt->getViewport(), args.fProxy->origin()); + gpu->flushScissor(*args.fScissor, rt->getViewport(), args.fProxy->origin()); gpu->flushHWAAState(rt, args.fUseHWAA, true); gpu->flushRenderTarget(rt); diff --git a/src/gpu/ops/GrClearOp.cpp b/src/gpu/ops/GrClearOp.cpp index 52360dbe93..612ff2085d 100644 --- a/src/gpu/ops/GrClearOp.cpp +++ b/src/gpu/ops/GrClearOp.cpp @@ -17,8 +17,7 @@ std::unique_ptr<GrClearOp> GrClearOp::Make(GrContext* context, GrColor color, GrSurfaceProxy* dstProxy) { const SkIRect rect = SkIRect::MakeWH(dstProxy->width(), dstProxy->height()); - if (clip.scissorTest() == GrScissorTest::kEnabled && - !SkIRect::Intersects(clip.scissorRect(), rect)) { + if (clip.scissorEnabled() && !SkIRect::Intersects(clip.scissorRect(), rect)) { return nullptr; } @@ -43,7 +42,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.scissorTest() == GrScissorTest::kEnabled) { + if (fClip.scissorEnabled()) { // Don't let scissors extend outside the RT. This may improve op combining. if (!fClip.intersect(rtRect)) { SkASSERT(0); // should be caught upstream @@ -54,10 +53,8 @@ GrClearOp::GrClearOp(const GrFixedClip& clip, GrColor color, GrSurfaceProxy* pro fClip.disableScissor(); } } - this->setBounds( - SkRect::Make(fClip.scissorTest() == GrScissorTest::kEnabled ? fClip.scissorRect() - : rtRect), - HasAABloat::kNo, IsZeroArea::kNo); + this->setBounds(SkRect::Make(fClip.scissorEnabled() ? 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 59929b269a..6e76191dff 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.scissorTest() == GrScissorTest::kEnabled) { + if (fClip.scissorEnabled()) { 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,11 +83,9 @@ private: bool contains(const GrClearOp* that) const { // The constructor ensures that scissor gets disabled on any clip that fills the entire RT. - if (fClip.scissorTest() == GrScissorTest::kDisabled) { - return true; - } - return that->fClip.scissorTest() == GrScissorTest::kEnabled && - fClip.scissorRect().contains(that->fClip.scissorRect()); + return !fClip.scissorEnabled() || + (that->fClip.scissorEnabled() && + 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 09c05e1ceb..3e7ad5070f 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.scissorTest() == GrScissorTest::kEnabled) { + if (fClip.scissorEnabled()) { 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.scissorTest() == GrScissorTest::kEnabled - ? SkRect::Make(fClip.scissorRect()) - : SkRect::MakeIWH(proxy->width(), proxy->height()); + const SkRect& bounds = fClip.scissorEnabled() + ? 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 6b56183752..f395927b63 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().scissorTest() == GrScissorTest::kEnabled) { + if (appliedClip.scissorState().enabled()) { stencilClip.fixedClip().setScissor(appliedClip.scissorState().rect()); } if (appliedClip.windowRectsState().enabled()) { diff --git a/src/gpu/vk/GrVkGpuCommandBuffer.cpp b/src/gpu/vk/GrVkGpuCommandBuffer.cpp index 63ebba0f25..91adb5a778 100644 --- a/src/gpu/vk/GrVkGpuCommandBuffer.cpp +++ b/src/gpu/vk/GrVkGpuCommandBuffer.cpp @@ -305,7 +305,7 @@ void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool in VkClearRect clearRect; // Flip rect if necessary SkIRect vkRect; - if (clip.scissorTest() == GrScissorTest::kDisabled) { + if (!clip.scissorEnabled()) { vkRect.setXYWH(0, 0, fRenderTarget->width(), fRenderTarget->height()); } else if (kBottomLeft_GrSurfaceOrigin != fOrigin) { vkRect = clip.scissorRect(); @@ -333,7 +333,7 @@ void GrVkGpuRTCommandBuffer::onClearStencilClip(const GrFixedClip& clip, bool in cbInfo.fIsEmpty = false; // Update command buffer bounds - if (clip.scissorTest() == GrScissorTest::kDisabled) { + if (!clip.scissorEnabled()) { cbInfo.fBounds.join(fRenderTarget->getBoundsRect()); } else { cbInfo.fBounds.join(SkRect::Make(clip.scissorRect())); @@ -351,7 +351,7 @@ void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) { VkClearColorValue vkColor; GrColorToRGBAFloat(color, vkColor.float32); - if (cbInfo.fIsEmpty && clip.scissorTest() == GrScissorTest::kDisabled) { + if (cbInfo.fIsEmpty && !clip.scissorEnabled()) { // Change the render pass to do a clear load GrVkRenderPass::LoadStoreOps vkColorOps(VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_STORE_OP_STORE); @@ -390,7 +390,7 @@ void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) { VkClearRect clearRect; // Flip rect if necessary SkIRect vkRect; - if (clip.scissorTest() == GrScissorTest::kDisabled) { + if (!clip.scissorEnabled()) { vkRect.setXYWH(0, 0, fRenderTarget->width(), fRenderTarget->height()); } else if (kBottomLeft_GrSurfaceOrigin != fOrigin) { vkRect = clip.scissorRect(); @@ -416,7 +416,7 @@ void GrVkGpuRTCommandBuffer::onClear(const GrFixedClip& clip, GrColor color) { cbInfo.fIsEmpty = false; // Update command buffer bounds - if (clip.scissorTest() == GrScissorTest::kDisabled) { + if (!clip.scissorEnabled()) { cbInfo.fBounds.join(fRenderTarget->getBoundsRect()); } else { cbInfo.fBounds.join(SkRect::Make(clip.scissorRect())); @@ -591,7 +591,7 @@ GrVkPipelineState* GrVkGpuRTCommandBuffer::prepareDrawState( GrRenderTarget* rt = pipeline.renderTarget(); - if (pipeline.scissorTest() == GrScissorTest::kDisabled) { + if (!pipeline.isScissorEnabled()) { GrVkPipeline::SetDynamicScissorRectState(fGpu, cbInfo.currentCmdBuf(), rt, pipeline.proxy()->origin(), SkIRect::MakeWH(rt->width(), rt->height())); @@ -663,8 +663,8 @@ void GrVkGpuRTCommandBuffer::onDraw(const GrPrimitiveProcessor& primProc, return; } - bool dynamicScissor = (pipeline.scissorTest() == GrScissorTest::kEnabled) && - dynamicStateArrays && dynamicStateArrays->fScissorRects; + bool dynamicScissor = + pipeline.isScissorEnabled() && dynamicStateArrays && dynamicStateArrays->fScissorRects; for (int i = 0; i < meshCount; ++i) { const GrMesh& mesh = meshes[i]; |