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" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 * and sets the GrGpu's scissor and stencil state. If the return is false | 62 * and sets the GrGpu's scissor and stencil state. If the return is false |
63 * then the draw can be skipped. The AutoRestoreEffects is initialized by | 63 * then the draw can be skipped. The AutoRestoreEffects is initialized by |
64 * the manager when it must install additional effects to implement the | 64 * the manager when it must install additional effects to implement the |
65 * clip. devBounds is optional but can help optimize clipping. | 65 * clip. devBounds is optional but can help optimize clipping. |
66 */ | 66 */ |
67 bool setupClipping(const GrPipelineBuilder&, | 67 bool setupClipping(const GrPipelineBuilder&, |
68 GrPipelineBuilder::AutoRestoreStencil*, | 68 GrPipelineBuilder::AutoRestoreStencil*, |
69 const SkRect* devBounds, | 69 const SkRect* devBounds, |
70 GrAppliedClip*); | 70 GrAppliedClip*); |
71 | 71 |
| 72 bool setupScissorClip(const GrPipelineBuilder& pipelineBuilder, |
| 73 GrPipelineBuilder::AutoRestoreStencil* ars, |
| 74 const SkIRect& scissor, |
| 75 const SkRect* devBounds, |
| 76 GrAppliedClip* out); |
| 77 |
72 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; | 78 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; |
73 | 79 |
74 private: | 80 private: |
75 inline GrContext* getContext(); | 81 inline GrContext* getContext(); |
76 inline const GrCaps* caps() const; | 82 inline const GrCaps* caps() const; |
77 inline GrResourceProvider* resourceProvider(); | 83 inline GrResourceProvider* resourceProvider(); |
78 | 84 |
79 static bool PathNeedsSWRenderer(GrContext* context, | 85 static bool PathNeedsSWRenderer(GrContext* context, |
80 bool isStencilDisabled, | 86 bool isStencilDisabled, |
81 const GrRenderTarget* rt, | 87 const GrRenderTarget* rt, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 // Draws the clip into the stencil buffer | 122 // Draws the clip into the stencil buffer |
117 bool createStencilClipMask(GrRenderTarget*, | 123 bool createStencilClipMask(GrRenderTarget*, |
118 int32_t elementsGenID, | 124 int32_t elementsGenID, |
119 GrReducedClip::InitialState initialState, | 125 GrReducedClip::InitialState initialState, |
120 const GrReducedClip::ElementList& elements, | 126 const GrReducedClip::ElementList& elements, |
121 const SkIRect& clipSpaceIBounds, | 127 const SkIRect& clipSpaceIBounds, |
122 const SkIPoint& clipSpaceToStencilOffset); | 128 const SkIPoint& clipSpaceToStencilOffset); |
123 | 129 |
124 // Creates an alpha mask of the clip. The mask is a rasterization of element
s through the | 130 // Creates an alpha mask of the clip. The mask is a rasterization of element
s through the |
125 // rect specified by clipSpaceIBounds. | 131 // rect specified by clipSpaceIBounds. |
126 GrTexture* createAlphaClipMask(int32_t elementsGenID, | 132 static GrTexture* CreateAlphaClipMask(GrContext*, |
127 GrReducedClip::InitialState initialState, | 133 int32_t elementsGenID, |
128 const GrReducedClip::ElementList& elements, | 134 GrReducedClip::InitialState initialSta
te, |
129 const SkVector& clipToMaskOffset, | 135 const GrReducedClip::ElementList& elem
ents, |
130 const SkIRect& clipSpaceIBounds); | 136 const SkVector& clipToMaskOffset, |
| 137 const SkIRect& clipSpaceIBounds); |
131 | 138 |
132 // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the
result texture. | 139 // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the
result texture. |
133 GrTexture* createSoftwareClipMask(int32_t elementsGenID, | 140 static GrTexture* CreateSoftwareClipMask(GrContext*, |
134 GrReducedClip::InitialState initialState, | 141 int32_t elementsGenID, |
135 const GrReducedClip::ElementList& elements
, | 142 GrReducedClip::InitialState initial
State, |
136 const SkVector& clipToMaskOffset, | 143 const GrReducedClip::ElementList& e
lements, |
137 const SkIRect& clipSpaceIBounds); | 144 const SkVector& clipToMaskOffset, |
| 145 const SkIRect& clipSpaceIBounds); |
138 | 146 |
139 bool useSWOnlyPath(const GrPipelineBuilder&, | 147 static bool UseSWOnlyPath(GrContext*, |
140 const GrRenderTarget* rt, | 148 const GrPipelineBuilder&, |
141 const SkVector& clipToMaskOffset, | 149 const GrRenderTarget* rt, |
142 const GrReducedClip::ElementList& elements); | 150 const SkVector& clipToMaskOffset, |
143 | 151 const GrReducedClip::ElementList& elements); |
144 // Draws a clip element into the target alpha mask. The caller should have a
lready setup the | |
145 // desired blend operation. Optionally if the caller already selected a path
renderer it can | |
146 // be passed. Otherwise the function will select one if the element is a pat
h. | |
147 bool drawElement(GrPipelineBuilder*, | |
148 const SkMatrix& viewMatrix, | |
149 GrTexture* target, | |
150 const SkClipStack::Element*, | |
151 GrPathRenderer* pr = nullptr); | |
152 | 152 |
153 /** | 153 /** |
154 * Called prior to return control back the GrGpu in setupClipping. It update
s the | 154 * Called prior to return control back the GrGpu in setupClipping. It update
s the |
155 * GrPipelineBuilder with stencil settings that account for stencil-based cl
ipping. | 155 * GrPipelineBuilder with stencil settings that account for stencil-based cl
ipping. |
156 */ | 156 */ |
157 void setPipelineBuilderStencil(const GrPipelineBuilder&, | 157 void setPipelineBuilderStencil(const GrPipelineBuilder&, |
158 GrPipelineBuilder::AutoRestoreStencil*); | 158 GrPipelineBuilder::AutoRestoreStencil*); |
159 | 159 |
160 /** | 160 /** |
161 * Adjusts the stencil settings to account for interaction with stencil | 161 * Adjusts the stencil settings to account for interaction with stencil |
162 * clipping. | 162 * clipping. |
163 */ | 163 */ |
164 void adjustStencilParams(GrStencilSettings* settings, | 164 void adjustStencilParams(GrStencilSettings* settings, |
165 StencilClipMode mode, | 165 StencilClipMode mode, |
166 int stencilBitCnt); | 166 int stencilBitCnt); |
167 | 167 |
168 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); | 168 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); |
169 | 169 |
170 static const int kMaxAnalyticElements = 4; | 170 static const int kMaxAnalyticElements = 4; |
171 | 171 |
172 GrDrawTarget* fDrawTarget; // This is our owning draw target. | 172 GrDrawTarget* fDrawTarget; // This is our owning draw target. |
173 StencilClipMode fClipMode; | 173 StencilClipMode fClipMode; |
174 bool fDebugClipBatchToBounds; | 174 bool fDebugClipBatchToBounds; |
175 | 175 |
176 typedef SkNoncopyable INHERITED; | 176 typedef SkNoncopyable INHERITED; |
177 }; | 177 }; |
178 #endif // GrClipMaskManager_DEFINED | 178 #endif // GrClipMaskManager_DEFINED |
OLD | NEW |