OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrDrawTarget.h" | 8 #include "GrDrawTarget.h" |
9 | 9 |
10 #include "GrAuditTrail.h" | 10 #include "GrAuditTrail.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 232 |
233 void GrDrawTarget::reset() { | 233 void GrDrawTarget::reset() { |
234 fBatches.reset(); | 234 fBatches.reset(); |
235 } | 235 } |
236 | 236 |
237 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, | 237 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, |
238 const GrClip& clip, | 238 const GrClip& clip, |
239 GrDrawBatch* batch) { | 239 GrDrawBatch* batch) { |
240 // Setup clip | 240 // Setup clip |
241 GrAppliedClip appliedClip; | 241 GrAppliedClip appliedClip; |
242 if (!fClipMaskManager->setupClipping(pipelineBuilder, clip, &batch->bounds()
, &appliedClip)) { | 242 if (!clip.apply(fClipMaskManager, pipelineBuilder, &batch->bounds(), &applie
dClip)) { |
243 return; | 243 return; |
244 } | 244 } |
245 | 245 |
246 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 246 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
247 if (appliedClip.clipCoverageFragmentProcessor()) { | 247 if (appliedClip.clipCoverageFragmentProcessor()) { |
248 arfps.set(&pipelineBuilder); | 248 arfps.set(&pipelineBuilder); |
249 arfps.addCoverageFragmentProcessor(appliedClip.clipCoverageFragmentProce
ssor()); | 249 arfps.addCoverageFragmentProcessor(appliedClip.clipCoverageFragmentProce
ssor()); |
250 } | 250 } |
251 | 251 |
252 GrPipeline::CreateArgs args; | 252 GrPipeline::CreateArgs args; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 const GrClip& clip, | 310 const GrClip& clip, |
311 const SkMatrix& viewMatrix, | 311 const SkMatrix& viewMatrix, |
312 const GrPath* path, | 312 const GrPath* path, |
313 GrPathRendering::FillType fill) { | 313 GrPathRendering::FillType fill) { |
314 // TODO: extract portions of checkDraw that are relevant to path stenciling. | 314 // TODO: extract portions of checkDraw that are relevant to path stenciling. |
315 SkASSERT(path); | 315 SkASSERT(path); |
316 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); | 316 SkASSERT(this->caps()->shaderCaps()->pathRenderingSupport()); |
317 | 317 |
318 // Setup clip | 318 // Setup clip |
319 GrAppliedClip appliedClip; | 319 GrAppliedClip appliedClip; |
320 if (!fClipMaskManager->setupClipping(pipelineBuilder, clip, nullptr, &applie
dClip)) { | 320 if (!clip.apply(fClipMaskManager, pipelineBuilder, nullptr, &appliedClip)) { |
321 return; | 321 return; |
322 } | 322 } |
323 // TODO: respect fClipBatchToBounds if we ever start computing bounds here. | 323 // TODO: respect fClipBatchToBounds if we ever start computing bounds here. |
324 | 324 |
325 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 325 // Coverage AA does not make sense when rendering to the stencil buffer. The
caller should never |
326 if (appliedClip.clipCoverageFragmentProcessor()) { | 326 // attempt this in a situation that would require coverage AA. |
327 arfps.set(&pipelineBuilder); | 327 SkASSERT(!appliedClip.clipCoverageFragmentProcessor()); |
328 arfps.addCoverageFragmentProcessor(appliedClip.clipCoverageFragmentProce
ssor()); | |
329 } | |
330 | 328 |
331 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 329 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
332 GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAtt
achment(rt); | 330 GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAtt
achment(rt); |
333 | 331 |
334 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, | 332 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
335 pipelineBuilder.isHWAntialias(), | 333 pipelineBuilder.isHWAntialias(), |
336 fill, | 334 fill, |
337 appliedClip.hasStencilClip(), | 335 appliedClip.hasStencilClip(), |
338 stencilAttachment->bits(), | 336 stencilAttachment->bits(), |
339 appliedClip.scissorState(), | 337 appliedClip.scissorState(), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 | 369 |
372 GrPipelineBuilder pipelineBuilder; | 370 GrPipelineBuilder pipelineBuilder; |
373 pipelineBuilder.setXPFactory( | 371 pipelineBuilder.setXPFactory( |
374 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref(); | 372 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref(); |
375 pipelineBuilder.setRenderTarget(renderTarget); | 373 pipelineBuilder.setRenderTarget(renderTarget); |
376 | 374 |
377 SkRect scalarRect = SkRect::Make(*rect); | 375 SkRect scalarRect = SkRect::Make(*rect); |
378 SkAutoTUnref<GrDrawBatch> batch( | 376 SkAutoTUnref<GrDrawBatch> batch( |
379 GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalar
Rect, | 377 GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalar
Rect, |
380 nullptr, nullptr)); | 378 nullptr, nullptr)); |
381 this->drawBatch(pipelineBuilder, GrClip::WideOpen(), batch); | 379 this->drawBatch(pipelineBuilder, GrNoClip(), batch); |
382 } else { | 380 } else { |
383 GrBatch* batch = new GrClearBatch(*rect, color, renderTarget); | 381 GrBatch* batch = new GrClearBatch(*rect, color, renderTarget); |
384 this->recordBatch(batch); | 382 this->recordBatch(batch); |
385 batch->unref(); | 383 batch->unref(); |
386 } | 384 } |
387 } | 385 } |
388 | 386 |
389 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { | 387 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { |
390 if (this->caps()->discardRenderTargetSupport()) { | 388 if (this->caps()->discardRenderTargetSupport()) { |
391 GrBatch* batch = new GrDiscardBatch(renderTarget); | 389 GrBatch* batch = new GrDiscardBatch(renderTarget); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 514 } |
517 } | 515 } |
518 | 516 |
519 /////////////////////////////////////////////////////////////////////////////// | 517 /////////////////////////////////////////////////////////////////////////////// |
520 | 518 |
521 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 519 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
522 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 520 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
523 this->recordBatch(batch); | 521 this->recordBatch(batch); |
524 batch->unref(); | 522 batch->unref(); |
525 } | 523 } |
OLD | NEW |