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 GrContext_DEFINED | 8 #ifndef GrContext_DEFINED |
9 #define GrContext_DEFINED | 9 #define GrContext_DEFINED |
10 | 10 |
| 11 #include "GrClipData.h" |
11 #include "GrColor.h" | 12 #include "GrColor.h" |
12 #include "GrClipData.h" | |
13 #include "SkMatrix.h" | |
14 #include "GrPaint.h" | 13 #include "GrPaint.h" |
15 #include "GrPathRendererChain.h" | 14 #include "GrPathRendererChain.h" |
16 #include "GrPoint.h" | 15 #include "GrPoint.h" |
17 #include "GrRenderTarget.h" | 16 #include "GrRenderTarget.h" |
18 #include "GrTexture.h" | 17 #include "GrTexture.h" |
| 18 #include "SkMatrix.h" |
| 19 #include "SkTypes.h" |
19 | 20 |
20 class GrAARectRenderer; | 21 class GrAARectRenderer; |
21 class GrAutoScratchTexture; | 22 class GrAutoScratchTexture; |
22 class GrDrawState; | 23 class GrDrawState; |
23 class GrDrawTarget; | 24 class GrDrawTarget; |
24 class GrEffect; | 25 class GrEffect; |
25 class GrFontCache; | 26 class GrFontCache; |
26 class GrGpu; | 27 class GrGpu; |
27 class GrIndexBuffer; | 28 class GrIndexBuffer; |
28 class GrIndexBufferAllocPool; | 29 class GrIndexBufferAllocPool; |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 * This is only necessary when a client wants to access the object directly | 624 * This is only necessary when a client wants to access the object directly |
624 * using the backend API directly. GrContext will detect when it must | 625 * using the backend API directly. GrContext will detect when it must |
625 * perform a resolve to a GrTexture used as the source of a draw or before | 626 * perform a resolve to a GrTexture used as the source of a draw or before |
626 * reading pixels back from a GrTexture or GrRenderTarget. | 627 * reading pixels back from a GrTexture or GrRenderTarget. |
627 */ | 628 */ |
628 void resolveRenderTarget(GrRenderTarget* target); | 629 void resolveRenderTarget(GrRenderTarget* target); |
629 | 630 |
630 /////////////////////////////////////////////////////////////////////////// | 631 /////////////////////////////////////////////////////////////////////////// |
631 // Helpers | 632 // Helpers |
632 | 633 |
633 class AutoRenderTarget : public ::GrNoncopyable { | 634 class AutoRenderTarget : public ::SkNoncopyable { |
634 public: | 635 public: |
635 AutoRenderTarget(GrContext* context, GrRenderTarget* target) { | 636 AutoRenderTarget(GrContext* context, GrRenderTarget* target) { |
636 fPrevTarget = context->getRenderTarget(); | 637 fPrevTarget = context->getRenderTarget(); |
637 SkSafeRef(fPrevTarget); | 638 SkSafeRef(fPrevTarget); |
638 context->setRenderTarget(target); | 639 context->setRenderTarget(target); |
639 fContext = context; | 640 fContext = context; |
640 } | 641 } |
641 AutoRenderTarget(GrContext* context) { | 642 AutoRenderTarget(GrContext* context) { |
642 fPrevTarget = context->getRenderTarget(); | 643 fPrevTarget = context->getRenderTarget(); |
643 SkSafeRef(fPrevTarget); | 644 SkSafeRef(fPrevTarget); |
(...skipping 17 matching lines...) Expand all Loading... |
661 * A GrPaint is setup with GrEffects. The stages will have access to the pre
-matrix source | 662 * A GrPaint is setup with GrEffects. The stages will have access to the pre
-matrix source |
662 * geometry positions when the draw is executed. Later on a decision is made
to transform the | 663 * geometry positions when the draw is executed. Later on a decision is made
to transform the |
663 * geometry to device space on the CPU. The effects now need to know that th
e space in which | 664 * geometry to device space on the CPU. The effects now need to know that th
e space in which |
664 * the geometry will be specified has changed. | 665 * the geometry will be specified has changed. |
665 * | 666 * |
666 * Note that when restore is called (or in the destructor) the context's mat
rix will be | 667 * Note that when restore is called (or in the destructor) the context's mat
rix will be |
667 * restored. However, the paint will not be restored. The caller must make a
copy of the | 668 * restored. However, the paint will not be restored. The caller must make a
copy of the |
668 * paint if necessary. Hint: use SkTCopyOnFirstWrite if the AutoMatrix is co
nditionally | 669 * paint if necessary. Hint: use SkTCopyOnFirstWrite if the AutoMatrix is co
nditionally |
669 * initialized. | 670 * initialized. |
670 */ | 671 */ |
671 class AutoMatrix : GrNoncopyable { | 672 class AutoMatrix : public ::SkNoncopyable { |
672 public: | 673 public: |
673 AutoMatrix() : fContext(NULL) {} | 674 AutoMatrix() : fContext(NULL) {} |
674 | 675 |
675 ~AutoMatrix() { this->restore(); } | 676 ~AutoMatrix() { this->restore(); } |
676 | 677 |
677 /** | 678 /** |
678 * Initializes by pre-concat'ing the context's current matrix with the p
reConcat param. | 679 * Initializes by pre-concat'ing the context's current matrix with the p
reConcat param. |
679 */ | 680 */ |
680 void setPreConcat(GrContext* context, const SkMatrix& preConcat, GrPaint
* paint = NULL) { | 681 void setPreConcat(GrContext* context, const SkMatrix& preConcat, GrPaint
* paint = NULL) { |
681 SkASSERT(NULL != context); | 682 SkASSERT(NULL != context); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 fContext->setMatrix(fMatrix); | 755 fContext->setMatrix(fMatrix); |
755 fContext = NULL; | 756 fContext = NULL; |
756 } | 757 } |
757 } | 758 } |
758 | 759 |
759 private: | 760 private: |
760 GrContext* fContext; | 761 GrContext* fContext; |
761 SkMatrix fMatrix; | 762 SkMatrix fMatrix; |
762 }; | 763 }; |
763 | 764 |
764 class AutoClip : GrNoncopyable { | 765 class AutoClip : public ::SkNoncopyable { |
765 public: | 766 public: |
766 // This enum exists to require a caller of the constructor to acknowledg
e that the clip will | 767 // This enum exists to require a caller of the constructor to acknowledg
e that the clip will |
767 // initially be wide open. It also could be extended if there are other
desirable initial | 768 // initially be wide open. It also could be extended if there are other
desirable initial |
768 // clip states. | 769 // clip states. |
769 enum InitialClip { | 770 enum InitialClip { |
770 kWideOpen_InitialClip, | 771 kWideOpen_InitialClip, |
771 }; | 772 }; |
772 | 773 |
773 AutoClip(GrContext* context, InitialClip initialState) | 774 AutoClip(GrContext* context, InitialClip initialState) |
774 : fContext(context) { | 775 : fContext(context) { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 */ | 934 */ |
934 static bool OverbudgetCB(void* data); | 935 static bool OverbudgetCB(void* data); |
935 | 936 |
936 typedef SkRefCnt INHERITED; | 937 typedef SkRefCnt INHERITED; |
937 }; | 938 }; |
938 | 939 |
939 /** | 940 /** |
940 * Gets and locks a scratch texture from a descriptor using either exact or appr
oximate criteria. | 941 * Gets and locks a scratch texture from a descriptor using either exact or appr
oximate criteria. |
941 * Unlocks texture in the destructor. | 942 * Unlocks texture in the destructor. |
942 */ | 943 */ |
943 class GrAutoScratchTexture : ::GrNoncopyable { | 944 class GrAutoScratchTexture : public ::SkNoncopyable { |
944 public: | 945 public: |
945 GrAutoScratchTexture() | 946 GrAutoScratchTexture() |
946 : fContext(NULL) | 947 : fContext(NULL) |
947 , fTexture(NULL) { | 948 , fTexture(NULL) { |
948 } | 949 } |
949 | 950 |
950 GrAutoScratchTexture(GrContext* context, | 951 GrAutoScratchTexture(GrContext* context, |
951 const GrTextureDesc& desc, | 952 const GrTextureDesc& desc, |
952 GrContext::ScratchTexMatch match = GrContext::kApprox_S
cratchTexMatch) | 953 GrContext::ScratchTexMatch match = GrContext::kApprox_S
cratchTexMatch) |
953 : fContext(NULL) | 954 : fContext(NULL) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1016 } | 1017 } |
1017 | 1018 |
1018 GrTexture* texture() { return fTexture; } | 1019 GrTexture* texture() { return fTexture; } |
1019 | 1020 |
1020 private: | 1021 private: |
1021 GrContext* fContext; | 1022 GrContext* fContext; |
1022 GrTexture* fTexture; | 1023 GrTexture* fTexture; |
1023 }; | 1024 }; |
1024 | 1025 |
1025 #endif | 1026 #endif |
OLD | NEW |