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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 } | 204 } |
205 | 205 |
206 void GrDrawTarget::reset() { | 206 void GrDrawTarget::reset() { |
207 fFirstUnpreparedBatch = 0; | 207 fFirstUnpreparedBatch = 0; |
208 fBatches.reset(); | 208 fBatches.reset(); |
209 fFlushState.reset(); | 209 fFlushState.reset(); |
210 } | 210 } |
211 | 211 |
212 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { | 212 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { |
213 // Setup clip | 213 // Setup clip |
214 GrScissorState scissorState; | |
215 GrPipelineBuilder::AutoRestoreStencil ars; | 214 GrPipelineBuilder::AutoRestoreStencil ars; |
216 GrAppliedClip clip; | 215 GrAppliedClip clip; |
217 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &
batch->bounds(), | 216 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { |
218 &clip)) { | |
219 return; | 217 return; |
220 } | 218 } |
221 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 219 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
222 if (clip.clipCoverageFragmentProcessor()) { | 220 if (clip.clipCoverageFragmentProcessor()) { |
223 arfps.set(&pipelineBuilder); | 221 arfps.set(&pipelineBuilder); |
224 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | 222 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; |
225 } | 223 } |
226 | 224 |
227 GrPipeline::CreateArgs args; | 225 GrPipeline::CreateArgs args; |
228 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch
)) { | 226 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { |
229 return; | 227 return; |
230 } | 228 } |
231 | 229 |
232 this->recordBatch(batch); | 230 this->recordBatch(batch); |
233 } | 231 } |
234 | 232 |
235 static const GrStencilSettings& winding_path_stencil_settings() { | 233 static const GrStencilSettings& winding_path_stencil_settings() { |
236 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | 234 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
237 kIncClamp_StencilOp, | 235 kIncClamp_StencilOp, |
238 kIncClamp_StencilOp, | 236 kIncClamp_StencilOp, |
(...skipping 30 matching lines...) Expand all Loading... |
269 | 267 |
270 void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, | 268 void GrDrawTarget::stencilPath(const GrPipelineBuilder& pipelineBuilder, |
271 const SkMatrix& viewMatrix, | 269 const SkMatrix& viewMatrix, |
272 const GrPath* path, | 270 const GrPath* path, |
273 GrPathRendering::FillType fill) { | 271 GrPathRendering::FillType fill) { |
274 // TODO: extract portions of checkDraw that are relevant to path stenciling. | 272 // TODO: extract portions of checkDraw that are relevant to path stenciling. |
275 SkASSERT(path); | 273 SkASSERT(path); |
276 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | 274 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
277 | 275 |
278 // Setup clip | 276 // Setup clip |
279 GrScissorState scissorState; | |
280 GrPipelineBuilder::AutoRestoreStencil ars; | 277 GrPipelineBuilder::AutoRestoreStencil ars; |
281 GrAppliedClip clip; | 278 GrAppliedClip clip; |
282 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, n
ullptr, &clip)) { | 279 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, nullptr, &clip))
{ |
283 return; | 280 return; |
284 } | 281 } |
285 | 282 |
286 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 283 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
287 if (clip.clipCoverageFragmentProcessor()) { | 284 if (clip.clipCoverageFragmentProcessor()) { |
288 arfps.set(&pipelineBuilder); | 285 arfps.set(&pipelineBuilder); |
289 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | 286 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; |
290 } | 287 } |
291 | 288 |
292 // set stencil settings for path | 289 // set stencil settings for path |
293 GrStencilSettings stencilSettings; | 290 GrStencilSettings stencilSettings; |
294 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 291 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
295 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); | 292 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
296 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 293 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
297 | 294 |
298 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, | 295 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
299 pipelineBuilder.isHWAntialias(), | 296 pipelineBuilder.isHWAntialias(), |
300 stencilSettings, scissorState, | 297 stencilSettings, clip.scissorSta
te(), |
301 pipelineBuilder.getRenderTarget(
), | 298 pipelineBuilder.getRenderTarget(
), |
302 path); | 299 path); |
303 this->recordBatch(batch); | 300 this->recordBatch(batch); |
304 batch->unref(); | 301 batch->unref(); |
305 } | 302 } |
306 | 303 |
307 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, | 304 void GrDrawTarget::drawPath(const GrPipelineBuilder& pipelineBuilder, |
308 const SkMatrix& viewMatrix, | 305 const SkMatrix& viewMatrix, |
309 GrColor color, | 306 GrColor color, |
310 const GrPath* path, | 307 const GrPath* path, |
(...skipping 20 matching lines...) Expand all Loading... |
331 } | 328 } |
332 | 329 |
333 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, | 330 void GrDrawTarget::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, |
334 GrDrawPathBatchBase* batch, | 331 GrDrawPathBatchBase* batch, |
335 GrPathRendering::FillType fill) { | 332 GrPathRendering::FillType fill) { |
336 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted | 333 // This looks like drawBatch() but there is an added wrinkle that stencil se
ttings get inserted |
337 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for | 334 // after setting up clipping but before onDrawBatch(). TODO: Figure out a be
tter model for |
338 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and | 335 // handling stencil settings WRT interactions between pipeline(builder), cli
pmaskmanager, and |
339 // batches. | 336 // batches. |
340 | 337 |
341 GrScissorState scissorState; | |
342 GrPipelineBuilder::AutoRestoreStencil ars; | 338 GrPipelineBuilder::AutoRestoreStencil ars; |
343 GrAppliedClip clip; | 339 GrAppliedClip clip; |
344 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &scissorState, &
batch->bounds(), | 340 if (!fClipMaskManager->setupClipping(pipelineBuilder, &ars, &batch->bounds()
, &clip)) { |
345 &clip)) { | |
346 return; | 341 return; |
347 } | 342 } |
348 | 343 |
349 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 344 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
350 if (clip.clipCoverageFragmentProcessor()) { | 345 if (clip.clipCoverageFragmentProcessor()) { |
351 arfps.set(&pipelineBuilder); | 346 arfps.set(&pipelineBuilder); |
352 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; | 347 arfps.addCoverageFragmentProcessor(clip.clipCoverageFragmentProcessor())
; |
353 } | 348 } |
354 | 349 |
355 // Ensure the render target has a stencil buffer and get the stencil setting
s. | 350 // Ensure the render target has a stencil buffer and get the stencil setting
s. |
356 GrStencilSettings stencilSettings; | 351 GrStencilSettings stencilSettings; |
357 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 352 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
358 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); | 353 GrStencilAttachment* sb = fResourceProvider->attachStencilAttachment(rt); |
359 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); | 354 this->getPathStencilSettingsForFilltype(fill, sb, &stencilSettings); |
360 batch->setStencilSettings(stencilSettings); | 355 batch->setStencilSettings(stencilSettings); |
361 | 356 |
362 GrPipeline::CreateArgs args; | 357 GrPipeline::CreateArgs args; |
363 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &scissorState, batch
)) { | 358 if (!this->installPipelineInDrawBatch(&pipelineBuilder, &clip.scissorState()
, batch)) { |
364 return; | 359 return; |
365 } | 360 } |
366 | 361 |
367 this->recordBatch(batch); | 362 this->recordBatch(batch); |
368 } | 363 } |
369 | 364 |
370 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, | 365 void GrDrawTarget::drawNonAARect(const GrPipelineBuilder& pipelineBuilder, |
371 GrColor color, | 366 GrColor color, |
372 const SkMatrix& viewMatrix, | 367 const SkMatrix& viewMatrix, |
373 const SkRect& rect) { | 368 const SkRect& rect) { |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 } | 550 } |
556 | 551 |
557 return true; | 552 return true; |
558 } | 553 } |
559 | 554 |
560 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 555 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
561 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 556 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
562 this->recordBatch(batch); | 557 this->recordBatch(batch); |
563 batch->unref(); | 558 batch->unref(); |
564 } | 559 } |
OLD | NEW |