| 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 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #include "batches/GrStencilPathBatch.h" | 29 #include "batches/GrStencilPathBatch.h" |
| 30 | 30 |
| 31 #include "SkStrokeRec.h" | 31 #include "SkStrokeRec.h" |
| 32 | 32 |
| 33 //////////////////////////////////////////////////////////////////////////////// | 33 //////////////////////////////////////////////////////////////////////////////// |
| 34 | 34 |
| 35 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) | 35 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) |
| 36 : fGpu(SkRef(gpu)) | 36 : fGpu(SkRef(gpu)) |
| 37 , fCaps(SkRef(gpu->caps())) | 37 , fCaps(SkRef(gpu->caps())) |
| 38 , fResourceProvider(resourceProvider) | 38 , fResourceProvider(resourceProvider) |
| 39 , fGpuTraceMarkerCount(0) | |
| 40 , fFlushing(false) { | 39 , fFlushing(false) { |
| 41 } | 40 } |
| 42 | 41 |
| 43 GrDrawTarget::~GrDrawTarget() { | 42 GrDrawTarget::~GrDrawTarget() { |
| 44 fGpu->unref(); | 43 fGpu->unref(); |
| 45 fCaps->unref(); | 44 fCaps->unref(); |
| 46 } | 45 } |
| 47 | 46 |
| 48 //////////////////////////////////////////////////////////////////////////////// | 47 //////////////////////////////////////////////////////////////////////////////// |
| 49 | 48 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); | 112 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); |
| 114 return true; | 113 return true; |
| 115 } | 114 } |
| 116 | 115 |
| 117 void GrDrawTarget::flush() { | 116 void GrDrawTarget::flush() { |
| 118 if (fFlushing) { | 117 if (fFlushing) { |
| 119 return; | 118 return; |
| 120 } | 119 } |
| 121 fFlushing = true; | 120 fFlushing = true; |
| 122 | 121 |
| 123 this->getGpu()->saveActiveTraceMarkers(); | |
| 124 | |
| 125 this->onFlush(); | 122 this->onFlush(); |
| 126 | 123 |
| 127 this->getGpu()->restoreActiveTraceMarkers(); | |
| 128 | |
| 129 fFlushing = false; | 124 fFlushing = false; |
| 130 this->reset(); | 125 this->reset(); |
| 131 } | 126 } |
| 132 | 127 |
| 133 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { | 128 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat
ch* batch) { |
| 134 // Setup clip | 129 // Setup clip |
| 135 GrScissorState scissorState; | 130 GrScissorState scissorState; |
| 136 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; | 131 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; |
| 137 GrPipelineBuilder::AutoRestoreStencil ars; | 132 GrPipelineBuilder::AutoRestoreStencil ars; |
| 138 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b
ounds())) { | 133 if (!this->setupClip(pipelineBuilder, &arfps, &ars, &scissorState, &batch->b
ounds())) { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 } | 382 } |
| 388 | 383 |
| 389 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { | 384 void GrDrawTarget::discard(GrRenderTarget* renderTarget) { |
| 390 if (this->caps()->discardRenderTargetSupport()) { | 385 if (this->caps()->discardRenderTargetSupport()) { |
| 391 GrBatch* batch = new GrDiscardBatch(renderTarget); | 386 GrBatch* batch = new GrDiscardBatch(renderTarget); |
| 392 this->onDrawBatch(batch); | 387 this->onDrawBatch(batch); |
| 393 batch->unref(); | 388 batch->unref(); |
| 394 } | 389 } |
| 395 } | 390 } |
| 396 | 391 |
| 397 typedef GrTraceMarkerSet::Iter TMIter; | |
| 398 void GrDrawTarget::saveActiveTraceMarkers() { | |
| 399 if (this->caps()->gpuTracingSupport()) { | |
| 400 SkASSERT(0 == fStoredTraceMarkers.count()); | |
| 401 fStoredTraceMarkers.addSet(fActiveTraceMarkers); | |
| 402 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark
ers.end(); ++iter) { | |
| 403 this->removeGpuTraceMarker(&(*iter)); | |
| 404 } | |
| 405 } | |
| 406 } | |
| 407 | |
| 408 void GrDrawTarget::restoreActiveTraceMarkers() { | |
| 409 if (this->caps()->gpuTracingSupport()) { | |
| 410 SkASSERT(0 == fActiveTraceMarkers.count()); | |
| 411 for (TMIter iter = fStoredTraceMarkers.begin(); iter != fStoredTraceMark
ers.end(); ++iter) { | |
| 412 this->addGpuTraceMarker(&(*iter)); | |
| 413 } | |
| 414 for (TMIter iter = fActiveTraceMarkers.begin(); iter != fActiveTraceMark
ers.end(); ++iter) { | |
| 415 this->fStoredTraceMarkers.remove(*iter); | |
| 416 } | |
| 417 } | |
| 418 } | |
| 419 | |
| 420 void GrDrawTarget::addGpuTraceMarker(const GrGpuTraceMarker* marker) { | |
| 421 if (this->caps()->gpuTracingSupport()) { | |
| 422 SkASSERT(fGpuTraceMarkerCount >= 0); | |
| 423 this->fActiveTraceMarkers.add(*marker); | |
| 424 ++fGpuTraceMarkerCount; | |
| 425 } | |
| 426 } | |
| 427 | |
| 428 void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) { | |
| 429 if (this->caps()->gpuTracingSupport()) { | |
| 430 SkASSERT(fGpuTraceMarkerCount >= 1); | |
| 431 this->fActiveTraceMarkers.remove(*marker); | |
| 432 --fGpuTraceMarkerCount; | |
| 433 } | |
| 434 } | |
| 435 | |
| 436 //////////////////////////////////////////////////////////////////////////////// | 392 //////////////////////////////////////////////////////////////////////////////// |
| 437 | 393 |
| 438 void GrDrawTarget::copySurface(GrSurface* dst, | 394 void GrDrawTarget::copySurface(GrSurface* dst, |
| 439 GrSurface* src, | 395 GrSurface* src, |
| 440 const SkIRect& srcRect, | 396 const SkIRect& srcRect, |
| 441 const SkIPoint& dstPoint) { | 397 const SkIPoint& dstPoint) { |
| 442 GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint); | 398 GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint); |
| 443 if (batch) { | 399 if (batch) { |
| 444 this->onDrawBatch(batch); | 400 this->onDrawBatch(batch); |
| 445 batch->unref(); | 401 batch->unref(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 // The clip mask manager can rebuild all its clip masks so just | 460 // The clip mask manager can rebuild all its clip masks so just |
| 505 // get rid of them all. | 461 // get rid of them all. |
| 506 fClipMaskManager->purgeResources(); | 462 fClipMaskManager->purgeResources(); |
| 507 }; | 463 }; |
| 508 | 464 |
| 509 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 465 void GrClipTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 510 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 466 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 511 this->onDrawBatch(batch); | 467 this->onDrawBatch(batch); |
| 512 batch->unref(); | 468 batch->unref(); |
| 513 } | 469 } |
| OLD | NEW |