| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
| 10 | 10 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 138 } |
| 139 | 139 |
| 140 void GrDrawTarget::reset() { | 140 void GrDrawTarget::reset() { |
| 141 fFirstUnpreparedBatch = 0; | 141 fFirstUnpreparedBatch = 0; |
| 142 fBatches.reset(); | 142 fBatches.reset(); |
| 143 fFlushState.reset(); | 143 fFlushState.reset(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { | 146 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { |
| 147 // Setup clip | 147 // Setup clip |
| 148 GrScissorState scissorState; | |
| 149 GrPipelineBuilder::AutoRestoreStencil ars; | 148 GrPipelineBuilder::AutoRestoreStencil ars; |
| 150 GrAppliedClip clip; | 149 GrAppliedClip clip; |
| 151 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &
batch->bounds(), | 150 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { |
| 152 &clip)) { | |
| 153 return; | 151 return; |
| 154 } | 152 } |
| 155 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 153 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 156 if (clip.clipCoverageFragmentProcessor()) { | 154 if (clip.clipCoverageFragmentProcessor()) { |
| 157 arfps.set(&pipelineBuilder); | 155 arfps.set(&pipelineBuilder); |
| 158 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | 156 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; |
| 159 } | 157 } |
| 160 | 158 |
| 161 GrPipeline::CreateArgs args; | 159 GrPipeline::CreateArgs args; |
| 162 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch
)) { | 160 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { |
| 163 return; | 161 return; |
| 164 } | 162 } |
| 165 | 163 |
| 166 this->recordBatch(batch); | 164 this->recordBatch(batch); |
| 167 } | 165 } |
| 168 | 166 |
| 169 static const GrStencilSettings& winding_path_stencil_settings() { | 167 static const GrStencilSettings& winding_path_stencil_settings() { |
| 170 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | 168 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
| 171 kIncClamp_StencilOp, | 169 kIncClamp_StencilOp, |
| 172 kIncClamp_StencilOp, | 170 kIncClamp_StencilOp, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 203 | 201 |
| 204 void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, | 202 void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
| 205 const SkMatrix& viewMatrix, | 203 const SkMatrix& viewMatrix, |
| 206 const GrPath* path, | 204 const GrPath* path, |
| 207 GrPathRendering::FillType fill) { | 205 GrPathRendering::FillType fill) { |
| 208 // TODO: extract portions of checkDraw that are relevant to path stenciling. | 206 // TODO: extract portions of checkDraw that are relevant to path stenciling. |
| 209 SkASSERT(path); | 207 SkASSERT(path); |
| 210 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | 208 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
| 211 | 209 |
| 212 // Setup clip | 210 // Setup clip |
| 213 GrScissorState scissorState; | |
| 214 GrPipelineBuilder::AutoRestoreStencil ars; | 211 GrPipelineBuilder::AutoRestoreStencil ars; |
| 215 GrAppliedClip clip; | 212 GrAppliedClip clip; |
| 216 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, n
ullptr, &clip)) { | 213 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, nullptr, &clip))
{ |
| 217 return; | 214 return; |
| 218 } | 215 } |
| 219 | 216 |
| 220 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 217 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 221 if (clip.clipCoverageFragmentProcessor()) { | 218 if (clip.clipCoverageFragmentProcessor()) { |
| 222 arfps.set(&pipelineBuilder); | 219 arfps.set(&pipelineBuilder); |
| 223 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | 220 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; |
| 224 } | 221 } |
| 225 | 222 |
| 226 // set stencil settings for path | 223 // set stencil settings for path |
| 227 GrStencilSettings stencilSettings; | 224 GrStencilSettings stencilSettings; |
| 228 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 225 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
| 229 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); | 226 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
| 230 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 227 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
| 231 | 228 |
| 232 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, | 229 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
| 233 pipelineBuilder.isHWAntialias(), | 230 pipelineBuilder.isHWAntialias(), |
| 234 stencilSettings, scissorState, | 231 stencilSettings, clip.scissorSta
te(), |
| 235 pipelineBuilder.getRenderTarget(
), | 232 pipelineBuilder.getRenderTarget(
), |
| 236 path); | 233 path); |
| 237 this->recordBatch(batch); | 234 this->recordBatch(batch); |
| 238 batch->unref(); | 235 batch->unref(); |
| 239 } | 236 } |
| 240 | 237 |
| 241 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, | 238 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, |
| 242 const SkMatrix& viewMatrix, | 239 const SkMatrix& viewMatrix, |
| 243 GrColor color, | 240 GrColor color, |
| 244 const GrPath* path, | 241 const GrPath* path, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 263 } | 260 } |
| 264 | 261 |
| 265 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, | 262 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
| 266 GrDrawPathBatchBase* batch, | 263 GrDrawPathBatchBase* batch, |
| 267 GrPathRendering::FillType fill) { | 264 GrPathRendering::FillType fill) { |
| 268 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted | 265 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted |
| 269 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for | 266 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for |
| 270 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and | 267 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and |
| 271 // batches. | 268 // batches. |
| 272 | 269 |
| 273 GrScissorState scissorState; | |
| 274 GrPipelineBuilder::AutoRestoreStencil ars; | 270 GrPipelineBuilder::AutoRestoreStencil ars; |
| 275 GrAppliedClip clip; | 271 GrAppliedClip clip; |
| 276 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &
batch->bounds(), | 272 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { |
| 277 &clip)) { | |
| 278 return; | 273 return; |
| 279 } | 274 } |
| 280 | 275 |
| 281 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 276 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 282 if (clip.clipCoverageFragmentProcessor()) { | 277 if (clip.clipCoverageFragmentProcessor()) { |
| 283 arfps.set(&pipelineBuilder); | 278 arfps.set(&pipelineBuilder); |
| 284 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | 279 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; |
| 285 } | 280 } |
| 286 | 281 |
| 287 // Ensure the render target has a stencil buffer and get the stencil setting
s. | 282 // Ensure the render target has a stencil buffer and get the stencil setting
s. |
| 288 GrStencilSettings stencilSettings; | 283 GrStencilSettings stencilSettings; |
| 289 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 284 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
| 290 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); | 285 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
| 291 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 286 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
| 292 batch->setStencilSettings(stencilSettings); | 287 batch->setStencilSettings(stencilSettings); |
| 293 | 288 |
| 294 GrPipeline::CreateArgs args; | 289 GrPipeline::CreateArgs args; |
| 295 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch
)) { | 290 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { |
| 296 return; | 291 return; |
| 297 } | 292 } |
| 298 | 293 |
| 299 this->recordBatch(batch); | 294 this->recordBatch(batch); |
| 300 } | 295 } |
| 301 | 296 |
| 302 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, | 297 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
| 303 GrColor color, | 298 GrColor color, |
| 304 const SkMatrix& viewMatrix, | 299 const SkMatrix& viewMatrix, |
| 305 const SkRect& rect) { | 300 const SkRect& rect) { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 } | 474 } |
| 480 | 475 |
| 481 return true; | 476 return true; |
| 482 } | 477 } |
| 483 | 478 |
| 484 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 479 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 485 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 480 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 486 this->recordBatch(batch); | 481 this->recordBatch(batch); |
| 487 batch->unref(); | 482 batch->unref(); |
| 488 } | 483 } |
| OLD | NEW |