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" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
12 #include "GrTextStrike.h" | 12 #include "GrTextStrike.h" |
13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
14 #include "GrIndexBuffer.h" | 14 #include "GrIndexBuffer.h" |
15 #include "GrPath.h" | 15 #include "GrPath.h" |
| 16 #include "GrPathRange.h" |
16 #include "GrRenderTarget.h" | 17 #include "GrRenderTarget.h" |
17 #include "GrTemplates.h" | 18 #include "GrTemplates.h" |
18 #include "GrTexture.h" | 19 #include "GrTexture.h" |
19 #include "GrVertexBuffer.h" | 20 #include "GrVertexBuffer.h" |
20 | 21 |
21 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, | 22 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, |
22 GrVertexBufferAllocPool* vertexPool, | 23 GrVertexBufferAllocPool* vertexPool, |
23 GrIndexBufferAllocPool* indexPool) | 24 GrIndexBufferAllocPool* indexPool) |
24 : GrDrawTarget(gpu->getContext()) | 25 : GrDrawTarget(gpu->getContext()) |
25 , fDstGpu(gpu) | 26 , fDstGpu(gpu) |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 } | 413 } |
413 } | 414 } |
414 | 415 |
415 GrInOrderDrawBuffer::StencilPath::StencilPath() {} | 416 GrInOrderDrawBuffer::StencilPath::StencilPath() {} |
416 GrInOrderDrawBuffer::DrawPath::DrawPath() {} | 417 GrInOrderDrawBuffer::DrawPath::DrawPath() {} |
417 GrInOrderDrawBuffer::DrawPaths::DrawPaths() {} | 418 GrInOrderDrawBuffer::DrawPaths::DrawPaths() {} |
418 GrInOrderDrawBuffer::DrawPaths::~DrawPaths() { | 419 GrInOrderDrawBuffer::DrawPaths::~DrawPaths() { |
419 if (fTransforms) { | 420 if (fTransforms) { |
420 SkDELETE_ARRAY(fTransforms); | 421 SkDELETE_ARRAY(fTransforms); |
421 } | 422 } |
422 for (int i = 0; i < fPathCount; ++i) { | 423 if (fIndices) { |
423 fPaths[i]->unref(); | 424 SkDELETE_ARRAY(fIndices); |
424 } | 425 } |
425 SkDELETE_ARRAY(fPaths); | |
426 } | 426 } |
427 | 427 |
428 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, SkPath::FillType fil
l) { | 428 void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, SkPath::FillType fil
l) { |
429 if (this->needsNewClip()) { | 429 if (this->needsNewClip()) { |
430 this->recordClip(); | 430 this->recordClip(); |
431 } | 431 } |
432 // Only compare the subset of GrDrawState relevant to path stenciling? | 432 // Only compare the subset of GrDrawState relevant to path stenciling? |
433 if (this->needsNewState()) { | 433 if (this->needsNewState()) { |
434 this->recordState(); | 434 this->recordState(); |
435 } | 435 } |
(...skipping 14 matching lines...) Expand all Loading... |
450 } | 450 } |
451 DrawPath* cp = this->recordDrawPath(); | 451 DrawPath* cp = this->recordDrawPath(); |
452 cp->fPath.reset(path); | 452 cp->fPath.reset(path); |
453 path->ref(); | 453 path->ref(); |
454 cp->fFill = fill; | 454 cp->fFill = fill; |
455 if (NULL != dstCopy) { | 455 if (NULL != dstCopy) { |
456 cp->fDstCopy = *dstCopy; | 456 cp->fDstCopy = *dstCopy; |
457 } | 457 } |
458 } | 458 } |
459 | 459 |
460 void GrInOrderDrawBuffer::onDrawPaths(int pathCount, const GrPath** paths, | 460 void GrInOrderDrawBuffer::onDrawPaths(const GrPathRange* pathRange, |
461 const SkMatrix* transforms, | 461 const uint32_t indices[], int count, |
462 SkPath::FillType fill, | 462 const float transforms[], PathTransformTyp
e transformsType, |
463 SkStrokeRec::Style stroke, | 463 SkPath::FillType fill, const GrDeviceCoord
Texture* dstCopy) { |
464 const GrDeviceCoordTexture* dstCopy) { | 464 SkASSERT(NULL != pathRange); |
465 SkASSERT(pathCount); | 465 SkASSERT(NULL != indices); |
| 466 SkASSERT(NULL != transforms); |
466 | 467 |
467 if (this->needsNewClip()) { | 468 if (this->needsNewClip()) { |
468 this->recordClip(); | 469 this->recordClip(); |
469 } | 470 } |
470 if (this->needsNewState()) { | 471 if (this->needsNewState()) { |
471 this->recordState(); | 472 this->recordState(); |
472 } | 473 } |
473 DrawPaths* dp = this->recordDrawPaths(); | 474 DrawPaths* dp = this->recordDrawPaths(); |
474 dp->fPathCount = pathCount; | 475 dp->fPathRange.reset(SkRef(pathRange)); |
475 dp->fPaths = SkNEW_ARRAY(const GrPath*, pathCount); | 476 dp->fIndices = SkNEW_ARRAY(uint32_t, count); // TODO: Accomplish this withou
t a malloc |
476 memcpy(dp->fPaths, paths, sizeof(GrPath*) * pathCount); | 477 memcpy(dp->fIndices, indices, sizeof(uint32_t) * count); |
477 for (int i = 0; i < pathCount; ++i) { | 478 dp->fCount = count; |
478 dp->fPaths[i]->ref(); | |
479 } | |
480 | 479 |
481 dp->fTransforms = SkNEW_ARRAY(SkMatrix, pathCount); | 480 const int transformsLength = PathTransformSize(transformsType) * count; |
482 memcpy(dp->fTransforms, transforms, sizeof(SkMatrix) * pathCount); | 481 dp->fTransforms = SkNEW_ARRAY(float, transformsLength); |
| 482 memcpy(dp->fTransforms, transforms, sizeof(float) * transformsLength); |
| 483 dp->fTransformsType = transformsType; |
483 | 484 |
484 dp->fFill = fill; | 485 dp->fFill = fill; |
485 dp->fStroke = stroke; | |
486 | 486 |
487 if (NULL != dstCopy) { | 487 if (NULL != dstCopy) { |
488 dp->fDstCopy = *dstCopy; | 488 dp->fDstCopy = *dstCopy; |
489 } | 489 } |
490 } | 490 } |
491 | 491 |
492 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, | 492 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, |
493 bool canIgnoreRect, GrRenderTarget* renderTarget
) { | 493 bool canIgnoreRect, GrRenderTarget* renderTarget
) { |
494 SkIRect r; | 494 SkIRect r; |
495 if (NULL == renderTarget) { | 495 if (NULL == renderTarget) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 NULL != drawPathIter->fDstCopy.texture(
) ? | 626 NULL != drawPathIter->fDstCopy.texture(
) ? |
627 &drawPathIter->fDstCopy : | 627 &drawPathIter->fDstCopy : |
628 NULL); | 628 NULL); |
629 break; | 629 break; |
630 } | 630 } |
631 case kDrawPaths_Cmd: { | 631 case kDrawPaths_Cmd: { |
632 SkASSERT(fDstGpu->drawState() != prevDrawState); | 632 SkASSERT(fDstGpu->drawState() != prevDrawState); |
633 SkAssertResult(drawPathsIter.next()); | 633 SkAssertResult(drawPathsIter.next()); |
634 const GrDeviceCoordTexture* dstCopy = | 634 const GrDeviceCoordTexture* dstCopy = |
635 NULL !=drawPathsIter->fDstCopy.texture() ? &drawPathsIter->f
DstCopy : NULL; | 635 NULL !=drawPathsIter->fDstCopy.texture() ? &drawPathsIter->f
DstCopy : NULL; |
636 fDstGpu->executeDrawPaths(drawPathsIter->fPathCount, drawPathsIt
er->fPaths, | 636 fDstGpu->executeDrawPaths(drawPathsIter->fPathRange.get(), |
637 drawPathsIter->fTransforms, drawPathsI
ter->fFill, | 637 drawPathsIter->fIndices, |
638 drawPathsIter->fStroke, dstCopy); | 638 drawPathsIter->fCount, |
| 639 drawPathsIter->fTransforms, |
| 640 drawPathsIter->fTransformsType, |
| 641 drawPathsIter->fFill, |
| 642 dstCopy); |
639 break; | 643 break; |
640 } | 644 } |
641 case kSetState_Cmd: | 645 case kSetState_Cmd: |
642 SkAssertResult(stateIter.next()); | 646 SkAssertResult(stateIter.next()); |
643 fDstGpu->setDrawState(stateIter.get()); | 647 fDstGpu->setDrawState(stateIter.get()); |
644 break; | 648 break; |
645 case kSetClip_Cmd: | 649 case kSetClip_Cmd: |
646 SkAssertResult(clipIter.next()); | 650 SkAssertResult(clipIter.next()); |
647 clipData.fClipStack = &clipIter->fStack; | 651 clipData.fClipStack = &clipIter->fStack; |
648 clipData.fOrigin = clipIter->fOrigin; | 652 clipData.fOrigin = clipIter->fOrigin; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { | 992 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { |
989 this->addToCmdBuffer(kCopySurface_Cmd); | 993 this->addToCmdBuffer(kCopySurface_Cmd); |
990 return &fCopySurfaces.push_back(); | 994 return &fCopySurfaces.push_back(); |
991 } | 995 } |
992 | 996 |
993 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { | 997 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { |
994 INHERITED::clipWillBeSet(newClipData); | 998 INHERITED::clipWillBeSet(newClipData); |
995 fClipSet = true; | 999 fClipSet = true; |
996 fClipProxyState = kUnknown_ClipProxyState; | 1000 fClipProxyState = kUnknown_ClipProxyState; |
997 } | 1001 } |
OLD | NEW |