| 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 15 matching lines...) Expand all Loading... |
| 26 class SkPath; | 26 class SkPath; |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * 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 |
| 30 * 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 |
| 31 * 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 |
| 32 * to implement clipping. | 32 * to implement clipping. |
| 33 */ | 33 */ |
| 34 class GrAppliedClip : public SkNoncopyable { | 34 class GrAppliedClip : public SkNoncopyable { |
| 35 public: | 35 public: |
| 36 GrAppliedClip() {} | 36 GrAppliedClip() : fHasStencilClip(false) {} |
| 37 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fC
lipCoverageFP; } | 37 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fC
lipCoverageFP; } |
| 38 const GrScissorState& scissorState() const { return fScissorState; } | 38 const GrScissorState& scissorState() const { return fScissorState; } |
| 39 bool hasStencilClip() const { return fHasStencilClip; } |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP; | 42 SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP; |
| 42 GrScissorState fScissorState; | 43 GrScissorState fScissorState; |
| 44 bool fHasStencilClip; |
| 43 friend class GrClipMaskManager; | 45 friend class GrClipMaskManager; |
| 44 | 46 |
| 45 typedef SkNoncopyable INHERITED; | 47 typedef SkNoncopyable INHERITED; |
| 46 }; | 48 }; |
| 47 | 49 |
| 48 /** | 50 /** |
| 49 * The clip mask creator handles the generation of the clip mask. If anti | 51 * The clip mask creator handles the generation of the clip mask. If anti |
| 50 * aliasing is requested it will (in the future) generate a single channel | 52 * aliasing is requested it will (in the future) generate a single channel |
| 51 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit | 53 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit |
| 52 * mask in the stencil buffer. In the non anti-aliasing case, if the clip | 54 * mask in the stencil buffer. In the non anti-aliasing case, if the clip |
| 53 * mask can be represented as a rectangle then scissoring is used. In all | 55 * mask can be represented as a rectangle then scissoring is used. In all |
| 54 * cases scissoring is used to bound the range of the clip mask. | 56 * cases scissoring is used to bound the range of the clip mask. |
| 55 */ | 57 */ |
| 56 class GrClipMaskManager : SkNoncopyable { | 58 class GrClipMaskManager : SkNoncopyable { |
| 57 public: | 59 public: |
| 58 GrClipMaskManager(GrDrawTarget* owner, bool debugClipBatchToBounds); | 60 GrClipMaskManager(GrDrawTarget* owner, bool debugClipBatchToBounds); |
| 59 | 61 |
| 60 /** | 62 /** |
| 61 * Creates a clip mask if necessary as a stencil buffer or alpha texture | 63 * Creates a clip mask if necessary as a stencil buffer or alpha texture |
| 62 * and sets the GrGpu's scissor and stencil state. If the return is false | 64 * 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 | 65 * then the draw can be skipped. devBounds is optional but can help optimize |
| 64 * the manager when it must install additional effects to implement the | 66 * clipping. |
| 65 * clip. devBounds is optional but can help optimize clipping. | |
| 66 */ | 67 */ |
| 67 bool setupClipping(const GrPipelineBuilder&, | 68 bool setupClipping(const GrPipelineBuilder&, const SkRect* devBounds, GrAppl
iedClip*); |
| 68 GrPipelineBuilder::AutoRestoreStencil*, | |
| 69 const SkRect* devBounds, | |
| 70 GrAppliedClip*); | |
| 71 | 69 |
| 72 bool setupScissorClip(const GrPipelineBuilder& pipelineBuilder, | 70 bool setupScissorClip(const GrPipelineBuilder& pipelineBuilder, |
| 73 GrPipelineBuilder::AutoRestoreStencil* ars, | |
| 74 const SkIRect& scissor, | 71 const SkIRect& scissor, |
| 75 const SkRect* devBounds, | 72 const SkRect* devBounds, |
| 76 GrAppliedClip* out); | 73 GrAppliedClip* out); |
| 77 | 74 |
| 78 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; | |
| 79 | |
| 80 private: | 75 private: |
| 81 inline GrContext* getContext(); | 76 inline GrContext* getContext(); |
| 82 inline const GrCaps* caps() const; | 77 inline const GrCaps* caps() const; |
| 83 inline GrResourceProvider* resourceProvider(); | 78 inline GrResourceProvider* resourceProvider(); |
| 84 | 79 |
| 85 static bool PathNeedsSWRenderer(GrContext* context, | 80 static bool PathNeedsSWRenderer(GrContext* context, |
| 86 bool isStencilDisabled, | 81 bool hasUserStencilSettings, |
| 87 const GrRenderTarget* rt, | 82 const GrRenderTarget* rt, |
| 88 const SkMatrix& viewMatrix, | 83 const SkMatrix& viewMatrix, |
| 89 const SkClipStack::Element* element, | 84 const SkClipStack::Element* element, |
| 90 GrPathRenderer** prOut, | 85 GrPathRenderer** prOut, |
| 91 bool needsStencil); | 86 bool needsStencil); |
| 92 static GrPathRenderer* GetPathRenderer(GrContext* context, | 87 static GrPathRenderer* GetPathRenderer(GrContext* context, |
| 93 GrTexture* texture, | 88 GrTexture* texture, |
| 94 const SkMatrix& viewMatrix, | 89 const SkMatrix& viewMatrix, |
| 95 const SkClipStack::Element* element); | 90 const SkClipStack::Element* element); |
| 96 | 91 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 const GrReducedClip::ElementList& e
lements, | 138 const GrReducedClip::ElementList& e
lements, |
| 144 const SkVector& clipToMaskOffset, | 139 const SkVector& clipToMaskOffset, |
| 145 const SkIRect& clipSpaceIBounds); | 140 const SkIRect& clipSpaceIBounds); |
| 146 | 141 |
| 147 static bool UseSWOnlyPath(GrContext*, | 142 static bool UseSWOnlyPath(GrContext*, |
| 148 const GrPipelineBuilder&, | 143 const GrPipelineBuilder&, |
| 149 const GrRenderTarget* rt, | 144 const GrRenderTarget* rt, |
| 150 const SkVector& clipToMaskOffset, | 145 const SkVector& clipToMaskOffset, |
| 151 const GrReducedClip::ElementList& elements); | 146 const GrReducedClip::ElementList& elements); |
| 152 | 147 |
| 153 /** | |
| 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. | |
| 156 */ | |
| 157 void setPipelineBuilderStencil(const GrPipelineBuilder&, | |
| 158 GrPipelineBuilder::AutoRestoreStencil*); | |
| 159 | |
| 160 /** | |
| 161 * Adjusts the stencil settings to account for interaction with stencil | |
| 162 * clipping. | |
| 163 */ | |
| 164 void adjustStencilParams(GrStencilSettings* settings, | |
| 165 StencilClipMode mode, | |
| 166 int stencilBitCnt); | |
| 167 | |
| 168 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); | 148 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); |
| 169 | 149 |
| 170 static const int kMaxAnalyticElements = 4; | 150 static const int kMaxAnalyticElements = 4; |
| 171 | 151 |
| 172 GrDrawTarget* fDrawTarget; // This is our owning draw target. | 152 GrDrawTarget* fDrawTarget; // This is our owning draw target. |
| 173 StencilClipMode fClipMode; | 153 StencilClipMode fClipMode; |
| 174 bool fDebugClipBatchToBounds; | 154 bool fDebugClipBatchToBounds; |
| 175 | 155 |
| 176 typedef SkNoncopyable INHERITED; | 156 typedef SkNoncopyable INHERITED; |
| 177 }; | 157 }; |
| 178 #endif // GrClipMaskManager_DEFINED | 158 #endif // GrClipMaskManager_DEFINED |
| OLD | NEW |