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 GrTexture; | 24 class GrTexture; |
25 class SkPath; | 25 class SkPath; |
26 | |
robertphillips
2015/10/07 13:06:43
// informative comment ?
| |
27 class GrAppliedClip : public SkNoncopyable { | |
28 public: | |
29 GrAppliedClip() {} | |
30 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fC lipCoverageFP; } | |
31 | |
32 private: | |
33 SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP; | |
34 friend GrClipMaskManager; | |
35 | |
36 typedef SkNoncopyable INHERITED; | |
37 }; | |
38 | |
26 /** | 39 /** |
27 * The clip mask creator handles the generation of the clip mask. If anti | 40 * The clip mask creator handles the generation of the clip mask. If anti |
28 * aliasing is requested it will (in the future) generate a single channel | 41 * aliasing is requested it will (in the future) generate a single channel |
29 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit | 42 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit |
30 * mask in the stencil buffer. In the non anti-aliasing case, if the clip | 43 * mask in the stencil buffer. In the non anti-aliasing case, if the clip |
31 * mask can be represented as a rectangle then scissoring is used. In all | 44 * mask can be represented as a rectangle then scissoring is used. In all |
32 * cases scissoring is used to bound the range of the clip mask. | 45 * cases scissoring is used to bound the range of the clip mask. |
33 */ | 46 */ |
34 class GrClipMaskManager : SkNoncopyable { | 47 class GrClipMaskManager : SkNoncopyable { |
35 public: | 48 public: |
36 GrClipMaskManager(GrDrawTarget* owner); | 49 GrClipMaskManager(GrDrawTarget* owner); |
37 | 50 |
38 /** | 51 /** |
39 * Creates a clip mask if necessary as a stencil buffer or alpha texture | 52 * Creates a clip mask if necessary as a stencil buffer or alpha texture |
40 * and sets the GrGpu's scissor and stencil state. If the return is false | 53 * and sets the GrGpu's scissor and stencil state. If the return is false |
41 * then the draw can be skipped. The AutoRestoreEffects is initialized by | 54 * then the draw can be skipped. The AutoRestoreEffects is initialized by |
42 * the manager when it must install additional effects to implement the | 55 * the manager when it must install additional effects to implement the |
43 * clip. devBounds is optional but can help optimize clipping. | 56 * clip. devBounds is optional but can help optimize clipping. |
44 */ | 57 */ |
45 bool setupClipping(const GrPipelineBuilder&, | 58 bool setupClipping(const GrPipelineBuilder&, |
46 GrPipelineBuilder::AutoRestoreFragmentProcessorState*, | |
47 GrPipelineBuilder::AutoRestoreStencil*, | 59 GrPipelineBuilder::AutoRestoreStencil*, |
48 GrScissorState*, | 60 GrScissorState*, |
49 const SkRect* devBounds); | 61 const SkRect* devBounds, |
62 GrAppliedClip*); | |
50 | 63 |
51 bool isClipInStencil() const { | 64 bool isClipInStencil() const { |
52 return kStencil_ClipMaskType == fCurrClipMaskType; | 65 return kStencil_ClipMaskType == fCurrClipMaskType; |
53 } | 66 } |
54 | 67 |
55 bool isClipInAlpha() const { | 68 bool isClipInAlpha() const { |
56 return kAlpha_ClipMaskType == fCurrClipMaskType; | 69 return kAlpha_ClipMaskType == fCurrClipMaskType; |
57 } | 70 } |
58 | 71 |
59 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*) ; | 72 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*) ; |
(...skipping 10 matching lines...) Expand all Loading... | |
70 kModifyClip_StencilClipMode, | 83 kModifyClip_StencilClipMode, |
71 // Clip against the existing representation of the clip in the high bit | 84 // Clip against the existing representation of the clip in the high bit |
72 // of the stencil buffer. | 85 // of the stencil buffer. |
73 kRespectClip_StencilClipMode, | 86 kRespectClip_StencilClipMode, |
74 // Neither writing to nor clipping against the clip bit. | 87 // Neither writing to nor clipping against the clip bit. |
75 kIgnoreClip_StencilClipMode, | 88 kIgnoreClip_StencilClipMode, |
76 }; | 89 }; |
77 | 90 |
78 // Attempts to install a series of coverage effects to implement the clip. R eturn indicates | 91 // Attempts to install a series of coverage effects to implement the clip. R eturn indicates |
79 // whether the element list was successfully converted to effects. | 92 // whether the element list was successfully converted to effects. |
80 bool installClipEffects(const GrPipelineBuilder&, | 93 const GrFragmentProcessor* getAnalyticClipProcessor(const GrReducedClip::Ele mentList&, |
81 GrPipelineBuilder::AutoRestoreFragmentProcessorState *, | 94 const SkVector& clipOffs et, |
82 const GrReducedClip::ElementList&, | 95 const SkRect* devBounds) ; |
83 const SkVector& clipOffset, | |
84 const SkRect* devBounds); | |
85 | 96 |
86 // Draws the clip into the stencil buffer | 97 // Draws the clip into the stencil buffer |
87 bool createStencilClipMask(GrRenderTarget*, | 98 bool createStencilClipMask(GrRenderTarget*, |
88 int32_t elementsGenID, | 99 int32_t elementsGenID, |
89 GrReducedClip::InitialState initialState, | 100 GrReducedClip::InitialState initialState, |
90 const GrReducedClip::ElementList& elements, | 101 const GrReducedClip::ElementList& elements, |
91 const SkIRect& clipSpaceIBounds, | 102 const SkIRect& clipSpaceIBounds, |
92 const SkIPoint& clipSpaceToStencilOffset); | 103 const SkIPoint& clipSpaceToStencilOffset); |
93 | 104 |
94 // Creates an alpha mask of the clip. The mask is a rasterization of element s through the | 105 // Creates an alpha mask of the clip. The mask is a rasterization of element s through the |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 * We may represent the clip as a mask in the stencil buffer or as an alpha | 168 * We may represent the clip as a mask in the stencil buffer or as an alpha |
158 * texture. It may be neither because the scissor rect suffices or we | 169 * texture. It may be neither because the scissor rect suffices or we |
159 * haven't yet examined the clip. | 170 * haven't yet examined the clip. |
160 */ | 171 */ |
161 enum ClipMaskType { | 172 enum ClipMaskType { |
162 kNone_ClipMaskType, | 173 kNone_ClipMaskType, |
163 kStencil_ClipMaskType, | 174 kStencil_ClipMaskType, |
164 kAlpha_ClipMaskType, | 175 kAlpha_ClipMaskType, |
165 } fCurrClipMaskType; | 176 } fCurrClipMaskType; |
166 | 177 |
178 static const int kMaxAnalyticElements = 4; | |
179 | |
167 GrDrawTarget* fDrawTarget; // This is our owning draw target. | 180 GrDrawTarget* fDrawTarget; // This is our owning draw target. |
168 StencilClipMode fClipMode; | 181 StencilClipMode fClipMode; |
169 | 182 |
170 typedef SkNoncopyable INHERITED; | 183 typedef SkNoncopyable INHERITED; |
171 }; | 184 }; |
172 #endif // GrClipMaskManager_DEFINED | 185 #endif // GrClipMaskManager_DEFINED |
OLD | NEW |