OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #ifndef GrClipMaskManager_DEFINED | 7 #ifndef GrClipMaskManager_DEFINED |
8 #define GrClipMaskManager_DEFINED | 8 #define GrClipMaskManager_DEFINED |
9 | 9 |
10 #include "GrPipelineBuilder.h" | 10 #include "GrPipelineBuilder.h" |
11 #include "GrReducedClip.h" | 11 #include "GrReducedClip.h" |
12 #include "GrStencil.h" | 12 #include "GrStencil.h" |
13 #include "GrTexture.h" | 13 #include "GrTexture.h" |
14 #include "SkClipStack.h" | 14 #include "SkClipStack.h" |
15 #include "SkDeque.h" | 15 #include "SkDeque.h" |
16 #include "SkPath.h" | 16 #include "SkPath.h" |
17 #include "SkRefCnt.h" | 17 #include "SkRefCnt.h" |
18 #include "SkTLList.h" | 18 #include "SkTLList.h" |
19 #include "SkTypes.h" | 19 #include "SkTypes.h" |
20 | 20 |
21 class GrDrawTarget; | 21 class GrDrawTarget; |
22 class GrPathRenderer; | 22 class GrPathRenderer; |
23 class GrPathRendererChain; | 23 class GrPathRendererChain; |
| 24 class GrResourceProvider; |
24 class GrTexture; | 25 class GrTexture; |
25 class SkPath; | 26 class SkPath; |
26 | 27 |
27 /** | 28 /** |
28 * Produced by GrClipMaskManager. It provides a set of modifications to the draw
ing state that | 29 * Produced by GrClipMaskManager. It provides a set of modifications to the draw
ing state that |
29 * are used to create the final GrPipeline for a GrBatch. This is a work in prog
ress. It will | 30 * are used to create the final GrPipeline for a GrBatch. This is a work in prog
ress. It will |
30 * eventually encapsulate all mechanisms for modifying the scissor, shaders, and
stencil state | 31 * eventually encapsulate all mechanisms for modifying the scissor, shaders, and
stencil state |
31 * to implement clipping. | 32 * to implement clipping. |
32 */ | 33 */ |
33 class GrAppliedClip : public SkNoncopyable { | 34 class GrAppliedClip : public SkNoncopyable { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 */ | 66 */ |
66 bool setupClipping(const GrPipelineBuilder&, | 67 bool setupClipping(const GrPipelineBuilder&, |
67 GrPipelineBuilder::AutoRestoreStencil*, | 68 GrPipelineBuilder::AutoRestoreStencil*, |
68 const SkRect* devBounds, | 69 const SkRect* devBounds, |
69 GrAppliedClip*); | 70 GrAppliedClip*); |
70 | 71 |
71 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; | 72 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; |
72 | 73 |
73 private: | 74 private: |
74 inline GrContext* getContext(); | 75 inline GrContext* getContext(); |
| 76 inline const GrCaps* caps() const; |
| 77 inline GrResourceProvider* resourceProvider(); |
75 | 78 |
76 /** | 79 /** |
77 * Informs the helper function adjustStencilParams() about how the stencil | 80 * Informs the helper function adjustStencilParams() about how the stencil |
78 * buffer clip is being used. | 81 * buffer clip is being used. |
79 */ | 82 */ |
80 enum StencilClipMode { | 83 enum StencilClipMode { |
81 // Draw to the clip bit of the stencil buffer | 84 // Draw to the clip bit of the stencil buffer |
82 kModifyClip_StencilClipMode, | 85 kModifyClip_StencilClipMode, |
83 // Clip against the existing representation of the clip in the high bit | 86 // Clip against the existing representation of the clip in the high bit |
84 // of the stencil buffer. | 87 // of the stencil buffer. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 130 |
128 // Draws a clip element into the target alpha mask. The caller should have a
lready setup the | 131 // Draws a clip element into the target alpha mask. The caller should have a
lready setup the |
129 // desired blend operation. Optionally if the caller already selected a path
renderer it can | 132 // desired blend operation. Optionally if the caller already selected a path
renderer it can |
130 // be passed. Otherwise the function will select one if the element is a pat
h. | 133 // be passed. Otherwise the function will select one if the element is a pat
h. |
131 bool drawElement(GrPipelineBuilder*, | 134 bool drawElement(GrPipelineBuilder*, |
132 const SkMatrix& viewMatrix, | 135 const SkMatrix& viewMatrix, |
133 GrTexture* target, | 136 GrTexture* target, |
134 const SkClipStack::Element*, | 137 const SkClipStack::Element*, |
135 GrPathRenderer* pr = nullptr); | 138 GrPathRenderer* pr = nullptr); |
136 | 139 |
137 void mergeMask(GrPipelineBuilder*, | |
138 GrTexture* dstMask, | |
139 GrTexture* srcMask, | |
140 SkRegion::Op op, | |
141 const SkIRect& dstBound, | |
142 const SkIRect& srcBound); | |
143 | |
144 GrTexture* createTempMask(int width, int height); | |
145 | |
146 /** | 140 /** |
147 * Called prior to return control back the GrGpu in setupClipping. It update
s the | 141 * Called prior to return control back the GrGpu in setupClipping. It update
s the |
148 * GrPipelineBuilder with stencil settings that account for stencil-based cl
ipping. | 142 * GrPipelineBuilder with stencil settings that account for stencil-based cl
ipping. |
149 */ | 143 */ |
150 void setPipelineBuilderStencil(const GrPipelineBuilder&, | 144 void setPipelineBuilderStencil(const GrPipelineBuilder&, |
151 GrPipelineBuilder::AutoRestoreStencil*); | 145 GrPipelineBuilder::AutoRestoreStencil*); |
152 | 146 |
153 /** | 147 /** |
154 * Adjusts the stencil settings to account for interaction with stencil | 148 * Adjusts the stencil settings to account for interaction with stencil |
155 * clipping. | 149 * clipping. |
156 */ | 150 */ |
157 void adjustStencilParams(GrStencilSettings* settings, | 151 void adjustStencilParams(GrStencilSettings* settings, |
158 StencilClipMode mode, | 152 StencilClipMode mode, |
159 int stencilBitCnt); | 153 int stencilBitCnt); |
160 | 154 |
161 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); | 155 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); |
162 | 156 |
163 static const int kMaxAnalyticElements = 4; | 157 static const int kMaxAnalyticElements = 4; |
164 | 158 |
165 GrDrawTarget* fDrawTarget; // This is our owning draw target. | 159 GrDrawTarget* fDrawTarget; // This is our owning draw target. |
166 StencilClipMode fClipMode; | 160 StencilClipMode fClipMode; |
167 | 161 |
168 typedef SkNoncopyable INHERITED; | 162 typedef SkNoncopyable INHERITED; |
169 }; | 163 }; |
170 #endif // GrClipMaskManager_DEFINED | 164 #endif // GrClipMaskManager_DEFINED |
OLD | NEW |