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

Side by Side Diff: include/gpu/GrClip.h

Issue 2035823002: Make GrClipMaskManager stateless and push GrPipelineBuilder construction downstack (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address code review comments Created 4 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 | « no previous file | include/gpu/GrDrawContext.h » ('j') | src/gpu/GrClipMaskManager.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2010 Google Inc. 2 * Copyright 2010 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 GrClip_DEFINED 8 #ifndef GrClip_DEFINED
9 #define GrClip_DEFINED 9 #define GrClip_DEFINED
10 10
11 #include "GrFragmentProcessor.h" 11 #include "GrFragmentProcessor.h"
12 #include "GrTypesPriv.h" 12 #include "GrTypesPriv.h"
13 #include "SkClipStack.h" 13 #include "SkClipStack.h"
14 14
15 class GrClipMaskManager; 15 class GrDrawContext;
16 class GrPipelineBuilder; 16 class GrPipelineBuilder;
17 17
18 /** 18 /**
19 * Produced by GrClip. It provides a set of modifications to the drawing state t hat are used to 19 * Produced by GrClip. It provides a set of modifications to the drawing state t hat are used to
20 * create the final GrPipeline for a GrBatch. 20 * create the final GrPipeline for a GrBatch.
21 */ 21 */
22 class GrAppliedClip : public SkNoncopyable { 22 class GrAppliedClip : public SkNoncopyable {
23 public: 23 public:
24 GrAppliedClip() : fHasStencilClip(false) {} 24 GrAppliedClip() : fHasStencilClip(false) {}
25 const GrFragmentProcessor* clipCoverageFragmentProcessor() const { 25 const GrFragmentProcessor* clipCoverageFragmentProcessor() const {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 /** 63 /**
64 * GrClip is an abstract base class for applying a clip. It constructs a clip ma sk if necessary, and 64 * GrClip is an abstract base class for applying a clip. It constructs a clip ma sk if necessary, and
65 * fills out a GrAppliedClip instructing the caller on how to set up the draw st ate. 65 * fills out a GrAppliedClip instructing the caller on how to set up the draw st ate.
66 */ 66 */
67 class GrClip { 67 class GrClip {
68 public: 68 public:
69 virtual bool quickContains(const SkRect&) const = 0; 69 virtual bool quickContains(const SkRect&) const = 0;
70 virtual void getConservativeBounds(int width, int height, SkIRect* devResult , 70 virtual void getConservativeBounds(int width, int height, SkIRect* devResult ,
71 bool* isIntersectionOfRects = nullptr) co nst = 0; 71 bool* isIntersectionOfRects = nullptr) co nst = 0;
72 virtual bool apply(GrClipMaskManager*, const GrPipelineBuilder&, const SkRec t* devBounds, 72 virtual bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
73 GrAppliedClip*) const = 0; 73 const SkRect* devBounds, GrAppliedClip*) const = 0;
74 74
75 virtual ~GrClip() {} 75 virtual ~GrClip() {}
76 }; 76 };
77 77
78 /** 78 /**
79 * Specialized implementation for no clip. 79 * Specialized implementation for no clip.
80 */ 80 */
81 class GrNoClip final : public GrClip { 81 class GrNoClip final : public GrClip {
82 private: 82 private:
83 bool quickContains(const SkRect&) const final { return true; } 83 bool quickContains(const SkRect&) const final { return true; }
84 void getConservativeBounds(int width, int height, SkIRect* devResult, 84 void getConservativeBounds(int width, int height, SkIRect* devResult,
85 bool* isIntersectionOfRects) const final; 85 bool* isIntersectionOfRects) const final;
86 bool apply(GrClipMaskManager*, const GrPipelineBuilder&, 86 bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
87 const SkRect*, GrAppliedClip*) const final { return true; } 87 const SkRect*, GrAppliedClip*) const final { return true; }
88 }; 88 };
89 89
90 /** 90 /**
91 * GrFixedClip is a clip that can be represented by fixed-function hardware. It never modifies the 91 * GrFixedClip is a clip that can be represented by fixed-function hardware. It never modifies the
92 * stencil buffer itself, but can be configured to use whatever clip is already there. 92 * stencil buffer itself, but can be configured to use whatever clip is already there.
93 */ 93 */
94 class GrFixedClip final : public GrClip { 94 class GrFixedClip final : public GrClip {
95 public: 95 public:
96 GrFixedClip() : fHasStencilClip(false) {} 96 GrFixedClip() : fHasStencilClip(false) {}
(...skipping 12 matching lines...) Expand all
109 void enableStencilClip(bool enable) { fHasStencilClip = enable; } 109 void enableStencilClip(bool enable) { fHasStencilClip = enable; }
110 110
111 const GrScissorState& scissorState() const { return fScissorState; } 111 const GrScissorState& scissorState() const { return fScissorState; }
112 bool hasStencilClip() const { return fHasStencilClip; } 112 bool hasStencilClip() const { return fHasStencilClip; }
113 113
114 bool quickContains(const SkRect&) const final; 114 bool quickContains(const SkRect&) const final;
115 void getConservativeBounds(int width, int height, SkIRect* devResult, 115 void getConservativeBounds(int width, int height, SkIRect* devResult,
116 bool* isIntersectionOfRects) const final; 116 bool* isIntersectionOfRects) const final;
117 117
118 private: 118 private:
119 bool apply(GrClipMaskManager*, const GrPipelineBuilder&, 119 bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
120 const SkRect* devBounds, GrAppliedClip* out) const final; 120 const SkRect* devBounds, GrAppliedClip* out) const final;
121 121
122 GrScissorState fScissorState; 122 GrScissorState fScissorState;
123 bool fHasStencilClip; 123 bool fHasStencilClip;
124 }; 124 };
125 125
126 /** 126 /**
127 * GrClipStackClip can apply a generic SkClipStack to the draw state. It may gen erate clip masks or 127 * GrClipStackClip can apply a generic SkClipStack to the draw state. It may gen erate clip masks or
128 * write to the stencil buffer during apply(). 128 * write to the stencil buffer during apply().
129 */ 129 */
130 class GrClipStackClip final : public GrClip { 130 class GrClipStackClip final : public GrClip {
131 public: 131 public:
132 GrClipStackClip(const SkClipStack* stack = nullptr, const SkIPoint* origin = nullptr) { 132 GrClipStackClip(const SkClipStack* stack = nullptr, const SkIPoint* origin = nullptr) {
133 this->reset(stack, origin); 133 this->reset(stack, origin);
134 } 134 }
135 135
136 void reset(const SkClipStack* stack = nullptr, const SkIPoint* origin = null ptr) { 136 void reset(const SkClipStack* stack = nullptr, const SkIPoint* origin = null ptr) {
137 fOrigin = origin ? *origin : SkIPoint::Make(0, 0); 137 fOrigin = origin ? *origin : SkIPoint::Make(0, 0);
138 fStack.reset(SkSafeRef(stack)); 138 fStack.reset(SkSafeRef(stack));
139 } 139 }
140 140
141 const SkIPoint& origin() const { return fOrigin; } 141 const SkIPoint& origin() const { return fOrigin; }
142 const SkClipStack* clipStack() const { return fStack; } 142 const SkClipStack* clipStack() const { return fStack; }
143 143
144 bool quickContains(const SkRect&) const final; 144 bool quickContains(const SkRect&) const final;
145 void getConservativeBounds(int width, int height, SkIRect* devResult, 145 void getConservativeBounds(int width, int height, SkIRect* devResult,
146 bool* isIntersectionOfRects) const final; 146 bool* isIntersectionOfRects) const final;
147 bool apply(GrClipMaskManager*, const GrPipelineBuilder&, 147 bool apply(GrContext*, const GrPipelineBuilder&, GrDrawContext*,
148 const SkRect* devBounds, GrAppliedClip*) const final; 148 const SkRect* devBounds, GrAppliedClip*) const final;
149 149
150 private: 150 private:
151 SkIPoint fOrigin; 151 SkIPoint fOrigin;
152 SkAutoTUnref<const SkClipStack> fStack; 152 SkAutoTUnref<const SkClipStack> fStack;
153 }; 153 };
154 154
155 #endif 155 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrDrawContext.h » ('j') | src/gpu/GrClipMaskManager.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698