| 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 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 } | 462 } |
| 463 | 463 |
| 464 if (this->caps()->useDrawInsteadOfClear()) { | 464 if (this->caps()->useDrawInsteadOfClear()) { |
| 465 // This works around a driver bug with clear by drawing a rect instead. | 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 | 466 // The driver will ignore a clear if it is the only thing rendered to a |
| 467 // target before the target is read. | 467 // target before the target is read. |
| 468 if (rect == &rtRect) { | 468 if (rect == &rtRect) { |
| 469 drawContext->discard(); | 469 drawContext->discard(); |
| 470 } | 470 } |
| 471 | 471 |
| 472 // TODO: flip this into real draw! | 472 SkRect scalarRect = SkRect::Make(*rect); |
| 473 GrPipelineBuilder pipelineBuilder; | |
| 474 pipelineBuilder.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSr
c_Mode)); | |
| 475 | 473 |
| 476 SkRect scalarRect = SkRect::Make(*rect); | 474 GrPaint paint; |
| 477 SkAutoTUnref<GrDrawBatch> batch( | 475 paint.setColor4f(GrColor4f::FromGrColor(color)); |
| 478 GrRectBatchFactory::CreateNonAAFill(color, SkMatrix::I(), scalar
Rect, | 476 paint.setXPFactory(GrPorterDuffXPFactory::Make(SkXfermode::kSrc_Mode)); |
| 479 nullptr, nullptr)); | 477 |
| 480 this->drawBatch(pipelineBuilder, drawContext, GrNoClip(), batch); | 478 drawContext->drawRect(GrNoClip(), paint, SkMatrix::I(), scalarRect); |
| 481 } else { | 479 } else { |
| 482 GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRende
rTarget()); | 480 GrBatch* batch = new GrClearBatch(*rect, color, drawContext->accessRende
rTarget()); |
| 483 this->recordBatch(batch, batch->bounds()); | 481 this->recordBatch(batch, batch->bounds()); |
| 484 batch->unref(); | 482 batch->unref(); |
| 485 } | 483 } |
| 486 } | 484 } |
| 487 | 485 |
| 488 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { | 486 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { |
| 489 if (this->caps()->discardRenderTargetSupport()) { | 487 if (this->caps()->discardRenderTargetSupport()) { |
| 490 GrBatch* batch = new GrDiscardBatch(renderTarget); | 488 GrBatch* batch = new GrDiscardBatch(renderTarget); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 } | 626 } |
| 629 } | 627 } |
| 630 | 628 |
| 631 /////////////////////////////////////////////////////////////////////////////// | 629 /////////////////////////////////////////////////////////////////////////////// |
| 632 | 630 |
| 633 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 631 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 634 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 632 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 635 this->recordBatch(batch, batch->bounds()); | 633 this->recordBatch(batch, batch->bounds()); |
| 636 batch->unref(); | 634 batch->unref(); |
| 637 } | 635 } |
| OLD | NEW |