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 |
11 #include "GrCaps.h" | 11 #include "GrCaps.h" |
12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
13 #include "GrPath.h" | 13 #include "GrPath.h" |
14 #include "GrPipeline.h" | 14 #include "GrPipeline.h" |
15 #include "GrMemoryPool.h" | 15 #include "GrMemoryPool.h" |
16 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
17 #include "GrResourceProvider.h" | 17 #include "GrResourceProvider.h" |
18 #include "GrRenderTargetPriv.h" | 18 #include "GrRenderTargetPriv.h" |
19 #include "GrSurfacePriv.h" | 19 #include "GrSurfacePriv.h" |
20 #include "GrTexture.h" | 20 #include "GrTexture.h" |
21 #include "GrVertexBuffer.h" | 21 #include "GrVertexBuffer.h" |
22 | 22 |
| 23 #include "batches/GrClearBatch.h" |
| 24 #include "batches/GrDiscardBatch.h" |
23 #include "batches/GrDrawBatch.h" | 25 #include "batches/GrDrawBatch.h" |
24 #include "batches/GrRectBatchFactory.h" | 26 #include "batches/GrRectBatchFactory.h" |
25 | 27 |
26 #include "SkStrokeRec.h" | 28 #include "SkStrokeRec.h" |
27 | 29 |
28 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
29 | 31 |
30 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) | 32 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) |
31 : fGpu(SkRef(gpu)) | 33 : fGpu(SkRef(gpu)) |
32 , fCaps(SkRef(gpu->caps())) | 34 , fCaps(SkRef(gpu->caps())) |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // The driver will ignore a clear if it is the only thing rendered to a | 335 // The driver will ignore a clear if it is the only thing rendered to a |
334 // target before the target is read. | 336 // target before the target is read. |
335 if (rect == &rtRect) { | 337 if (rect == &rtRect) { |
336 this->discard(renderTarget); | 338 this->discard(renderTarget); |
337 } | 339 } |
338 | 340 |
339 GrPipelineBuilder pipelineBuilder; | 341 GrPipelineBuilder pipelineBuilder; |
340 pipelineBuilder.setRenderTarget(renderTarget); | 342 pipelineBuilder.setRenderTarget(renderTarget); |
341 | 343 |
342 this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect); | 344 this->drawSimpleRect(pipelineBuilder, color, SkMatrix::I(), *rect); |
343 } else { | 345 } else { |
344 this->onClear(*rect, color, renderTarget); | 346 GrBatch* batch = SkNEW_ARGS(GrClearBatch, (*rect, color, renderTarget)); |
| 347 this->onDrawBatch(batch); |
| 348 batch->unref(); |
345 } | 349 } |
346 } | 350 } |
347 | 351 |
| 352 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { |
| 353 if (this->caps()->discardRenderTargetSupport()) { |
| 354 GrBatch* batch = SkNEW_ARGS(GrDiscardBatch, (renderTarget)); |
| 355 this->onDrawBatch(batch); |
| 356 batch->unref(); |
| 357 } |
| 358 } |
| 359 |
348 typedef GrTraceMarkerSet::Iter TMIter; | 360 typedef GrTraceMarkerSet::Iter TMIter; |
349 void GrDrawTarget::saveActiveTraceMarkers() { | 361 void GrDrawTarget::saveActiveTraceMarkers() { |
350 if (this->caps()->gpuTracingSupport()) { | 362 if (this->caps()->gpuTracingSupport()) { |
351 SkASSERT(0 == fStoredTraceMarkers.count()); | 363 SkASSERT(0 == fStoredTraceMarkers.count()); |
352 fStoredTraceMarkers.addSet(fActiveTraceMarkers); | 364 fStoredTraceMarkers.addSet(fActiveTraceMarkers); |
353 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark
ers.end(); ++iter) { | 365 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark
ers.end(); ++iter) { |
354 this->removeGpuTraceMarker(&(*iter)); | 366 this->removeGpuTraceMarker(&(*iter)); |
355 } | 367 } |
356 } | 368 } |
357 } | 369 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 ars, | 525 ars, |
514 scissorState, | 526 scissorState, |
515 devBounds); | 527 devBounds); |
516 } | 528 } |
517 | 529 |
518 void GrClipTarget::purgeResources() { | 530 void GrClipTarget::purgeResources() { |
519 // The clip mask manager can rebuild all its clip masks so just | 531 // The clip mask manager can rebuild all its clip masks so just |
520 // get rid of them all. | 532 // get rid of them all. |
521 fClipMaskManager->purgeResources(); | 533 fClipMaskManager->purgeResources(); |
522 }; | 534 }; |
OLD | NEW |