| 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 16 matching lines...) Expand all Loading... |
| 27 /** | 27 /** |
| 28 * Produced by GrClipMaskManager. It provides a set of modifications to the draw
ing state that | 28 * 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 | 29 * 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 | 30 * eventually encapsulate all mechanisms for modifying the scissor, shaders, and
stencil state |
| 31 * to implement clipping. | 31 * to implement clipping. |
| 32 */ | 32 */ |
| 33 class GrAppliedClip : public SkNoncopyable { | 33 class GrAppliedClip : public SkNoncopyable { |
| 34 public: | 34 public: |
| 35 GrAppliedClip() {} | 35 GrAppliedClip() {} |
| 36 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fC
lipCoverageFP; } | 36 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fC
lipCoverageFP; } |
| 37 const GrScissorState& scissorState() const { return fScissorState; } |
| 37 | 38 |
| 38 private: | 39 private: |
| 39 SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP; | 40 SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP; |
| 41 GrScissorState fScissorState; |
| 40 friend class GrClipMaskManager; | 42 friend class GrClipMaskManager; |
| 41 | 43 |
| 42 typedef SkNoncopyable INHERITED; | 44 typedef SkNoncopyable INHERITED; |
| 43 }; | 45 }; |
| 44 | 46 |
| 45 /** | 47 /** |
| 46 * The clip mask creator handles the generation of the clip mask. If anti | 48 * The clip mask creator handles the generation of the clip mask. If anti |
| 47 * aliasing is requested it will (in the future) generate a single channel | 49 * aliasing is requested it will (in the future) generate a single channel |
| 48 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit | 50 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit |
| 49 * mask in the stencil buffer. In the non anti-aliasing case, if the clip | 51 * mask in the stencil buffer. In the non anti-aliasing case, if the clip |
| 50 * mask can be represented as a rectangle then scissoring is used. In all | 52 * mask can be represented as a rectangle then scissoring is used. In all |
| 51 * cases scissoring is used to bound the range of the clip mask. | 53 * cases scissoring is used to bound the range of the clip mask. |
| 52 */ | 54 */ |
| 53 class GrClipMaskManager : SkNoncopyable { | 55 class GrClipMaskManager : SkNoncopyable { |
| 54 public: | 56 public: |
| 55 GrClipMaskManager(GrDrawTarget* owner); | 57 GrClipMaskManager(GrDrawTarget* owner); |
| 56 | 58 |
| 57 /** | 59 /** |
| 58 * Creates a clip mask if necessary as a stencil buffer or alpha texture | 60 * Creates a clip mask if necessary as a stencil buffer or alpha texture |
| 59 * and sets the GrGpu's scissor and stencil state. If the return is false | 61 * and sets the GrGpu's scissor and stencil state. If the return is false |
| 60 * then the draw can be skipped. The AutoRestoreEffects is initialized by | 62 * then the draw can be skipped. The AutoRestoreEffects is initialized by |
| 61 * the manager when it must install additional effects to implement the | 63 * the manager when it must install additional effects to implement the |
| 62 * clip. devBounds is optional but can help optimize clipping. | 64 * clip. devBounds is optional but can help optimize clipping. |
| 63 */ | 65 */ |
| 64 bool setupClipping(const GrPipelineBuilder&, | 66 bool setupClipping(const GrPipelineBuilder&, |
| 65 GrPipelineBuilder::AutoRestoreStencil*, | 67 GrPipelineBuilder::AutoRestoreStencil*, |
| 66 GrScissorState*, | |
| 67 const SkRect* devBounds, | 68 const SkRect* devBounds, |
| 68 GrAppliedClip*); | 69 GrAppliedClip*); |
| 69 | 70 |
| 70 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; | 71 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*)
; |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 inline GrContext* getContext(); | 74 inline GrContext* getContext(); |
| 74 | 75 |
| 75 /** | 76 /** |
| 76 * Informs the helper function adjustStencilParams() about how the stencil | 77 * Informs the helper function adjustStencilParams() about how the stencil |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); | 169 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b
ool renderTarget); |
| 169 | 170 |
| 170 static const int kMaxAnalyticElements = 4; | 171 static const int kMaxAnalyticElements = 4; |
| 171 | 172 |
| 172 GrDrawTarget* fDrawTarget; // This is our owning draw target. | 173 GrDrawTarget* fDrawTarget; // This is our owning draw target. |
| 173 StencilClipMode fClipMode; | 174 StencilClipMode fClipMode; |
| 174 | 175 |
| 175 typedef SkNoncopyable INHERITED; | 176 typedef SkNoncopyable INHERITED; |
| 176 }; | 177 }; |
| 177 #endif // GrClipMaskManager_DEFINED | 178 #endif // GrClipMaskManager_DEFINED |
| OLD | NEW |