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

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

Issue 705593002: Refactor DrawTarget and GPU to be independent (Closed) Base URL: https://skia.googlesource.com/skia.git@early_clip
Patch Set: rebase on master Created 6 years, 1 month 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/GrGpu.cpp ('k') | src/gpu/GrInOrderDrawBuffer.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 2011 Google Inc. 2 * Copyright 2011 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 GrInOrderDrawBuffer_DEFINED 8 #ifndef GrInOrderDrawBuffer_DEFINED
9 #define GrInOrderDrawBuffer_DEFINED 9 #define GrInOrderDrawBuffer_DEFINED
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 kClear_Cmd = 4, 103 kClear_Cmd = 4,
104 kCopySurface_Cmd = 5, 104 kCopySurface_Cmd = 5,
105 kDrawPath_Cmd = 6, 105 kDrawPath_Cmd = 6,
106 kDrawPaths_Cmd = 7, 106 kDrawPaths_Cmd = 7,
107 }; 107 };
108 108
109 struct Cmd : ::SkNoncopyable { 109 struct Cmd : ::SkNoncopyable {
110 Cmd(uint8_t type) : fType(type) {} 110 Cmd(uint8_t type) : fType(type) {}
111 virtual ~Cmd() {} 111 virtual ~Cmd() {}
112 112
113 virtual void execute(GrClipTarget*) = 0; 113 virtual void execute(GrGpu*) = 0;
114 114
115 uint8_t fType; 115 uint8_t fType;
116 }; 116 };
117 117
118 struct Draw : public Cmd { 118 struct Draw : public Cmd {
119 Draw(const DrawInfo& info, 119 Draw(const DrawInfo& info,
120 const ScissorState& scissorState, 120 const ScissorState& scissorState,
121 const GrVertexBuffer* vb, 121 const GrVertexBuffer* vb,
122 const GrIndexBuffer* ib) 122 const GrIndexBuffer* ib)
123 : Cmd(kDraw_Cmd) 123 : Cmd(kDraw_Cmd)
124 , fInfo(info) 124 , fInfo(info)
125 , fScissorState(scissorState) 125 , fScissorState(scissorState)
126 , fVertexBuffer(vb) 126 , fVertexBuffer(vb)
127 , fIndexBuffer(ib) {} 127 , fIndexBuffer(ib) {}
128 128
129 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); } 129 const GrVertexBuffer* vertexBuffer() const { return fVertexBuffer.get(); }
130 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); } 130 const GrIndexBuffer* indexBuffer() const { return fIndexBuffer.get(); }
131 131
132 virtual void execute(GrClipTarget*); 132 virtual void execute(GrGpu*);
133 133
134 DrawInfo fInfo; 134 DrawInfo fInfo;
135 ScissorState fScissorState; 135 ScissorState fScissorState;
136 136
137 private: 137 private:
138 GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuff er; 138 GrPendingIOResource<const GrVertexBuffer, kRead_GrIOType> fVertexBuff er;
139 GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffe r; 139 GrPendingIOResource<const GrIndexBuffer, kRead_GrIOType> fIndexBuffe r;
140 }; 140 };
141 141
142 struct StencilPath : public Cmd { 142 struct StencilPath : public Cmd {
143 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {} 143 StencilPath(const GrPath* path) : Cmd(kStencilPath_Cmd), fPath(path) {}
144 144
145 const GrPath* path() const { return fPath.get(); } 145 const GrPath* path() const { return fPath.get(); }
146 146
147 virtual void execute(GrClipTarget*); 147 virtual void execute(GrGpu*);
148 148
149 ScissorState fScissorState; 149 ScissorState fScissorState;
150 GrStencilSettings fStencilSettings; 150 GrStencilSettings fStencilSettings;
151 151
152 private: 152 private:
153 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; 153 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
154 }; 154 };
155 155
156 struct DrawPath : public Cmd { 156 struct DrawPath : public Cmd {
157 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {} 157 DrawPath(const GrPath* path) : Cmd(kDrawPath_Cmd), fPath(path) {}
158 158
159 const GrPath* path() const { return fPath.get(); } 159 const GrPath* path() const { return fPath.get(); }
160 160
161 virtual void execute(GrClipTarget*); 161 virtual void execute(GrGpu*);
162 162
163 GrDeviceCoordTexture fDstCopy; 163 GrDeviceCoordTexture fDstCopy;
164 ScissorState fScissorState; 164 ScissorState fScissorState;
165 GrStencilSettings fStencilSettings; 165 GrStencilSettings fStencilSettings;
166 166
167 private: 167 private:
168 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath; 168 GrPendingIOResource<const GrPath, kRead_GrIOType> fPath;
169 }; 169 };
170 170
171 struct DrawPaths : public Cmd { 171 struct DrawPaths : public Cmd {
172 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang e(pathRange) {} 172 DrawPaths(const GrPathRange* pathRange) : Cmd(kDrawPaths_Cmd), fPathRang e(pathRange) {}
173 173
174 const GrPathRange* pathRange() const { return fPathRange.get(); } 174 const GrPathRange* pathRange() const { return fPathRange.get(); }
175 uint32_t* indices() { return reinterpret_cast<uint32_t*>(CmdBuffer::GetD ataForItem(this)); } 175 uint32_t* indices() { return reinterpret_cast<uint32_t*>(CmdBuffer::GetD ataForItem(this)); }
176 float* transforms() { return reinterpret_cast<float*>(&this->indices()[f Count]); } 176 float* transforms() { return reinterpret_cast<float*>(&this->indices()[f Count]); }
177 177
178 virtual void execute(GrClipTarget*); 178 virtual void execute(GrGpu*);
179 179
180 size_t fCount; 180 size_t fCount;
181 PathTransformType fTransformsType; 181 PathTransformType fTransformsType;
182 GrDeviceCoordTexture fDstCopy; 182 GrDeviceCoordTexture fDstCopy;
183 ScissorState fScissorState; 183 ScissorState fScissorState;
184 GrStencilSettings fStencilSettings; 184 GrStencilSettings fStencilSettings;
185 185
186 private: 186 private:
187 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange; 187 GrPendingIOResource<const GrPathRange, kRead_GrIOType> fPathRange;
188 }; 188 };
189 189
190 // This is also used to record a discard by setting the color to GrColor_ILL EGAL 190 // This is also used to record a discard by setting the color to GrColor_ILL EGAL
191 struct Clear : public Cmd { 191 struct Clear : public Cmd {
192 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {} 192 Clear(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt) {}
193 193
194 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } 194 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
195 195
196 virtual void execute(GrClipTarget*); 196 virtual void execute(GrGpu*);
197 197
198 SkIRect fRect; 198 SkIRect fRect;
199 GrColor fColor; 199 GrColor fColor;
200 bool fCanIgnoreRect; 200 bool fCanIgnoreRect;
201 201
202 private: 202 private:
203 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; 203 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
204 }; 204 };
205 205
206 // This command is ONLY used by the clip mask manager to clear the stencil c lip bits 206 // This command is ONLY used by the clip mask manager to clear the stencil c lip bits
207 struct ClearStencilClip : public Cmd { 207 struct ClearStencilClip : public Cmd {
208 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt ) {} 208 ClearStencilClip(GrRenderTarget* rt) : Cmd(kClear_Cmd), fRenderTarget(rt ) {}
209 209
210 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); } 210 GrRenderTarget* renderTarget() const { return fRenderTarget.get(); }
211 211
212 virtual void execute(GrClipTarget*); 212 virtual void execute(GrGpu*);
213 213
214 SkIRect fRect; 214 SkIRect fRect;
215 bool fInsideClip; 215 bool fInsideClip;
216 216
217 private: 217 private:
218 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget; 218 GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> fRenderTarget;
219 }; 219 };
220 220
221 struct CopySurface : public Cmd { 221 struct CopySurface : public Cmd {
222 CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDs t(dst), fSrc(src) {} 222 CopySurface(GrSurface* dst, GrSurface* src) : Cmd(kCopySurface_Cmd), fDs t(dst), fSrc(src) {}
223 223
224 GrSurface* dst() const { return fDst.get(); } 224 GrSurface* dst() const { return fDst.get(); }
225 GrSurface* src() const { return fSrc.get(); } 225 GrSurface* src() const { return fSrc.get(); }
226 226
227 virtual void execute(GrClipTarget*); 227 virtual void execute(GrGpu*);
228 228
229 SkIPoint fDstPoint; 229 SkIPoint fDstPoint;
230 SkIRect fSrcRect; 230 SkIRect fSrcRect;
231 231
232 private: 232 private:
233 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; 233 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst;
234 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; 234 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc;
235 }; 235 };
236 236
237 struct SetState : public Cmd { 237 struct SetState : public Cmd {
238 SetState(const GrDrawState& state) : Cmd(kSetState_Cmd), fState(state) { } 238 SetState(const GrDrawState& state) : Cmd(kSetState_Cmd), fState(state) { }
239 239
240 virtual void execute(GrClipTarget*); 240 virtual void execute(GrGpu*);
241 241
242 GrDrawState fState; 242 GrDrawState fState;
243 }; 243 };
244 244
245 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. 245 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
246 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; 246 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
247 247
248 // overrides from GrDrawTarget 248 // overrides from GrDrawTarget
249 virtual void onDraw(const DrawInfo&, const GrClipMaskManager::ScissorState&) SK_OVERRIDE; 249 virtual void onDraw(const DrawInfo&, const GrClipMaskManager::ScissorState&) SK_OVERRIDE;
250 virtual void onDrawRect(const SkRect& rect, 250 virtual void onDrawRect(const SkRect& rect,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 301
302 // TODO: Use a single allocator for commands and records 302 // TODO: Use a single allocator for commands and records
303 enum { 303 enum {
304 kCmdBufferInitialSizeInBytes = 64 * 1024, 304 kCmdBufferInitialSizeInBytes = 64 * 1024,
305 kGeoPoolStatePreAllocCnt = 4, 305 kGeoPoolStatePreAllocCnt = 4,
306 }; 306 };
307 307
308 CmdBuffer fCmdBuffer; 308 CmdBuffer fCmdBuffer;
309 GrDrawState* fLastState; 309 GrDrawState* fLastState;
310 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; 310 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers;
311 GrClipTarget* fDstGpu; 311 GrGpu* fDstGpu;
312 GrVertexBufferAllocPool& fVertexPool; 312 GrVertexBufferAllocPool& fVertexPool;
313 GrIndexBufferAllocPool& fIndexPool; 313 GrIndexBufferAllocPool& fIndexPool;
314 314
315 struct GeometryPoolState { 315 struct GeometryPoolState {
316 const GrVertexBuffer* fPoolVertexBuffer; 316 const GrVertexBuffer* fPoolVertexBuffer;
317 int fPoolStartVertex; 317 int fPoolStartVertex;
318 const GrIndexBuffer* fPoolIndexBuffer; 318 const GrIndexBuffer* fPoolIndexBuffer;
319 int fPoolStartIndex; 319 int fPoolStartIndex;
320 // caller may conservatively over reserve vertices / indices. 320 // caller may conservatively over reserve vertices / indices.
321 // we release unused space back to allocator if possible 321 // we release unused space back to allocator if possible
322 // can only do this if there isn't an intervening pushGeometrySource() 322 // can only do this if there isn't an intervening pushGeometrySource()
323 size_t fUsedPoolVertexBytes; 323 size_t fUsedPoolVertexBytes;
324 size_t fUsedPoolIndexBytes; 324 size_t fUsedPoolIndexBytes;
325 }; 325 };
326 326
327 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateS tack; 327 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateS tack;
328 328
329 GeoPoolStateStack fGeoPoolStateStack; 329 GeoPoolStateStack fGeoPoolStateStack;
330 bool fFlushing; 330 bool fFlushing;
331 uint32_t fDrawID; 331 uint32_t fDrawID;
332 332
333 typedef GrClipTarget INHERITED; 333 typedef GrClipTarget INHERITED;
334 }; 334 };
335 335
336 #endif 336 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698