| 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 | |
| 78 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; | 72 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; |
| 79 | 73 |
| 80 private: | 74 private: |
| 81 inline GrContext* getContext(); | 75 inline GrContext* getContext(); |
| 82 inline const GrCaps* caps() const; | 76 inline const GrCaps* caps() const; |
| 83 inline GrResourceProvider* resourceProvider(); | 77 inline GrResourceProvider* resourceProvider(); |
| 84 | 78 |
| 85 static bool PathNeedsSWRenderer(GrContext* context, | 79 static bool PathNeedsSWRenderer(GrContext* context, |
| 86 bool isStencilDisabled, | 80 bool isStencilDisabled, |
| 87 const GrRenderTarget* rt, | 81 const GrRenderTarget* rt, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // Draws the clip into the stencil buffer | 116 // Draws the clip into the stencil buffer |
| 123 bool createStencilClipMask(GrRenderTarget*, | 117 bool createStencilClipMask(GrRenderTarget*, |
| 124 int32_t elementsGenID, | 118 int32_t elementsGenID, |
| 125 GrReducedClip::InitialState initialState, | 119 GrReducedClip::InitialState initialState, |
| 126 const GrReducedClip::ElementList& elements, | 120 const GrReducedClip::ElementList& elements, |
| 127 const SkIRect& clipSpaceIBounds, | 121 const SkIRect& clipSpaceIBounds, |
| 128 const SkIPoint& clipSpaceToStencilOffset); | 122 const SkIPoint& clipSpaceToStencilOffset); |
| 129 | 123 |
| 130 // Creates an alpha mask of the clip. The mask is a rasterization of element
s through the | 124 // Creates an alpha mask of the clip. The mask is a rasterization of element
s through the |
| 131 // rect specified by clipSpaceIBounds. | 125 // rect specified by clipSpaceIBounds. |
| 132 static GrTexture* CreateAlphaClipMask(GrContext*, | 126 GrTexture* createAlphaClipMask(int32_t elementsGenID, |
| 133 int32_t elementsGenID, | 127 GrReducedClip::InitialState initialState, |
| 134 GrReducedClip::InitialState initialSta
te, | 128 const GrReducedClip::ElementList& elements, |
| 135 const GrReducedClip::ElementList& elem
ents, | 129 const SkVector& clipToMaskOffset, |
| 136 const SkVector& clipToMaskOffset, | 130 const SkIRect& clipSpaceIBounds); |
| 137 const SkIRect& clipSpaceIBounds); | |
| 138 | 131 |
| 139 // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the
result texture. | 132 // Similar to createAlphaClipMask but it rasterizes in SW and uploads to the
result texture. |
| 140 static GrTexture* CreateSoftwareClipMask(GrContext*, | 133 GrTexture* createSoftwareClipMask(int32_t elementsGenID, |
| 141 int32_t elementsGenID, | 134 GrReducedClip::InitialState initialState, |
| 142 GrReducedClip::InitialState initial
State, | 135 const GrReducedClip::ElementList& elements
, |
| 143 const GrReducedClip::ElementList& e
lements, | 136 const SkVector& clipToMaskOffset, |
| 144 const SkVector& clipToMaskOffset, | 137 const SkIRect& clipSpaceIBounds); |
| 145 const SkIRect& clipSpaceIBounds); | |
| 146 | 138 |
| 147 static bool UseSWOnlyPath(GrContext*, | 139 bool useSWOnlyPath(const GrPipelineBuilder&, |
| 148 const GrPipelineBuilder&, | 140 const GrRenderTarget* rt, |
| 149 const GrRenderTarget* rt, | 141 const SkVector& clipToMaskOffset, |
| 150 const SkVector& clipToMaskOffset, | 142 const GrReducedClip::ElementList& elements); |
| 151 const GrReducedClip::ElementList& elements); | 143 |
| 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 |