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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 class AutoReleaseGeometry : public ::SkNoncopyable { | 586 class AutoReleaseGeometry : public ::SkNoncopyable { |
587 public: | 587 public: |
588 AutoReleaseGeometry(GrDrawTarget* target, | 588 AutoReleaseGeometry(GrDrawTarget* target, |
589 int vertexCount, | 589 int vertexCount, |
590 int indexCount); | 590 int indexCount); |
591 AutoReleaseGeometry(); | 591 AutoReleaseGeometry(); |
592 ~AutoReleaseGeometry(); | 592 ~AutoReleaseGeometry(); |
593 bool set(GrDrawTarget* target, | 593 bool set(GrDrawTarget* target, |
594 int vertexCount, | 594 int vertexCount, |
595 int indexCount); | 595 int indexCount); |
596 bool succeeded() const { return NULL != fTarget; } | 596 bool succeeded() const { return SkToBool(fTarget); } |
597 void* vertices() const { SkASSERT(this->succeeded()); return fVertices;
} | 597 void* vertices() const { SkASSERT(this->succeeded()); return fVertices;
} |
598 void* indices() const { SkASSERT(this->succeeded()); return fIndices; } | 598 void* indices() const { SkASSERT(this->succeeded()); return fIndices; } |
599 SkPoint* positions() const { | 599 SkPoint* positions() const { |
600 return static_cast<SkPoint*>(this->vertices()); | 600 return static_cast<SkPoint*>(this->vertices()); |
601 } | 601 } |
602 | 602 |
603 private: | 603 private: |
604 void reset(); | 604 void reset(); |
605 | 605 |
606 GrDrawTarget* fTarget; | 606 GrDrawTarget* fTarget; |
(...skipping 25 matching lines...) Expand all Loading... |
632 //////////////////////////////////////////////////////////////////////////// | 632 //////////////////////////////////////////////////////////////////////////// |
633 | 633 |
634 /** | 634 /** |
635 * Saves the geometry src state at construction and restores in the destruct
or. It also saves | 635 * Saves the geometry src state at construction and restores in the destruct
or. It also saves |
636 * and then restores the vertex attrib state. | 636 * and then restores the vertex attrib state. |
637 */ | 637 */ |
638 class AutoGeometryPush : public ::SkNoncopyable { | 638 class AutoGeometryPush : public ::SkNoncopyable { |
639 public: | 639 public: |
640 AutoGeometryPush(GrDrawTarget* target) | 640 AutoGeometryPush(GrDrawTarget* target) |
641 : fAttribRestore(target->drawState()) { | 641 : fAttribRestore(target->drawState()) { |
642 SkASSERT(NULL != target); | 642 SkASSERT(target); |
643 fTarget = target; | 643 fTarget = target; |
644 target->pushGeometrySource(); | 644 target->pushGeometrySource(); |
645 } | 645 } |
646 | 646 |
647 ~AutoGeometryPush() { fTarget->popGeometrySource(); } | 647 ~AutoGeometryPush() { fTarget->popGeometrySource(); } |
648 | 648 |
649 private: | 649 private: |
650 GrDrawTarget* fTarget; | 650 GrDrawTarget* fTarget; |
651 GrDrawState::AutoVertexAttribRestore fAttribRestore; | 651 GrDrawState::AutoVertexAttribRestore fAttribRestore; |
652 }; | 652 }; |
653 | 653 |
654 /** | 654 /** |
655 * Combination of AutoGeometryPush and AutoStateRestore. The vertex attribs
will be in default | 655 * Combination of AutoGeometryPush and AutoStateRestore. The vertex attribs
will be in default |
656 * state regardless of ASRInit value. | 656 * state regardless of ASRInit value. |
657 */ | 657 */ |
658 class AutoGeometryAndStatePush : public ::SkNoncopyable { | 658 class AutoGeometryAndStatePush : public ::SkNoncopyable { |
659 public: | 659 public: |
660 AutoGeometryAndStatePush(GrDrawTarget* target, | 660 AutoGeometryAndStatePush(GrDrawTarget* target, |
661 ASRInit init, | 661 ASRInit init, |
662 const SkMatrix* viewMatrix = NULL) | 662 const SkMatrix* viewMatrix = NULL) |
663 : fState(target, init, viewMatrix) { | 663 : fState(target, init, viewMatrix) { |
664 SkASSERT(NULL != target); | 664 SkASSERT(target); |
665 fTarget = target; | 665 fTarget = target; |
666 target->pushGeometrySource(); | 666 target->pushGeometrySource(); |
667 if (kPreserve_ASRInit == init) { | 667 if (kPreserve_ASRInit == init) { |
668 target->drawState()->setDefaultVertexAttribs(); | 668 target->drawState()->setDefaultVertexAttribs(); |
669 } | 669 } |
670 } | 670 } |
671 | 671 |
672 ~AutoGeometryAndStatePush() { fTarget->popGeometrySource(); } | 672 ~AutoGeometryAndStatePush() { fTarget->popGeometrySource(); } |
673 | 673 |
674 private: | 674 private: |
675 AutoStateRestore fState; | 675 AutoStateRestore fState; |
676 GrDrawTarget* fTarget; | 676 GrDrawTarget* fTarget; |
677 }; | 677 }; |
678 | 678 |
679 /////////////////////////////////////////////////////////////////////////// | 679 /////////////////////////////////////////////////////////////////////////// |
680 // Draw execution tracking (for font atlases and other resources) | 680 // Draw execution tracking (for font atlases and other resources) |
681 class DrawToken { | 681 class DrawToken { |
682 public: | 682 public: |
683 DrawToken(GrDrawTarget* drawTarget, uint32_t drawID) : | 683 DrawToken(GrDrawTarget* drawTarget, uint32_t drawID) : |
684 fDrawTarget(drawTarget), fDrawID(drawID) {} | 684 fDrawTarget(drawTarget), fDrawID(drawID) {} |
685 | 685 |
686 bool isIssued() { return NULL != fDrawTarget && fDrawTarget->isIssued(fD
rawID); } | 686 bool isIssued() { return fDrawTarget && fDrawTarget->isIssued(fDrawID);
} |
687 | 687 |
688 private: | 688 private: |
689 GrDrawTarget* fDrawTarget; | 689 GrDrawTarget* fDrawTarget; |
690 uint32_t fDrawID; // this may wrap, but we're doing direct compa
rison | 690 uint32_t fDrawID; // this may wrap, but we're doing direct compa
rison |
691 // so that should be okay | 691 // so that should be okay |
692 }; | 692 }; |
693 | 693 |
694 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } | 694 virtual DrawToken getCurrentDrawToken() { return DrawToken(this, 0); } |
695 | 695 |
696 protected: | 696 protected: |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 void adjustStartIndex(int indexOffset); | 815 void adjustStartIndex(int indexOffset); |
816 | 816 |
817 void setDevBounds(const SkRect& bounds) { | 817 void setDevBounds(const SkRect& bounds) { |
818 fDevBoundsStorage = bounds; | 818 fDevBoundsStorage = bounds; |
819 fDevBounds = &fDevBoundsStorage; | 819 fDevBounds = &fDevBoundsStorage; |
820 } | 820 } |
821 const SkRect* getDevBounds() const { return fDevBounds; } | 821 const SkRect* getDevBounds() const { return fDevBounds; } |
822 | 822 |
823 // NULL if no copy of the dst is needed for the draw. | 823 // NULL if no copy of the dst is needed for the draw. |
824 const GrDeviceCoordTexture* getDstCopy() const { | 824 const GrDeviceCoordTexture* getDstCopy() const { |
825 if (NULL != fDstCopy.texture()) { | 825 if (fDstCopy.texture()) { |
826 return &fDstCopy; | 826 return &fDstCopy; |
827 } else { | 827 } else { |
828 return NULL; | 828 return NULL; |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 private: | 832 private: |
833 DrawInfo() { fDevBounds = NULL; } | 833 DrawInfo() { fDevBounds = NULL; } |
834 | 834 |
835 friend class GrDrawTarget; | 835 friend class GrDrawTarget; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 GrContext* fContext; | 930 GrContext* fContext; |
931 // To keep track that we always have at least as many debug marker adds as r
emoves | 931 // To keep track that we always have at least as many debug marker adds as r
emoves |
932 int fGpuTraceMar
kerCount; | 932 int fGpuTraceMar
kerCount; |
933 GrTraceMarkerSet fActiveTrace
Markers; | 933 GrTraceMarkerSet fActiveTrace
Markers; |
934 GrTraceMarkerSet fStoredTrace
Markers; | 934 GrTraceMarkerSet fStoredTrace
Markers; |
935 | 935 |
936 typedef SkRefCnt INHERITED; | 936 typedef SkRefCnt INHERITED; |
937 }; | 937 }; |
938 | 938 |
939 #endif | 939 #endif |
OLD | NEW |