OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" | 8 #include "GrInOrderDrawBuffer.h" |
9 | 9 |
10 #include "GrBufferAllocPool.h" | 10 #include "GrBufferAllocPool.h" |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 fGpuCmdMarkers.push_back(this->getActiveTraceMarkers()); | 248 fGpuCmdMarkers.push_back(this->getActiveTraceMarkers()); |
249 draw->fType = add_trace_bit(draw->fType); | 249 draw->fType = add_trace_bit(draw->fType); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 return instancesToConcat; | 253 return instancesToConcat; |
254 } | 254 } |
255 | 255 |
256 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, | 256 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, |
257 const DrawInfo& info, | 257 const DrawInfo& info, |
258 const ScissorState& scissorState) { | 258 const ScissorState& scissorState, |
| 259 const GrDeviceCoordTexture* dstCopy) { |
259 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); | 260 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); |
260 | 261 |
261 GeometryPoolState& poolState = fGeoPoolStateStack.back(); | 262 GeometryPoolState& poolState = fGeoPoolStateStack.back(); |
262 | 263 |
263 if (!this->recordStateAndShouldDraw(ds, GrGpu::PrimTypeToDrawType(info.primi
tiveType()), | 264 if (!this->recordStateAndShouldDraw(ds, GrGpu::PrimTypeToDrawType(info.primi
tiveType()), |
264 scissorState, info.getDstCopy())) { | 265 scissorState, dstCopy)) { |
265 return; | 266 return; |
266 } | 267 } |
267 | 268 |
268 Draw* draw; | 269 Draw* draw; |
269 if (info.isInstanced()) { | 270 if (info.isInstanced()) { |
270 int instancesConcated = this->concatInstancedDraw(ds, info); | 271 int instancesConcated = this->concatInstancedDraw(ds, info); |
271 if (info.instanceCount() > instancesConcated) { | 272 if (info.instanceCount() > instancesConcated) { |
272 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 273 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
273 draw->fInfo.adjustInstanceCount(-instancesConcated); | 274 draw->fInfo.adjustInstanceCount(-instancesConcated); |
274 } else { | 275 } else { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, | 311 void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, |
311 const GrPath* path, | 312 const GrPath* path, |
312 const GrClipMaskManager::ScissorState& scis
sorState, | 313 const GrClipMaskManager::ScissorState& scis
sorState, |
313 const GrStencilSettings& stencilSettings, | 314 const GrStencilSettings& stencilSettings, |
314 const GrDeviceCoordTexture* dstCopy) { | 315 const GrDeviceCoordTexture* dstCopy) { |
315 // TODO: Only compare the subset of GrDrawState relevant to path covering? | 316 // TODO: Only compare the subset of GrDrawState relevant to path covering? |
316 if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorSt
ate, dstCopy)) { | 317 if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, scissorSt
ate, dstCopy)) { |
317 return; | 318 return; |
318 } | 319 } |
319 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); | 320 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
320 if (dstCopy) { | |
321 dp->fDstCopy = *dstCopy; | |
322 } | |
323 dp->fStencilSettings = stencilSettings; | 321 dp->fStencilSettings = stencilSettings; |
324 this->recordTraceMarkersIfNecessary(); | 322 this->recordTraceMarkersIfNecessary(); |
325 } | 323 } |
326 | 324 |
327 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, | 325 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, |
328 const GrPathRange* pathRange, | 326 const GrPathRange* pathRange, |
329 const uint32_t indices[], | 327 const uint32_t indices[], |
330 int count, | 328 int count, |
331 const float transforms[], | 329 const float transforms[], |
332 PathTransformType transformsType, | 330 PathTransformType transformsType, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 return; | 362 return; |
365 } | 363 } |
366 } | 364 } |
367 | 365 |
368 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange))
; | 366 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange))
; |
369 dp->fIndicesLocation = savedIndices - fPathIndexBuffer.begin(); | 367 dp->fIndicesLocation = savedIndices - fPathIndexBuffer.begin(); |
370 dp->fCount = count; | 368 dp->fCount = count; |
371 dp->fTransformsLocation = savedTransforms - fPathTransformBuffer.begin(); | 369 dp->fTransformsLocation = savedTransforms - fPathTransformBuffer.begin(); |
372 dp->fTransformsType = transformsType; | 370 dp->fTransformsType = transformsType; |
373 dp->fStencilSettings = stencilSettings; | 371 dp->fStencilSettings = stencilSettings; |
374 if (dstCopy) { | |
375 dp->fDstCopy = *dstCopy; | |
376 } | |
377 | 372 |
378 this->recordTraceMarkersIfNecessary(); | 373 this->recordTraceMarkersIfNecessary(); |
379 } | 374 } |
380 | 375 |
381 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, | 376 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, |
382 bool canIgnoreRect, GrRenderTarget* renderTarg
et) { | 377 bool canIgnoreRect, GrRenderTarget* renderTarg
et) { |
383 SkASSERT(renderTarget); | 378 SkASSERT(renderTarget); |
384 SkIRect r; | 379 SkIRect r; |
385 if (NULL == rect) { | 380 if (NULL == rect) { |
386 // We could do something smart and remove previous draws and clears to | 381 // We could do something smart and remove previous draws and clears to |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 buf->fDstGpu->draw(*optState, fInfo); | 505 buf->fDstGpu->draw(*optState, fInfo); |
511 } | 506 } |
512 | 507 |
513 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, | 508 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, |
514 const GrOptDrawState* optState) { | 509 const GrOptDrawState* optState) { |
515 buf->fDstGpu->stencilPath(*optState, this->path(), fStencilSettings); | 510 buf->fDstGpu->stencilPath(*optState, this->path(), fStencilSettings); |
516 } | 511 } |
517 | 512 |
518 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, | 513 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, |
519 const GrOptDrawState* optState) { | 514 const GrOptDrawState* optState) { |
520 buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings, | 515 buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings); |
521 fDstCopy.texture() ? &fDstCopy : NULL); | |
522 } | 516 } |
523 | 517 |
524 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, | 518 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, |
525 const GrOptDrawState* optState) { | 519 const GrOptDrawState* optState) { |
526 buf->fDstGpu->drawPaths(*optState, this->pathRange(), | 520 buf->fDstGpu->drawPaths(*optState, this->pathRange(), |
527 &buf->fPathIndexBuffer[fIndicesLocation], fCount, | 521 &buf->fPathIndexBuffer[fIndicesLocation], fCount, |
528 &buf->fPathTransformBuffer[fTransformsLocation], fTr
ansformsType, | 522 &buf->fPathTransformBuffer[fTransformsLocation], fTr
ansformsType, |
529 fStencilSettings, fDstCopy.texture() ? &fDstCopy : N
ULL); | 523 fStencilSettings); |
530 } | 524 } |
531 | 525 |
532 void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDra
wState*) { | 526 void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDra
wState*) { |
533 } | 527 } |
534 | 528 |
535 void GrInOrderDrawBuffer::Clear::execute(GrInOrderDrawBuffer* buf, const GrOptDr
awState*) { | 529 void GrInOrderDrawBuffer::Clear::execute(GrInOrderDrawBuffer* buf, const GrOptDr
awState*) { |
536 if (GrColor_ILLEGAL == fColor) { | 530 if (GrColor_ILLEGAL == fColor) { |
537 buf->fDstGpu->discard(this->renderTarget()); | 531 buf->fDstGpu->discard(this->renderTarget()); |
538 } else { | 532 } else { |
539 buf->fDstGpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget()
); | 533 buf->fDstGpu->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget()
); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 const GrClipMaskManager::Scis
sorState& scissor, | 728 const GrClipMaskManager::Scis
sorState& scissor, |
735 const GrDeviceCoordTexture* d
stCopy) { | 729 const GrDeviceCoordTexture* d
stCopy) { |
736 SkAutoTUnref<GrOptDrawState> optState(GrOptDrawState::Create(ds, fDstGpu, sc
issor, dstCopy, | 730 SkAutoTUnref<GrOptDrawState> optState(GrOptDrawState::Create(ds, fDstGpu, sc
issor, dstCopy, |
737 drawType)); | 731 drawType)); |
738 if (!optState) { | 732 if (!optState) { |
739 return false; | 733 return false; |
740 } | 734 } |
741 if (!fLastState || *optState != *fLastState) { | 735 if (!fLastState || *optState != *fLastState) { |
742 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (optState)
); | 736 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (optState)
); |
743 fLastState.reset(SkRef(optState.get())); | 737 fLastState.reset(SkRef(optState.get())); |
744 if (dstCopy) { | |
745 ss->fDstCopy = *dstCopy; | |
746 } | |
747 ss->fDrawType = drawType; | 738 ss->fDrawType = drawType; |
748 this->recordTraceMarkersIfNecessary(); | 739 this->recordTraceMarkersIfNecessary(); |
749 } | 740 } |
750 return true; | 741 return true; |
751 } | 742 } |
752 | 743 |
753 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 744 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { |
754 SkASSERT(!fCmdBuffer.empty()); | 745 SkASSERT(!fCmdBuffer.empty()); |
755 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); | 746 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); |
756 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 747 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
757 if (activeTraceMarkers.count() > 0) { | 748 if (activeTraceMarkers.count() > 0) { |
758 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 749 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
759 fGpuCmdMarkers.push_back(activeTraceMarkers); | 750 fGpuCmdMarkers.push_back(activeTraceMarkers); |
760 } | 751 } |
761 } | 752 } |
OLD | NEW |