Move scissor state to GrAppliedClip
authorbsalomon <bsalomon@google.com>
Tue, 27 Oct 2015 13:42:50 +0000 (06:42 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 27 Oct 2015 13:42:50 +0000 (06:42 -0700)
Review URL: https://codereview.chromium.org/1385233002

src/gpu/GrClipMaskManager.cpp
src/gpu/GrClipMaskManager.h
src/gpu/GrDrawTarget.cpp

index 2596a06..4c651f7 100644 (file)
@@ -209,7 +209,6 @@ bool GrClipMaskManager::getAnalyticClipProcessor(const GrReducedClip::ElementLis
 // scissor, or entirely software
 bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
                                       GrPipelineBuilder::AutoRestoreStencil* ars,
-                                      GrScissorState* scissorState,
                                       const SkRect* devBounds,
                                       GrAppliedClip* out) {
     if (kRespectClip_StencilClipMode == fClipMode) {
@@ -242,7 +241,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
         case GrClip::kIRect_ClipType: {
             SkIRect scissor = clip.irect();
             if (scissor.intersect(clipSpaceRTIBounds)) {
-                scissorState->set(scissor);
+                out->fScissorState.set(scissor);
                 this->setPipelineBuilderStencil(pipelineBuilder, ars);
                 return true;
             }
@@ -293,7 +292,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
             scissorSpaceIBounds.offset(-clip.origin());
             if (nullptr == devBounds ||
                 !SkRect::Make(scissorSpaceIBounds).contains(*devBounds)) {
-                scissorState->set(scissorSpaceIBounds);
+                out->fScissorState.set(scissorSpaceIBounds);
             }
             this->setPipelineBuilderStencil(pipelineBuilder, ars);
             out->fClipCoverageFP.reset(clipFP);
@@ -353,7 +352,7 @@ bool GrClipMaskManager::setupClipping(const GrPipelineBuilder& pipelineBuilder,
     // use both stencil and scissor test to the bounds for the final draw.
     SkIRect scissorSpaceIBounds(clipSpaceIBounds);
     scissorSpaceIBounds.offset(clipSpaceToStencilSpaceOffset);
-    scissorState->set(scissorSpaceIBounds);
+    out->fScissorState.set(scissorSpaceIBounds);
     this->setPipelineBuilderStencil(pipelineBuilder, ars);
     return true;
 }
index 3ce3e72..9b5607e 100644 (file)
@@ -34,9 +34,11 @@ class GrAppliedClip : public SkNoncopyable {
 public:
     GrAppliedClip() {}
     const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fClipCoverageFP; }
+    const GrScissorState& scissorState() const { return fScissorState; }
 
 private:
     SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP;
+    GrScissorState                          fScissorState;
     friend class GrClipMaskManager;
 
     typedef SkNoncopyable INHERITED;
@@ -63,7 +65,6 @@ public:
      */
     bool setupClipping(const GrPipelineBuilder&,
                        GrPipelineBuilder::AutoRestoreStencil*,
-                       GrScissorState*,
                        const SkRect* devBounds,
                        GrAppliedClip*);
 
index 1dc26bc..5a3fecc 100644 (file)
@@ -211,11 +211,9 @@ void GrDrawTarget::reset() {
 
 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBatch* batch) {
     // Setup clip
-    GrScissorState scissorState;
     GrPipelineBuilder::AutoRestoreStencil ars;
     GrAppliedClip clip;
-    if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &batch->bounds(),
-                                         &clip)) {
+    if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds(), &clip)) {
         return;
     }
     GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
@@ -225,7 +223,7 @@ void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
     }
 
     GrPipeline::CreateArgs args;
-    if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch)) {
+    if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), batch)) {
         return;
     }
 
@@ -276,10 +274,9 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
     SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport());
 
     // Setup clip
-    GrScissorState scissorState;
     GrPipelineBuilder::AutoRestoreStencil ars;
     GrAppliedClip clip;
-    if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, nullptr, &clip)) {
+    if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, nullptr, &clip)) {
         return;
     }
 
@@ -297,7 +294,7 @@ void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder,
 
     GrBatch* batch = GrStencilPathBatch::Create(viewMatrix,
                                                 pipelineBuilder.isHWAntialias(),
-                                                stencilSettings, scissorState,
+                                                stencilSettings, clip.scissorState(),
                                                 pipelineBuilder.getRenderTarget(),
                                                 path);
     this->recordBatch(batch);
@@ -338,11 +335,9 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder,
     // handling stencil settings WRT interactions between pipeline(builder), clipmaskmanager, and
     // batches.
 
-    GrScissorState scissorState;
     GrPipelineBuilder::AutoRestoreStencil ars;
     GrAppliedClip clip;
-    if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &batch->bounds(),
-                                         &clip)) {
+    if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds(), &clip)) {
         return;
     }
 
@@ -360,7 +355,7 @@ void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder,
     batch->setStencilSettings(stencilSettings);
 
     GrPipeline::CreateArgs args;
-    if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch)) {
+    if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState(), batch)) {
         return;
     }