| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a
ppliedClip)) { | 242 if (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a
ppliedClip)) { |
| 243 return; | 243 return; |
| 244 } | 244 } |
| 245 | 245 |
| 246 // TODO: this is the only remaining usage of the AutoRestoreFragmentProcesso
rState - remove it | 246 // TODO: this is the only remaining usage of the AutoRestoreFragmentProcesso
rState - remove it |
| 247 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 247 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 248 if (appliedClip.clipCoverageFragmentProcessor()) { | 248 if (appliedClip.getClipCoverageFragmentProcessor()) { |
| 249 arfps.set(&pipelineBuilder); | 249 arfps.set(&pipelineBuilder); |
| 250 arfps.addCoverageFragmentProcessor(appliedClip.clipCoverageFragmentProce
ssor()); | 250 arfps.addCoverageFragmentProcessor(sk_ref_sp(appliedClip.getClipCoverage
FragmentProcessor())); |
| 251 } | 251 } |
| 252 | 252 |
| 253 GrPipeline::CreateArgs args; | 253 GrPipeline::CreateArgs args; |
| 254 args.fPipelineBuilder = &pipelineBuilder; | 254 args.fPipelineBuilder = &pipelineBuilder; |
| 255 args.fDrawContext = drawContext; | 255 args.fDrawContext = drawContext; |
| 256 args.fCaps = this->caps(); | 256 args.fCaps = this->caps(); |
| 257 args.fScissor = &appliedClip.scissorState(); | 257 args.fScissor = &appliedClip.scissorState(); |
| 258 args.fHasStencilClip = appliedClip.hasStencilClip(); | 258 args.fHasStencilClip = appliedClip.hasStencilClip(); |
| 259 if (pipelineBuilder.hasUserStencilSettings() || appliedClip.hasStencilClip()
) { | 259 if (pipelineBuilder.hasUserStencilSettings() || appliedClip.hasStencilClip()
) { |
| 260 if (!fResourceProvider->attachStencilAttachment(drawContext->accessRende
rTarget())) { | 260 if (!fResourceProvider->attachStencilAttachment(drawContext->accessRende
rTarget())) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 | 323 |
| 324 // Setup clip | 324 // Setup clip |
| 325 GrAppliedClip appliedClip; | 325 GrAppliedClip appliedClip; |
| 326 if (!clip.apply(fContext, pipelineBuilder, drawContext, nullptr, &appliedCli
p)) { | 326 if (!clip.apply(fContext, pipelineBuilder, drawContext, nullptr, &appliedCli
p)) { |
| 327 return; | 327 return; |
| 328 } | 328 } |
| 329 // TODO: respect fClipBatchToBounds if we ever start computing bounds here. | 329 // TODO: respect fClipBatchToBounds if we ever start computing bounds here. |
| 330 | 330 |
| 331 // Coverage AA does not make sense when rendering to the stencil buffer. The
caller should never | 331 // Coverage AA does not make sense when rendering to the stencil buffer. The
caller should never |
| 332 // attempt this in a situation that would require coverage AA. | 332 // attempt this in a situation that would require coverage AA. |
| 333 SkASSERT(!appliedClip.clipCoverageFragmentProcessor()); | 333 SkASSERT(!appliedClip.getClipCoverageFragmentProcessor()); |
| 334 | 334 |
| 335 GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAtt
achment( | 335 GrStencilAttachment* stencilAttachment = fResourceProvider->attachStencilAtt
achment( |
| 336 drawContext->accessRenderTarget(
)); | 336 drawContext->accessRenderTarget(
)); |
| 337 if (!stencilAttachment) { | 337 if (!stencilAttachment) { |
| 338 SkDebugf("ERROR creating stencil attachment. Draw skipped.\n"); | 338 SkDebugf("ERROR creating stencil attachment. Draw skipped.\n"); |
| 339 return; | 339 return; |
| 340 } | 340 } |
| 341 | 341 |
| 342 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, | 342 GrBatch* batch = GrStencilPathBatch::Create(viewMatrix, |
| 343 pipelineBuilder.isHWAntialias(), | 343 pipelineBuilder.isHWAntialias(), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 372 if (this->caps()->useDrawInsteadOfClear()) { | 372 if (this->caps()->useDrawInsteadOfClear()) { |
| 373 // This works around a driver bug with clear by drawing a rect instead. | 373 // This works around a driver bug with clear by drawing a rect instead. |
| 374 // The driver will ignore a clear if it is the only thing rendered to a | 374 // The driver will ignore a clear if it is the only thing rendered to a |
| 375 // target before the target is read. | 375 // target before the target is read. |
| 376 if (rect == &rtRect) { | 376 if (rect == &rtRect) { |
| 377 drawContext->discard(); | 377 drawContext->discard(); |
| 378 } | 378 } |
| 379 | 379 |
| 380 // TODO: flip this into real draw! | 380 // TODO: flip this into real draw! |
| 381 GrPipelineBuilder pipelineBuilder; | 381 GrPipelineBuilder pipelineBuilder; |
| 382 pipelineBuilder.setXPFactory( | 382 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSr
c_Mode)); |
| 383 GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode))->unref(); | |
| 384 | 383 |
| 385 SkRect scalarRect = SkRect::Make(*rect); | 384 SkRect scalarRect = SkRect::Make(*rect); |
| 386 SkAutoTUnref<GrDrawBatch> batch( | 385 SkAutoTUnref<GrDrawBatch> batch( |
| 387 GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalar
Rect, | 386 GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalar
Rect, |
| 388 nullptr, nullptr)); | 387 nullptr, nullptr)); |
| 389 this->drawBatch(pipelineBuilder, drawContext, GrNoClip(), batch); | 388 this->drawBatch(pipelineBuilder, drawContext, GrNoClip(), batch); |
| 390 } else { | 389 } else { |
| 391 GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRende
rTarget()); | 390 GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRende
rTarget()); |
| 392 this->recordBatch(batch); | 391 this->recordBatch(batch); |
| 393 batch->unref(); | 392 batch->unref(); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 523 } |
| 525 } | 524 } |
| 526 | 525 |
| 527 /////////////////////////////////////////////////////////////////////////////// | 526 /////////////////////////////////////////////////////////////////////////////// |
| 528 | 527 |
| 529 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 528 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 530 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 529 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 531 this->recordBatch(batch); | 530 this->recordBatch(batch); |
| 532 batch->unref(); | 531 batch->unref(); |
| 533 } | 532 } |
| OLD | NEW |