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