Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: src/gpu/GrClipMaskManager.h

Issue 1144013007: Remove GrContext from GrClipMaskCache (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrClipMaskCache.cpp ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "GrClipMaskCache.h" 10 #include "GrClipMaskCache.h"
11 #include "GrContext.h"
12 #include "GrPipelineBuilder.h" 11 #include "GrPipelineBuilder.h"
13 #include "GrReducedClip.h" 12 #include "GrReducedClip.h"
14 #include "GrStencil.h" 13 #include "GrStencil.h"
15 #include "GrTexture.h" 14 #include "GrTexture.h"
16 #include "SkClipStack.h" 15 #include "SkClipStack.h"
17 #include "SkDeque.h" 16 #include "SkDeque.h"
18 #include "SkPath.h" 17 #include "SkPath.h"
19 #include "SkRefCnt.h" 18 #include "SkRefCnt.h"
20 #include "SkTLList.h" 19 #include "SkTLList.h"
21 #include "SkTypes.h" 20 #include "SkTypes.h"
22 21
23 class GrClipTarget; 22 class GrClipTarget;
24 class GrPathRenderer; 23 class GrPathRenderer;
25 class GrPathRendererChain; 24 class GrPathRendererChain;
26 class GrTexture; 25 class GrTexture;
27 class SkPath; 26 class SkPath;
28 /** 27 /**
29 * The clip mask creator handles the generation of the clip mask. If anti 28 * The clip mask creator handles the generation of the clip mask. If anti
30 * aliasing is requested it will (in the future) generate a single channel 29 * aliasing is requested it will (in the future) generate a single channel
31 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit 30 * (8bit) mask. If no anti aliasing is requested it will generate a 1-bit
32 * mask in the stencil buffer. In the non anti-aliasing case, if the clip 31 * mask in the stencil buffer. In the non anti-aliasing case, if the clip
33 * mask can be represented as a rectangle then scissoring is used. In all 32 * mask can be represented as a rectangle then scissoring is used. In all
34 * cases scissoring is used to bound the range of the clip mask. 33 * cases scissoring is used to bound the range of the clip mask.
35 */ 34 */
36 class GrClipMaskManager : SkNoncopyable { 35 class GrClipMaskManager : SkNoncopyable {
37 public: 36 public:
38 GrClipMaskManager() 37 GrClipMaskManager(GrClipTarget* owner);
39 : fCurrClipMaskType(kNone_ClipMaskType)
40 , fClipTarget(NULL)
41 , fClipMode(kIgnoreClip_StencilClipMode) {
42 }
43 38
44 /** 39 /**
45 * Creates a clip mask if necessary as a stencil buffer or alpha texture 40 * Creates a clip mask if necessary as a stencil buffer or alpha texture
46 * and sets the GrGpu's scissor and stencil state. If the return is false 41 * and sets the GrGpu's scissor and stencil state. If the return is false
47 * then the draw can be skipped. The AutoRestoreEffects is initialized by 42 * then the draw can be skipped. The AutoRestoreEffects is initialized by
48 * the manager when it must install additional effects to implement the 43 * the manager when it must install additional effects to implement the
49 * clip. devBounds is optional but can help optimize clipping. 44 * clip. devBounds is optional but can help optimize clipping.
50 */ 45 */
51 bool setupClipping(GrPipelineBuilder*, 46 bool setupClipping(GrPipelineBuilder*,
52 GrPipelineBuilder::AutoRestoreFragmentProcessors*, 47 GrPipelineBuilder::AutoRestoreFragmentProcessors*,
53 GrPipelineBuilder::AutoRestoreStencil*, 48 GrPipelineBuilder::AutoRestoreStencil*,
54 GrScissorState*, 49 GrScissorState*,
55 const SkRect* devBounds); 50 const SkRect* devBounds);
56 51
57 /** 52 /**
58 * Purge resources to free up memory. TODO: This class shouldn't hold any lo ng lived refs 53 * Purge resources to free up memory. TODO: This class shouldn't hold any lo ng lived refs
59 * which will allow Resourcecache to automatically purge anything this class has created. 54 * which will allow Resourcecache to automatically purge anything this class has created.
60 */ 55 */
61 void purgeResources(); 56 void purgeResources();
62 57
63 bool isClipInStencil() const { 58 bool isClipInStencil() const {
64 return kStencil_ClipMaskType == fCurrClipMaskType; 59 return kStencil_ClipMaskType == fCurrClipMaskType;
65 } 60 }
66 61
67 bool isClipInAlpha() const { 62 bool isClipInAlpha() const {
68 return kAlpha_ClipMaskType == fCurrClipMaskType; 63 return kAlpha_ClipMaskType == fCurrClipMaskType;
69 } 64 }
70 65
71 GrContext* getContext() {
72 return fAACache.getContext();
73 }
74
75 void setClipTarget(GrClipTarget*); 66 void setClipTarget(GrClipTarget*);
76 67
77 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*) ; 68 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*) ;
78 69
79 private: 70 private:
71 inline GrContext* getContext();
72
80 /** 73 /**
81 * Informs the helper function adjustStencilParams() about how the stencil 74 * Informs the helper function adjustStencilParams() about how the stencil
82 * buffer clip is being used. 75 * buffer clip is being used.
83 */ 76 */
84 enum StencilClipMode { 77 enum StencilClipMode {
85 // Draw to the clip bit of the stencil buffer 78 // Draw to the clip bit of the stencil buffer
86 kModifyClip_StencilClipMode, 79 kModifyClip_StencilClipMode,
87 // Clip against the existing representation of the clip in the high bit 80 // Clip against the existing representation of the clip in the high bit
88 // of the stencil buffer. 81 // of the stencil buffer.
89 kRespectClip_StencilClipMode, 82 kRespectClip_StencilClipMode,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 * texture. It may be neither because the scissor rect suffices or we 176 * texture. It may be neither because the scissor rect suffices or we
184 * haven't yet examined the clip. 177 * haven't yet examined the clip.
185 */ 178 */
186 enum ClipMaskType { 179 enum ClipMaskType {
187 kNone_ClipMaskType, 180 kNone_ClipMaskType,
188 kStencil_ClipMaskType, 181 kStencil_ClipMaskType,
189 kAlpha_ClipMaskType, 182 kAlpha_ClipMaskType,
190 } fCurrClipMaskType; 183 } fCurrClipMaskType;
191 184
192 GrClipMaskCache fAACache; // cache for the AA path 185 GrClipMaskCache fAACache; // cache for the AA path
193 GrClipTarget* fClipTarget; 186 GrClipTarget* fClipTarget; // This is our owning clip target.
194 StencilClipMode fClipMode; 187 StencilClipMode fClipMode;
195 188
196 typedef SkNoncopyable INHERITED; 189 typedef SkNoncopyable INHERITED;
197 }; 190 };
198 #endif // GrClipMaskManager_DEFINED 191 #endif // GrClipMaskManager_DEFINED
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskCache.cpp ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698