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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 default: | 378 default: |
379 GrCrash("unknown geom src type"); | 379 GrCrash("unknown geom src type"); |
380 } | 380 } |
381 draw->fIndexBuffer->ref(); | 381 draw->fIndexBuffer->ref(); |
382 } else { | 382 } else { |
383 draw->fIndexBuffer = NULL; | 383 draw->fIndexBuffer = NULL; |
384 } | 384 } |
385 } | 385 } |
386 | 386 |
387 GrInOrderDrawBuffer::StencilPath::StencilPath() : fStroke(SkStrokeRec::kFill_Ini
tStyle) {} | 387 GrInOrderDrawBuffer::StencilPath::StencilPath() : fStroke(SkStrokeRec::kFill_Ini
tStyle) {} |
388 GrInOrderDrawBuffer::FillPath::FillPath() : fStroke(SkStrokeRec::kFill_InitStyle
) {} | 388 GrInOrderDrawBuffer::DrawPath::DrawPath() : fStroke(SkStrokeRec::kFill_InitStyle
) {} |
389 | 389 |
390 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, const SkStrokeRec& s
troke, | 390 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, const SkStrokeRec& s
troke, |
391 SkPath::FillType fill) { | 391 SkPath::FillType fill) { |
392 if (this->needsNewClip()) { | 392 if (this->needsNewClip()) { |
393 this->recordClip(); | 393 this->recordClip(); |
394 } | 394 } |
395 // Only compare the subset of GrDrawState relevant to path stenciling? | 395 // Only compare the subset of GrDrawState relevant to path stenciling? |
396 if (this->needsNewState()) { | 396 if (this->needsNewState()) { |
397 this->recordState(); | 397 this->recordState(); |
398 } | 398 } |
399 StencilPath* sp = this->recordStencilPath(); | 399 StencilPath* sp = this->recordStencilPath(); |
400 sp->fPath.reset(path); | 400 sp->fPath.reset(path); |
401 path->ref(); | 401 path->ref(); |
402 sp->fFill = fill; | 402 sp->fFill = fill; |
403 sp->fStroke = stroke; | 403 sp->fStroke = stroke; |
404 } | 404 } |
405 | 405 |
406 void GrInOrderDrawBuffer::onFillPath(const GrPath* path, const SkStrokeRec& stro
ke, | 406 void GrInOrderDrawBuffer::onDrawPath(const GrPath* path, const SkStrokeRec& stro
ke, |
407 SkPath::FillType fill) { | 407 SkPath::FillType fill) { |
408 if (this->needsNewClip()) { | 408 if (this->needsNewClip()) { |
409 this->recordClip(); | 409 this->recordClip(); |
410 } | 410 } |
411 // TODO: Only compare the subset of GrDrawState relevant to path covering? | 411 // TODO: Only compare the subset of GrDrawState relevant to path covering? |
412 if (this->needsNewState()) { | 412 if (this->needsNewState()) { |
413 this->recordState(); | 413 this->recordState(); |
414 } | 414 } |
415 FillPath* cp = this->recordFillPath(); | 415 DrawPath* cp = this->recordDrawPath(); |
416 cp->fPath.reset(path); | 416 cp->fPath.reset(path); |
417 path->ref(); | 417 path->ref(); |
418 cp->fFill = fill; | 418 cp->fFill = fill; |
419 cp->fStroke = stroke; | 419 cp->fStroke = stroke; |
420 } | 420 } |
421 | 421 |
422 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg
et* renderTarget) { | 422 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, GrRenderTarg
et* renderTarget) { |
423 SkIRect r; | 423 SkIRect r; |
424 if (NULL == renderTarget) { | 424 if (NULL == renderTarget) { |
425 renderTarget = this->drawState()->getRenderTarget(); | 425 renderTarget = this->drawState()->getRenderTarget(); |
(...skipping 20 matching lines...) Expand all Loading... |
446 int numDraws = fDraws.count(); | 446 int numDraws = fDraws.count(); |
447 for (int d = 0; d < numDraws; ++d) { | 447 for (int d = 0; d < numDraws; ++d) { |
448 // we always have a VB, but not always an IB | 448 // we always have a VB, but not always an IB |
449 SkASSERT(NULL != fDraws[d].fVertexBuffer); | 449 SkASSERT(NULL != fDraws[d].fVertexBuffer); |
450 fDraws[d].fVertexBuffer->unref(); | 450 fDraws[d].fVertexBuffer->unref(); |
451 SkSafeUnref(fDraws[d].fIndexBuffer); | 451 SkSafeUnref(fDraws[d].fIndexBuffer); |
452 } | 452 } |
453 fCmds.reset(); | 453 fCmds.reset(); |
454 fDraws.reset(); | 454 fDraws.reset(); |
455 fStencilPaths.reset(); | 455 fStencilPaths.reset(); |
456 fFillPaths.reset(); | 456 fDrawPaths.reset(); |
457 fStates.reset(); | 457 fStates.reset(); |
458 fClears.reset(); | 458 fClears.reset(); |
459 fVertexPool.reset(); | 459 fVertexPool.reset(); |
460 fIndexPool.reset(); | 460 fIndexPool.reset(); |
461 fClips.reset(); | 461 fClips.reset(); |
462 fClipOrigins.reset(); | 462 fClipOrigins.reset(); |
463 fCopySurfaces.reset(); | 463 fCopySurfaces.reset(); |
464 fClipSet = true; | 464 fClipSet = true; |
465 } | 465 } |
466 | 466 |
(...skipping 24 matching lines...) Expand all Loading... |
491 prevDrawState->ref(); | 491 prevDrawState->ref(); |
492 fDstGpu->setDrawState(&playbackState); | 492 fDstGpu->setDrawState(&playbackState); |
493 | 493 |
494 GrClipData clipData; | 494 GrClipData clipData; |
495 | 495 |
496 int currState = 0; | 496 int currState = 0; |
497 int currClip = 0; | 497 int currClip = 0; |
498 int currClear = 0; | 498 int currClear = 0; |
499 int currDraw = 0; | 499 int currDraw = 0; |
500 int currStencilPath = 0; | 500 int currStencilPath = 0; |
501 int currFillPath = 0; | 501 int currDrawPath = 0; |
502 int currCopySurface = 0; | 502 int currCopySurface = 0; |
503 | 503 |
504 for (int c = 0; c < numCmds; ++c) { | 504 for (int c = 0; c < numCmds; ++c) { |
505 switch (fCmds[c]) { | 505 switch (fCmds[c]) { |
506 case kDraw_Cmd: { | 506 case kDraw_Cmd: { |
507 const DrawRecord& draw = fDraws[currDraw]; | 507 const DrawRecord& draw = fDraws[currDraw]; |
508 fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer); | 508 fDstGpu->setVertexSourceToBuffer(draw.fVertexBuffer); |
509 if (draw.isIndexed()) { | 509 if (draw.isIndexed()) { |
510 fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer); | 510 fDstGpu->setIndexSourceToBuffer(draw.fIndexBuffer); |
511 } | 511 } |
512 fDstGpu->executeDraw(draw); | 512 fDstGpu->executeDraw(draw); |
513 | 513 |
514 ++currDraw; | 514 ++currDraw; |
515 break; | 515 break; |
516 } | 516 } |
517 case kStencilPath_Cmd: { | 517 case kStencilPath_Cmd: { |
518 const StencilPath& sp = fStencilPaths[currStencilPath]; | 518 const StencilPath& sp = fStencilPaths[currStencilPath]; |
519 fDstGpu->stencilPath(sp.fPath.get(), sp.fStroke, sp.fFill); | 519 fDstGpu->stencilPath(sp.fPath.get(), sp.fStroke, sp.fFill); |
520 ++currStencilPath; | 520 ++currStencilPath; |
521 break; | 521 break; |
522 } | 522 } |
523 case kFillPath_Cmd: { | 523 case kDrawPath_Cmd: { |
524 const FillPath& cp = fFillPaths[currFillPath]; | 524 const DrawPath& cp = fDrawPaths[currDrawPath]; |
525 fDstGpu->fillPath(cp.fPath.get(), cp.fStroke, cp.fFill); | 525 fDstGpu->drawPath(cp.fPath.get(), cp.fStroke, cp.fFill); |
526 ++currFillPath; | 526 ++currDrawPath; |
527 break; | 527 break; |
528 } | 528 } |
529 case kSetState_Cmd: | 529 case kSetState_Cmd: |
530 fStates[currState].restoreTo(&playbackState); | 530 fStates[currState].restoreTo(&playbackState); |
531 ++currState; | 531 ++currState; |
532 break; | 532 break; |
533 case kSetClip_Cmd: | 533 case kSetClip_Cmd: |
534 clipData.fClipStack = &fClips[currClip]; | 534 clipData.fClipStack = &fClips[currClip]; |
535 clipData.fOrigin = fClipOrigins[currClip]; | 535 clipData.fOrigin = fClipOrigins[currClip]; |
536 fDstGpu->setClip(&clipData); | 536 fDstGpu->setClip(&clipData); |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo&
info) { | 829 GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo&
info) { |
830 fCmds.push_back(kDraw_Cmd); | 830 fCmds.push_back(kDraw_Cmd); |
831 return &fDraws.push_back(info); | 831 return &fDraws.push_back(info); |
832 } | 832 } |
833 | 833 |
834 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() { | 834 GrInOrderDrawBuffer::StencilPath* GrInOrderDrawBuffer::recordStencilPath() { |
835 fCmds.push_back(kStencilPath_Cmd); | 835 fCmds.push_back(kStencilPath_Cmd); |
836 return &fStencilPaths.push_back(); | 836 return &fStencilPaths.push_back(); |
837 } | 837 } |
838 | 838 |
839 GrInOrderDrawBuffer::FillPath* GrInOrderDrawBuffer::recordFillPath() { | 839 GrInOrderDrawBuffer::DrawPath* GrInOrderDrawBuffer::recordDrawPath() { |
840 fCmds.push_back(kFillPath_Cmd); | 840 fCmds.push_back(kDrawPath_Cmd); |
841 return &fFillPaths.push_back(); | 841 return &fDrawPaths.push_back(); |
842 } | 842 } |
843 | 843 |
844 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() { | 844 GrInOrderDrawBuffer::Clear* GrInOrderDrawBuffer::recordClear() { |
845 fCmds.push_back(kClear_Cmd); | 845 fCmds.push_back(kClear_Cmd); |
846 return &fClears.push_back(); | 846 return &fClears.push_back(); |
847 } | 847 } |
848 | 848 |
849 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { | 849 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { |
850 fCmds.push_back(kCopySurface_Cmd); | 850 fCmds.push_back(kCopySurface_Cmd); |
851 return &fCopySurfaces.push_back(); | 851 return &fCopySurfaces.push_back(); |
852 } | 852 } |
853 | 853 |
854 | 854 |
855 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { | 855 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { |
856 INHERITED::clipWillBeSet(newClipData); | 856 INHERITED::clipWillBeSet(newClipData); |
857 fClipSet = true; | 857 fClipSet = true; |
858 fClipProxyState = kUnknown_ClipProxyState; | 858 fClipProxyState = kUnknown_ClipProxyState; |
859 } | 859 } |
OLD | NEW |