| 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 | 7 |
| 8 #ifndef GrClipMaskManager_DEFINED | 8 #ifndef GrClipMaskManager_DEFINED |
| 9 #define GrClipMaskManager_DEFINED | 9 #define GrClipMaskManager_DEFINED |
| 10 | 10 |
| 11 #include "GrClipMaskCache.h" | 11 #include "GrClipMaskCache.h" |
| 12 #include "GrContext.h" | 12 #include "GrContext.h" |
| 13 #include "GrDrawState.h" | 13 #include "GrDrawState.h" |
| 14 #include "GrDrawTarget.h" | |
| 15 #include "GrReducedClip.h" | 14 #include "GrReducedClip.h" |
| 16 #include "GrStencil.h" | 15 #include "GrStencil.h" |
| 17 #include "GrTexture.h" | 16 #include "GrTexture.h" |
| 18 | 17 |
| 19 #include "SkClipStack.h" | 18 #include "SkClipStack.h" |
| 20 #include "SkDeque.h" | 19 #include "SkDeque.h" |
| 21 #include "SkPath.h" | 20 #include "SkPath.h" |
| 22 #include "SkRefCnt.h" | 21 #include "SkRefCnt.h" |
| 23 #include "SkTLList.h" | 22 #include "SkTLList.h" |
| 24 #include "SkTypes.h" | 23 #include "SkTypes.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 37 * mask can be represented as a rectangle then scissoring is used. In all | 36 * mask can be represented as a rectangle then scissoring is used. In all |
| 38 * cases scissoring is used to bound the range of the clip mask. | 37 * cases scissoring is used to bound the range of the clip mask. |
| 39 */ | 38 */ |
| 40 class GrClipMaskManager : SkNoncopyable { | 39 class GrClipMaskManager : SkNoncopyable { |
| 41 public: | 40 public: |
| 42 GrClipMaskManager() | 41 GrClipMaskManager() |
| 43 : fGpu(NULL) | 42 : fGpu(NULL) |
| 44 , fCurrClipMaskType(kNone_ClipMaskType) { | 43 , fCurrClipMaskType(kNone_ClipMaskType) { |
| 45 } | 44 } |
| 46 | 45 |
| 46 // The state of the scissor is controlled by the clip manager, no one else s
hould set |
| 47 // Scissor state. This should really be on Gpu itself. We should revist th
is when GPU |
| 48 // and drawtarget are separate |
| 49 struct ScissorState { |
| 50 ScissorState() : fEnabled(false) {} |
| 51 void set(const SkIRect& rect) { fRect = rect; fEnabled = true; } |
| 52 bool fEnabled; |
| 53 SkIRect fRect; |
| 54 }; |
| 55 |
| 47 /** | 56 /** |
| 48 * Creates a clip mask if necessary as a stencil buffer or alpha texture | 57 * Creates a clip mask if necessary as a stencil buffer or alpha texture |
| 49 * and sets the GrGpu's scissor and stencil state. If the return is false | 58 * and sets the GrGpu's scissor and stencil state. If the return is false |
| 50 * then the draw can be skipped. The AutoRestoreEffects is initialized by | 59 * then the draw can be skipped. The AutoRestoreEffects is initialized by |
| 51 * the manager when it must install additional effects to implement the | 60 * the manager when it must install additional effects to implement the |
| 52 * clip. devBounds is optional but can help optimize clipping. | 61 * clip. devBounds is optional but can help optimize clipping. |
| 53 */ | 62 */ |
| 54 bool setupClipping(const GrClipData* clipDataIn, | 63 bool setupClipping(const GrClipData* clipDataIn, |
| 55 const SkRect* devBounds, | 64 const SkRect* devBounds, |
| 56 GrDrawState::AutoRestoreEffects*, | 65 GrDrawState::AutoRestoreEffects*, |
| 57 GrDrawState::AutoRestoreStencil*, | 66 GrDrawState::AutoRestoreStencil*, |
| 58 GrDrawTarget::ScissorState* scissorState); | 67 ScissorState* scissorState); |
| 59 | 68 |
| 60 /** | 69 /** |
| 61 * Purge resources to free up memory. TODO: This class shouldn't hold any lo
ng lived refs | 70 * Purge resources to free up memory. TODO: This class shouldn't hold any lo
ng lived refs |
| 62 * which will allow ResourceCache2 to automatically purge anything this clas
s has created. | 71 * which will allow ResourceCache2 to automatically purge anything this clas
s has created. |
| 63 */ | 72 */ |
| 64 void purgeResources(); | 73 void purgeResources(); |
| 65 | 74 |
| 66 bool isClipInStencil() const { | 75 bool isClipInStencil() const { |
| 67 return kStencil_ClipMaskType == fCurrClipMaskType; | 76 return kStencil_ClipMaskType == fCurrClipMaskType; |
| 68 } | 77 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 * clipping. | 193 * clipping. |
| 185 */ | 194 */ |
| 186 void adjustStencilParams(GrStencilSettings* settings, | 195 void adjustStencilParams(GrStencilSettings* settings, |
| 187 StencilClipMode mode, | 196 StencilClipMode mode, |
| 188 int stencilBitCnt); | 197 int stencilBitCnt); |
| 189 | 198 |
| 190 typedef SkNoncopyable INHERITED; | 199 typedef SkNoncopyable INHERITED; |
| 191 }; | 200 }; |
| 192 | 201 |
| 193 #endif // GrClipMaskManager_DEFINED | 202 #endif // GrClipMaskManager_DEFINED |
| OLD | NEW |