| 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" |
| 11 #include "GrCaps.h" | 11 #include "GrCaps.h" |
| 12 #include "GrDrawContext.h" | 12 #include "GrDrawContext.h" |
| 13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 14 #include "GrGpuCommandBuffer.h" | 14 #include "GrGpuCommandBuffer.h" |
| 15 #include "GrPath.h" | 15 #include "GrPath.h" |
| 16 #include "GrPipeline.h" | 16 #include "GrPipeline.h" |
| 17 #include "GrMemoryPool.h" | 17 #include "GrMemoryPool.h" |
| 18 #include "GrRenderTarget.h" | 18 #include "GrRenderTarget.h" |
| 19 #include "GrResourceProvider.h" | 19 #include "GrResourceProvider.h" |
| 20 #include "GrRenderTargetPriv.h" | 20 #include "GrRenderTargetPriv.h" |
| 21 #include "GrStencilAttachment.h" | 21 #include "GrStencilAttachment.h" |
| 22 #include "GrSurfacePriv.h" | 22 #include "GrSurfacePriv.h" |
| 23 #include "GrTexture.h" | 23 #include "GrTexture.h" |
| 24 #include "gl/GrGLRenderTarget.h" | 24 #include "gl/GrGLRenderTarget.h" |
| 25 | 25 |
| 26 #include "SkStrokeRec.h" | 26 #include "SkStrokeRec.h" |
| 27 | 27 |
| 28 #include "batches/GrClearBatch.h" | 28 #include "batches/GrClearStencilClipBatch.h" |
| 29 #include "batches/GrCopySurfaceBatch.h" | 29 #include "batches/GrCopySurfaceBatch.h" |
| 30 #include "batches/GrDiscardBatch.h" | 30 #include "batches/GrDiscardBatch.h" |
| 31 #include "batches/GrDrawBatch.h" | 31 #include "batches/GrDrawBatch.h" |
| 32 #include "batches/GrDrawPathBatch.h" | 32 #include "batches/GrDrawPathBatch.h" |
| 33 #include "batches/GrRectBatchFactory.h" | 33 #include "batches/GrRectBatchFactory.h" |
| 34 #include "batches/GrStencilPathBatch.h" | 34 #include "batches/GrStencilPathBatch.h" |
| 35 | 35 |
| 36 #include "instanced/InstancedRendering.h" | 36 #include "instanced/InstancedRendering.h" |
| 37 | 37 |
| 38 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 fill, | 436 fill, |
| 437 appliedClip.hasStencilClip(), | 437 appliedClip.hasStencilClip(), |
| 438 stencilAttachment->bits(), | 438 stencilAttachment->bits(), |
| 439 appliedClip.scissorState(), | 439 appliedClip.scissorState(), |
| 440 drawContext->accessRenderTarget(
), | 440 drawContext->accessRenderTarget(
), |
| 441 path); | 441 path); |
| 442 this->recordBatch(batch, appliedClip.deviceBounds()); | 442 this->recordBatch(batch, appliedClip.deviceBounds()); |
| 443 batch->unref(); | 443 batch->unref(); |
| 444 } | 444 } |
| 445 | 445 |
| 446 void GrDrawTarget::clear(const SkIRect* rect, | 446 void GrDrawTarget::addBatch(sk_sp<GrBatch> batch) { |
| 447 GrColor color, | 447 this->recordBatch(batch.get(), batch->bounds()); |
| 448 bool canIgnoreRect, | |
| 449 GrDrawContext* drawContext) { | |
| 450 SkIRect rtRect = SkIRect::MakeWH(drawContext->width(), drawContext->height()
); | |
| 451 SkIRect clippedRect; | |
| 452 if (!rect || | |
| 453 (canIgnoreRect && this->caps()->fullClearIsFree()) || | |
| 454 rect->contains(rtRect)) { | |
| 455 rect = &rtRect; | |
| 456 } else { | |
| 457 clippedRect = *rect; | |
| 458 if (!clippedRect.intersect(rtRect)) { | |
| 459 return; | |
| 460 } | |
| 461 rect = &clippedRect; | |
| 462 } | |
| 463 | |
| 464 if (this->caps()->useDrawInsteadOfClear()) { | |
| 465 // This works around a driver bug with clear by drawing a rect instead. | |
| 466 // The driver will ignore a clear if it is the only thing rendered to a | |
| 467 // target before the target is read. | |
| 468 if (rect == &rtRect) { | |
| 469 drawContext->discard(); | |
| 470 } | |
| 471 | |
| 472 SkRect scalarRect = SkRect::Make(*rect); | |
| 473 | |
| 474 GrPaint paint; | |
| 475 paint.setColor4f(GrColor4f::FromGrColor(color)); | |
| 476 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); | |
| 477 | |
| 478 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), scalarRect); | |
| 479 } else { | |
| 480 GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRende
rTarget()); | |
| 481 this->recordBatch(batch, batch->bounds()); | |
| 482 batch->unref(); | |
| 483 } | |
| 484 } | 448 } |
| 485 | 449 |
| 486 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { | 450 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { |
| 487 if (this->caps()->discardRenderTargetSupport()) { | 451 if (this->caps()->discardRenderTargetSupport()) { |
| 488 GrBatch* batch = new GrDiscardBatch(renderTarget); | 452 GrBatch* batch = new GrDiscardBatch(renderTarget); |
| 489 this->recordBatch(batch, batch->bounds()); | 453 this->recordBatch(batch, batch->bounds()); |
| 490 batch->unref(); | 454 batch->unref(); |
| 491 } | 455 } |
| 492 } | 456 } |
| 493 | 457 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 626 } | 590 } |
| 627 } | 591 } |
| 628 | 592 |
| 629 /////////////////////////////////////////////////////////////////////////////// | 593 /////////////////////////////////////////////////////////////////////////////// |
| 630 | 594 |
| 631 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 595 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 632 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 596 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 633 this->recordBatch(batch, batch->bounds()); | 597 this->recordBatch(batch, batch->bounds()); |
| 634 batch->unref(); | 598 batch->unref(); |
| 635 } | 599 } |
| OLD | NEW |