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[], GrTransformForma t transformsFormat, |
463 SkStrokeRec::Style stroke, | 463 SkPath::FillType fill, const GrDeviceCoord Texture* dstCopy) { |
464 const GrDeviceCoordTexture* dstCopy) { | |
465 SkASSERT(pathCount); | |
466 | |
467 if (this->needsNewClip()) { | 464 if (this->needsNewClip()) { |
468 this->recordClip(); | 465 this->recordClip(); |
469 } | 466 } |
470 if (this->needsNewState()) { | 467 if (this->needsNewState()) { |
471 this->recordState(); | 468 this->recordState(); |
472 } | 469 } |
473 DrawPaths* dp = this->recordDrawPaths(); | 470 DrawPaths* dp = this->recordDrawPaths(); |
474 dp->fPathCount = pathCount; | 471 dp->fPathRange = pathRange; |
475 dp->fPaths = SkNEW_ARRAY(const GrPath*, pathCount); | 472 dp->fIndices = SkNEW_ARRAY(uint32_t, count); // TODO: Accomplish this withou t a malloc |
bsalomon
2014/07/17 17:27:28
What's the plan here? An immutable ref-cnt'ed arra
Chris Dalton
2014/07/17 18:15:19
I don't quite see where you are going with the imm
bsalomon
2014/07/21 14:11:08
I was thinking that drawPaths() could take a index
| |
476 memcpy(dp->fPaths, paths, sizeof(GrPath*) * pathCount); | 473 memcpy(dp->fIndices, indices, sizeof(uint32_t) * count); |
477 for (int i = 0; i < pathCount; ++i) { | 474 dp->fCount = count; |
478 dp->fPaths[i]->ref(); | |
479 } | |
480 | 475 |
481 dp->fTransforms = SkNEW_ARRAY(SkMatrix, pathCount); | 476 dp->fTransforms = SkNEW_ARRAY(float, GrTransformSize(transformsFormat) * cou nt); |
482 memcpy(dp->fTransforms, transforms, sizeof(SkMatrix) * pathCount); | 477 memcpy(dp->fTransforms, transforms, sizeof(float) * GrTransformSize(transfor msFormat) * count); |
478 dp->fTransformsFormat = transformsFormat; | |
483 | 479 |
484 dp->fFill = fill; | 480 dp->fFill = fill; |
485 dp->fStroke = stroke; | |
486 | 481 |
487 if (NULL != dstCopy) { | 482 if (NULL != dstCopy) { |
488 dp->fDstCopy = *dstCopy; | 483 dp->fDstCopy = *dstCopy; |
489 } | 484 } |
490 } | 485 } |
491 | 486 |
492 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, | 487 void GrInOrderDrawBuffer::clear(const SkIRect* rect, GrColor color, |
493 bool canIgnoreRect, GrRenderTarget* renderTarget ) { | 488 bool canIgnoreRect, GrRenderTarget* renderTarget ) { |
494 SkIRect r; | 489 SkIRect r; |
495 if (NULL == renderTarget) { | 490 if (NULL == renderTarget) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 NULL != drawPathIter->fDstCopy.texture( ) ? | 621 NULL != drawPathIter->fDstCopy.texture( ) ? |
627 &drawPathIter->fDstCopy : | 622 &drawPathIter->fDstCopy : |
628 NULL); | 623 NULL); |
629 break; | 624 break; |
630 } | 625 } |
631 case kDrawPaths_Cmd: { | 626 case kDrawPaths_Cmd: { |
632 SkASSERT(fDstGpu->drawState() != prevDrawState); | 627 SkASSERT(fDstGpu->drawState() != prevDrawState); |
633 SkAssertResult(drawPathsIter.next()); | 628 SkAssertResult(drawPathsIter.next()); |
634 const GrDeviceCoordTexture* dstCopy = | 629 const GrDeviceCoordTexture* dstCopy = |
635 NULL !=drawPathsIter->fDstCopy.texture() ? &drawPathsIter->f DstCopy : NULL; | 630 NULL !=drawPathsIter->fDstCopy.texture() ? &drawPathsIter->f DstCopy : NULL; |
636 fDstGpu->executeDrawPaths(drawPathsIter->fPathCount, drawPathsIt er->fPaths, | 631 fDstGpu->executeDrawPaths(drawPathsIter->fPathRange.get(), |
637 drawPathsIter->fTransforms, drawPathsI ter->fFill, | 632 drawPathsIter->fIndices, |
638 drawPathsIter->fStroke, dstCopy); | 633 drawPathsIter->fCount, |
634 drawPathsIter->fTransforms, | |
635 drawPathsIter->fTransformsFormat, | |
636 drawPathsIter->fFill, | |
637 dstCopy); | |
639 break; | 638 break; |
640 } | 639 } |
641 case kSetState_Cmd: | 640 case kSetState_Cmd: |
642 SkAssertResult(stateIter.next()); | 641 SkAssertResult(stateIter.next()); |
643 fDstGpu->setDrawState(stateIter.get()); | 642 fDstGpu->setDrawState(stateIter.get()); |
644 break; | 643 break; |
645 case kSetClip_Cmd: | 644 case kSetClip_Cmd: |
646 SkAssertResult(clipIter.next()); | 645 SkAssertResult(clipIter.next()); |
647 clipData.fClipStack = &clipIter->fStack; | 646 clipData.fClipStack = &clipIter->fStack; |
648 clipData.fOrigin = clipIter->fOrigin; | 647 clipData.fOrigin = clipIter->fOrigin; |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
988 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { | 987 GrInOrderDrawBuffer::CopySurface* GrInOrderDrawBuffer::recordCopySurface() { |
989 this->addToCmdBuffer(kCopySurface_Cmd); | 988 this->addToCmdBuffer(kCopySurface_Cmd); |
990 return &fCopySurfaces.push_back(); | 989 return &fCopySurfaces.push_back(); |
991 } | 990 } |
992 | 991 |
993 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { | 992 void GrInOrderDrawBuffer::clipWillBeSet(const GrClipData* newClipData) { |
994 INHERITED::clipWillBeSet(newClipData); | 993 INHERITED::clipWillBeSet(newClipData); |
995 fClipSet = true; | 994 fClipSet = true; |
996 fClipProxyState = kUnknown_ClipProxyState; | 995 fClipProxyState = kUnknown_ClipProxyState; |
997 } | 996 } |
OLD | NEW |