| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 #ifndef GrDrawTarget_DEFINED | 8 #ifndef GrDrawTarget_DEFINED |
| 9 #define GrDrawTarget_DEFINED | 9 #define GrDrawTarget_DEFINED |
| 10 | 10 |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get();
} | 562 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get();
} |
| 563 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } | 563 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } |
| 564 void setVertexBuffer(const GrVertexBuffer* vb) { | 564 void setVertexBuffer(const GrVertexBuffer* vb) { |
| 565 fVertexBuffer.reset(vb); | 565 fVertexBuffer.reset(vb); |
| 566 } | 566 } |
| 567 void setIndexBuffer(const GrIndexBuffer* ib) { | 567 void setIndexBuffer(const GrIndexBuffer* ib) { |
| 568 fIndexBuffer.reset(ib); | 568 fIndexBuffer.reset(ib); |
| 569 } | 569 } |
| 570 const SkRect* getDevBounds() const { return fDevBounds; } | 570 const SkRect* getDevBounds() const { return fDevBounds; } |
| 571 | 571 |
| 572 // NULL if no copy of the dst is needed for the draw. | |
| 573 const GrDeviceCoordTexture* getDstCopy() const { | |
| 574 if (fDstCopy.texture()) { | |
| 575 return &fDstCopy; | |
| 576 } else { | |
| 577 return NULL; | |
| 578 } | |
| 579 } | |
| 580 | |
| 581 private: | 572 private: |
| 582 DrawInfo() { fDevBounds = NULL; } | 573 DrawInfo() { fDevBounds = NULL; } |
| 583 | 574 |
| 584 friend class GrDrawTarget; | 575 friend class GrDrawTarget; |
| 585 | 576 |
| 586 GrPrimitiveType fPrimitiveType; | 577 GrPrimitiveType fPrimitiveType; |
| 587 | 578 |
| 588 int fStartVertex; | 579 int fStartVertex; |
| 589 int fStartIndex; | 580 int fStartIndex; |
| 590 int fVertexCount; | 581 int fVertexCount; |
| 591 int fIndexCount; | 582 int fIndexCount; |
| 592 | 583 |
| 593 int fInstanceCount; | 584 int fInstanceCount; |
| 594 int fVerticesPerInstance; | 585 int fVerticesPerInstance; |
| 595 int fIndicesPerInstance; | 586 int fIndicesPerInstance; |
| 596 | 587 |
| 597 SkRect fDevBoundsStorage; | 588 SkRect fDevBoundsStorage; |
| 598 SkRect* fDevBounds; | 589 SkRect* fDevBounds; |
| 599 | 590 |
| 600 GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer; | 591 GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuffer; |
| 601 GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer; | 592 GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffer; |
| 602 | |
| 603 GrDeviceCoordTexture fDstCopy; | |
| 604 }; | 593 }; |
| 605 | 594 |
| 606 virtual void setDrawBuffers(DrawInfo*) = 0;; | 595 virtual void setDrawBuffers(DrawInfo*) = 0;; |
| 607 bool programUnitTest(int maxStages); | 596 bool programUnitTest(int maxStages); |
| 608 | 597 |
| 609 protected: | 598 protected: |
| 610 enum GeometrySrcType { | 599 enum GeometrySrcType { |
| 611 kNone_GeometrySrcType, //<! src has not been specified | 600 kNone_GeometrySrcType, //<! src has not been specified |
| 612 kReserved_GeometrySrcType, //<! src was set using reserve*Space | 601 kReserved_GeometrySrcType, //<! src was set using reserve*Space |
| 613 kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer | 602 kBuffer_GeometrySrcType //<! src was set using set*SourceToBuffer |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 } | 655 } |
| 667 | 656 |
| 668 // Subclass must initialize this in its constructor. | 657 // Subclass must initialize this in its constructor. |
| 669 SkAutoTUnref<const GrDrawTargetCaps> fCaps; | 658 SkAutoTUnref<const GrDrawTargetCaps> fCaps; |
| 670 | 659 |
| 671 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } | 660 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers
; } |
| 672 | 661 |
| 673 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required | 662 // Makes a copy of the dst if it is necessary for the draw. Returns false if
a copy is required |
| 674 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it | 663 // but couldn't be made. Otherwise, returns true. This method needs to be p
rotected because it |
| 675 // needs to be accessed by GLPrograms to setup a correct drawstate | 664 // needs to be accessed by GLPrograms to setup a correct drawstate |
| 676 bool setupDstReadIfNecessary(GrDrawState* ds, DrawInfo* info) { | |
| 677 return this->setupDstReadIfNecessary(ds, &info->fDstCopy, info->getDevBo
unds()); | |
| 678 } | |
| 679 bool setupDstReadIfNecessary(GrDrawState*, | 665 bool setupDstReadIfNecessary(GrDrawState*, |
| 680 GrDeviceCoordTexture* dstCopy, | 666 GrDeviceCoordTexture* dstCopy, |
| 681 const SkRect* drawBounds); | 667 const SkRect* drawBounds); |
| 682 | 668 |
| 683 private: | 669 private: |
| 684 // A subclass can optionally overload this function to be notified before | 670 // A subclass can optionally overload this function to be notified before |
| 685 // vertex and index space is reserved. | 671 // vertex and index space is reserved. |
| 686 virtual void willReserveVertexAndIndexSpace(int vertexCount, | 672 virtual void willReserveVertexAndIndexSpace(int vertexCount, |
| 687 size_t vertexStride, | 673 size_t vertexStride, |
| 688 int indexCount) {} | 674 int indexCount) {} |
| 689 | 675 |
| 690 // implemented by subclass to allocate space for reserved geom | 676 // implemented by subclass to allocate space for reserved geom |
| 691 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; | 677 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void**
vertices) = 0; |
| 692 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; | 678 virtual bool onReserveIndexSpace(int indexCount, void** indices) = 0; |
| 693 // implemented by subclass to handle release of reserved geom space | 679 // implemented by subclass to handle release of reserved geom space |
| 694 virtual void releaseReservedVertexSpace() = 0; | 680 virtual void releaseReservedVertexSpace() = 0; |
| 695 virtual void releaseReservedIndexSpace() = 0; | 681 virtual void releaseReservedIndexSpace() = 0; |
| 696 // subclass overrides to be notified just before geo src state is pushed/pop
ped. | 682 // subclass overrides to be notified just before geo src state is pushed/pop
ped. |
| 697 virtual void geometrySourceWillPush() = 0; | 683 virtual void geometrySourceWillPush() = 0; |
| 698 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; | 684 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) =
0; |
| 699 // subclass called to perform drawing | 685 // subclass called to perform drawing |
| 700 virtual void onDraw(const GrDrawState&, | 686 virtual void onDraw(const GrDrawState&, |
| 701 const DrawInfo&, | 687 const DrawInfo&, |
| 702 const GrClipMaskManager::ScissorState&) = 0; | 688 const GrClipMaskManager::ScissorState&, |
| 689 const GrDeviceCoordTexture* dstCopy) = 0; |
| 703 // TODO copy in order drawbuffer onDrawRect to here | 690 // TODO copy in order drawbuffer onDrawRect to here |
| 704 virtual void onDrawRect(GrDrawState*, | 691 virtual void onDrawRect(GrDrawState*, |
| 705 const SkRect& rect, | 692 const SkRect& rect, |
| 706 const SkRect* localRect, | 693 const SkRect* localRect, |
| 707 const SkMatrix* localMatrix) = 0; | 694 const SkMatrix* localMatrix) = 0; |
| 708 | 695 |
| 709 virtual void onStencilPath(const GrDrawState&, | 696 virtual void onStencilPath(const GrDrawState&, |
| 710 const GrPath*, | 697 const GrPath*, |
| 711 const GrClipMaskManager::ScissorState&, | 698 const GrClipMaskManager::ScissorState&, |
| 712 const GrStencilSettings&) = 0; | 699 const GrStencilSettings&) = 0; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 virtual bool setupClip(const SkRect* devBounds, | 803 virtual bool setupClip(const SkRect* devBounds, |
| 817 GrDrawState::AutoRestoreEffects* are, | 804 GrDrawState::AutoRestoreEffects* are, |
| 818 GrDrawState::AutoRestoreStencil* ars, | 805 GrDrawState::AutoRestoreStencil* ars, |
| 819 GrDrawState*, | 806 GrDrawState*, |
| 820 GrClipMaskManager::ScissorState* scissorState) SK_OVE
RRIDE; | 807 GrClipMaskManager::ScissorState* scissorState) SK_OVE
RRIDE; |
| 821 | 808 |
| 822 typedef GrDrawTarget INHERITED; | 809 typedef GrDrawTarget INHERITED; |
| 823 }; | 810 }; |
| 824 | 811 |
| 825 #endif | 812 #endif |
| OLD | NEW |