OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 | |
11 #ifndef GrDrawTarget_DEFINED | 10 #ifndef GrDrawTarget_DEFINED |
12 #define GrDrawTarget_DEFINED | 11 #define GrDrawTarget_DEFINED |
13 | 12 |
14 #include "GrClipData.h" | 13 #include "GrClipData.h" |
15 #include "GrDrawState.h" | 14 #include "GrDrawState.h" |
16 #include "GrIndexBuffer.h" | 15 #include "GrIndexBuffer.h" |
17 #include "SkMatrix.h" | 16 #include "SkMatrix.h" |
18 #include "GrRefCnt.h" | 17 #include "GrRefCnt.h" |
19 | 18 |
20 #include "SkClipStack.h" | 19 #include "SkClipStack.h" |
21 #include "SkPath.h" | 20 #include "SkPath.h" |
22 #include "SkTLazy.h" | 21 #include "SkTLazy.h" |
23 #include "SkTArray.h" | 22 #include "SkTArray.h" |
24 #include "SkXfermode.h" | 23 #include "SkXfermode.h" |
25 | 24 |
26 class GrClipData; | 25 class GrClipData; |
| 26 class GrDrawTargetCaps; |
27 class GrPath; | 27 class GrPath; |
28 class GrVertexBuffer; | 28 class GrVertexBuffer; |
29 class SkStrokeRec; | 29 class SkStrokeRec; |
30 | 30 |
31 class GrDrawTarget : public GrRefCnt { | 31 class GrDrawTarget : public GrRefCnt { |
32 protected: | 32 protected: |
33 class DrawInfo; | 33 class DrawInfo; |
34 | 34 |
35 public: | 35 public: |
36 SK_DECLARE_INST_COUNT(GrDrawTarget) | 36 SK_DECLARE_INST_COUNT(GrDrawTarget) |
37 | 37 |
38 /** | |
39 * Represents the draw target capabilities. | |
40 */ | |
41 class Caps : public SkRefCnt { | |
42 public: | |
43 SK_DECLARE_INST_COUNT(Caps) | |
44 | |
45 Caps() { this->reset(); } | |
46 Caps(const Caps& c) { *this = c; } | |
47 Caps& operator= (const Caps& c); | |
48 | |
49 virtual void reset(); | |
50 virtual void print() const; | |
51 | |
52 bool eightBitPaletteSupport() const { return f8BitPaletteSupport; } | |
53 bool npotTextureTileSupport() const { return fNPOTTextureTileSupport; } | |
54 bool twoSidedStencilSupport() const { return fTwoSidedStencilSupport; } | |
55 bool stencilWrapOpsSupport() const { return fStencilWrapOpsSupport; } | |
56 bool hwAALineSupport() const { return fHWAALineSupport; } | |
57 bool shaderDerivativeSupport() const { return fShaderDerivativeSupport;
} | |
58 bool geometryShaderSupport() const { return fGeometryShaderSupport; } | |
59 bool dualSourceBlendingSupport() const { return fDualSourceBlendingSuppo
rt; } | |
60 bool bufferLockSupport() const { return fBufferLockSupport; } | |
61 bool pathStencilingSupport() const { return fPathStencilingSupport; } | |
62 | |
63 int maxRenderTargetSize() const { return fMaxRenderTargetSize; } | |
64 int maxTextureSize() const { return fMaxTextureSize; } | |
65 // Will be 0 if MSAA is not supported | |
66 int maxSampleCount() const { return fMaxSampleCount; } | |
67 protected: | |
68 | |
69 bool f8BitPaletteSupport : 1; | |
70 bool fNPOTTextureTileSupport : 1; | |
71 bool fTwoSidedStencilSupport : 1; | |
72 bool fStencilWrapOpsSupport : 1; | |
73 bool fHWAALineSupport : 1; | |
74 bool fShaderDerivativeSupport : 1; | |
75 bool fGeometryShaderSupport : 1; | |
76 bool fDualSourceBlendingSupport : 1; | |
77 bool fBufferLockSupport : 1; | |
78 bool fPathStencilingSupport : 1; | |
79 | |
80 int fMaxRenderTargetSize; | |
81 int fMaxTextureSize; | |
82 int fMaxSampleCount; | |
83 | |
84 typedef SkRefCnt INHERITED; | |
85 }; | |
86 | |
87 /////////////////////////////////////////////////////////////////////////// | 38 /////////////////////////////////////////////////////////////////////////// |
88 | 39 |
89 // The context may not be fully constructed and should not be used during Gr
DrawTarget | 40 // The context may not be fully constructed and should not be used during Gr
DrawTarget |
90 // construction. | 41 // construction. |
91 GrDrawTarget(GrContext* context); | 42 GrDrawTarget(GrContext* context); |
92 virtual ~GrDrawTarget(); | 43 virtual ~GrDrawTarget(); |
93 | 44 |
94 /** | 45 /** |
95 * Gets the capabilities of the draw target. | 46 * Gets the capabilities of the draw target. |
96 */ | 47 */ |
97 const Caps* caps() const { return fCaps.get(); } | 48 const GrDrawTargetCaps* caps() const { return fCaps.get(); } |
98 | 49 |
99 /** | 50 /** |
100 * Sets the current clip to the region specified by clip. All draws will be | 51 * Sets the current clip to the region specified by clip. All draws will be |
101 * clipped against this clip if kClip_StateBit is enabled. | 52 * clipped against this clip if kClip_StateBit is enabled. |
102 * | 53 * |
103 * Setting the clip may (or may not) zero out the client's stencil bits. | 54 * Setting the clip may (or may not) zero out the client's stencil bits. |
104 * | 55 * |
105 * @param description of the clipping region | 56 * @param description of the clipping region |
106 */ | 57 */ |
107 void setClip(const GrClipData* clip); | 58 void setClip(const GrClipData* clip); |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 // accessors for derived classes | 609 // accessors for derived classes |
659 const GeometrySrcState& getGeomSrc() const { return fGeoSrcStateStack.back()
; } | 610 const GeometrySrcState& getGeomSrc() const { return fGeoSrcStateStack.back()
; } |
660 // it is preferable to call this rather than getGeomSrc()->fVertexSize becau
se of the assert. | 611 // it is preferable to call this rather than getGeomSrc()->fVertexSize becau
se of the assert. |
661 size_t getVertexSize() const { | 612 size_t getVertexSize() const { |
662 // the vertex layout is only valid if a vertex source has been specified
. | 613 // the vertex layout is only valid if a vertex source has been specified
. |
663 GrAssert(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); | 614 GrAssert(this->getGeomSrc().fVertexSrc != kNone_GeometrySrcType); |
664 return this->getGeomSrc().fVertexSize; | 615 return this->getGeomSrc().fVertexSize; |
665 } | 616 } |
666 | 617 |
667 // Subclass must initialize this in its constructor. | 618 // Subclass must initialize this in its constructor. |
668 SkAutoTUnref<const Caps> fCaps; | 619 SkAutoTUnref<const GrDrawTargetCaps> fCaps; |
669 | 620 |
670 /** | 621 /** |
671 * Used to communicate draws to subclass's onDraw function. | 622 * Used to communicate draws to subclass's onDraw function. |
672 */ | 623 */ |
673 class DrawInfo { | 624 class DrawInfo { |
674 public: | 625 public: |
675 DrawInfo(const DrawInfo& di) { (*this) = di; } | 626 DrawInfo(const DrawInfo& di) { (*this) = di; } |
676 DrawInfo& operator =(const DrawInfo& di); | 627 DrawInfo& operator =(const DrawInfo& di); |
677 | 628 |
678 GrPrimitiveType primitiveType() const { return fPrimitiveType; } | 629 GrPrimitiveType primitiveType() const { return fPrimitiveType; } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 const GrClipData* fClip; | 721 const GrClipData* fClip; |
771 GrDrawState* fDrawState; | 722 GrDrawState* fDrawState; |
772 GrDrawState fDefaultDraw
State; | 723 GrDrawState fDefaultDraw
State; |
773 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. | 724 // The context owns us, not vice-versa, so this ptr is not ref'ed by DrawTar
get. |
774 GrContext* fContext; | 725 GrContext* fContext; |
775 | 726 |
776 typedef GrRefCnt INHERITED; | 727 typedef GrRefCnt INHERITED; |
777 }; | 728 }; |
778 | 729 |
779 #endif | 730 #endif |
OLD | NEW |