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

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

Issue 1962243002: Separate user and raw stencil settings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 | « gyp/gpu.gypi ('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 "GrPipelineBuilder.h" 10 #include "GrPipelineBuilder.h"
11 #include "GrReducedClip.h" 11 #include "GrReducedClip.h"
12 #include "GrStencil.h"
13 #include "GrTexture.h" 12 #include "GrTexture.h"
14 #include "SkClipStack.h" 13 #include "SkClipStack.h"
15 #include "SkDeque.h" 14 #include "SkDeque.h"
16 #include "SkPath.h" 15 #include "SkPath.h"
17 #include "SkRefCnt.h" 16 #include "SkRefCnt.h"
18 #include "SkTLList.h" 17 #include "SkTLList.h"
19 #include "SkTypes.h" 18 #include "SkTypes.h"
20 19
21 class GrDrawTarget; 20 class GrDrawTarget;
22 class GrPathRenderer; 21 class GrPathRenderer;
23 class GrPathRendererChain; 22 class GrPathRendererChain;
24 class GrResourceProvider; 23 class GrResourceProvider;
25 class GrTexture; 24 class GrTexture;
26 class SkPath; 25 class SkPath;
27 26
28 /** 27 /**
29 * 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
30 * 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
31 * 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
32 * to implement clipping. 31 * to implement clipping.
33 */ 32 */
34 class GrAppliedClip : public SkNoncopyable { 33 class GrAppliedClip : public SkNoncopyable {
35 public: 34 public:
36 GrAppliedClip() {} 35 GrAppliedClip() : fHasStencilClip(false) {}
37 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fC lipCoverageFP; } 36 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { return fC lipCoverageFP; }
38 const GrScissorState& scissorState() const { return fScissorState; } 37 const GrScissorState& scissorState() const { return fScissorState; }
38 bool hasStencilClip() const { return fHasStencilClip; }
39 39
40 private: 40 private:
41 SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP; 41 SkAutoTUnref<const GrFragmentProcessor> fClipCoverageFP;
42 GrScissorState fScissorState; 42 GrScissorState fScissorState;
43 bool fHasStencilClip;
43 friend class GrClipMaskManager; 44 friend class GrClipMaskManager;
44 45
45 typedef SkNoncopyable INHERITED; 46 typedef SkNoncopyable INHERITED;
46 }; 47 };
47 48
48 /** 49 /**
49 * The clip mask creator handles the generation of the clip mask. If anti 50 * 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 51 * 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 52 * (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 53 * 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 54 * 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. 55 * cases scissoring is used to bound the range of the clip mask.
55 */ 56 */
56 class GrClipMaskManager : SkNoncopyable { 57 class GrClipMaskManager : SkNoncopyable {
57 public: 58 public:
58 GrClipMaskManager(GrDrawTarget* owner, bool debugClipBatchToBounds); 59 GrClipMaskManager(GrDrawTarget* owner, bool debugClipBatchToBounds);
59 60
60 /** 61 /**
61 * Creates a clip mask if necessary as a stencil buffer or alpha texture 62 * 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 63 * 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 64 * 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 65 * clipping.
65 * clip. devBounds is optional but can help optimize clipping.
66 */ 66 */
67 bool setupClipping(const GrPipelineBuilder&, 67 bool setupClipping(const GrPipelineBuilder&, const SkRect* devBounds, GrAppl iedClip*);
68 GrPipelineBuilder::AutoRestoreStencil*,
69 const SkRect* devBounds,
70 GrAppliedClip*);
71 68
72 bool setupScissorClip(const GrPipelineBuilder& pipelineBuilder, 69 bool setupScissorClip(const GrPipelineBuilder& pipelineBuilder,
73 GrPipelineBuilder::AutoRestoreStencil* ars,
74 const SkIRect& scissor, 70 const SkIRect& scissor,
75 const SkRect* devBounds, 71 const SkRect* devBounds,
76 GrAppliedClip* out); 72 GrAppliedClip* out);
77 73
78 void adjustPathStencilParams(const GrStencilAttachment*, GrStencilSettings*) ;
79
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 hasUserStencilSettings,
87 const GrRenderTarget* rt, 81 const GrRenderTarget* rt,
88 const SkMatrix& viewMatrix, 82 const SkMatrix& viewMatrix,
89 const SkClipStack::Element* element, 83 const SkClipStack::Element* element,
90 GrPathRenderer** prOut, 84 GrPathRenderer** prOut,
91 bool needsStencil); 85 bool needsStencil);
92 static GrPathRenderer* GetPathRenderer(GrContext* context, 86 static GrPathRenderer* GetPathRenderer(GrContext* context,
93 GrTexture* texture, 87 GrTexture* texture,
94 const SkMatrix& viewMatrix, 88 const SkMatrix& viewMatrix,
95 const SkClipStack::Element* element); 89 const SkClipStack::Element* element);
96 90
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const GrReducedClip::ElementList& e lements, 137 const GrReducedClip::ElementList& e lements,
144 const SkVector& clipToMaskOffset, 138 const SkVector& clipToMaskOffset,
145 const SkIRect& clipSpaceIBounds); 139 const SkIRect& clipSpaceIBounds);
146 140
147 static bool UseSWOnlyPath(GrContext*, 141 static bool UseSWOnlyPath(GrContext*,
148 const GrPipelineBuilder&, 142 const GrPipelineBuilder&,
149 const GrRenderTarget* rt, 143 const GrRenderTarget* rt,
150 const SkVector& clipToMaskOffset, 144 const SkVector& clipToMaskOffset,
151 const GrReducedClip::ElementList& elements); 145 const GrReducedClip::ElementList& elements);
152 146
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); 147 GrTexture* createCachedMask(int width, int height, const GrUniqueKey& key, b ool renderTarget);
169 148
170 static const int kMaxAnalyticElements = 4; 149 static const int kMaxAnalyticElements = 4;
171 150
172 GrDrawTarget* fDrawTarget; // This is our owning draw target. 151 GrDrawTarget* fDrawTarget; // This is our owning draw target.
173 StencilClipMode fClipMode; 152 StencilClipMode fClipMode;
174 bool fDebugClipBatchToBounds; 153 bool fDebugClipBatchToBounds;
175 154
176 typedef SkNoncopyable INHERITED; 155 typedef SkNoncopyable INHERITED;
177 }; 156 };
178 #endif // GrClipMaskManager_DEFINED 157 #endif // GrClipMaskManager_DEFINED
OLDNEW
« no previous file with comments | « gyp/gpu.gypi ('k') | src/gpu/GrClipMaskManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698