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

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

Issue 712223002: Combine similar DrawPaths calls in GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrClipMaskManager.h ('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(GrGpu*, const GrOptDrawState*) = 0; 113 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*) = 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(GrGpu*, const GrOptDrawState*); 132 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
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(GrGpu*, const GrOptDrawState*); 147 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
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(GrGpu*, const GrOptDrawState*); 161 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
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)); }
176 float* transforms() { return reinterpret_cast<float*>(&this->indices()[f Count]); }
177 175
178 virtual void execute(GrGpu*, const GrOptDrawState*); 176 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
179 177
178 int fIndicesLocation;
180 size_t fCount; 179 size_t fCount;
180 int fTransformsLocation;
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(GrGpu*, const GrOptDrawState*); 196 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
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(GrGpu*, const GrOptDrawState*); 212 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
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(GrGpu*, const GrOptDrawState*); 227 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
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(GrGpu*, const GrOptDrawState*); 240 virtual void execute(GrInOrderDrawBuffer*, const GrOptDrawState*);
241 241
242 GrDrawState fState; 242 GrDrawState fState;
243 GrGpu::DrawType fDrawType; 243 GrGpu::DrawType fDrawType;
244 GrDeviceCoordTexture fDstCopy; 244 GrDeviceCoordTexture fDstCopy;
245 }; 245 };
246 246
247 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. 247 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double.
248 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; 248 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer;
249 249
250 // overrides from GrDrawTarget 250 // overrides from GrDrawTarget
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // We lazily record clip changes in order to skip clips that have no effect. 294 // We lazily record clip changes in order to skip clips that have no effect.
295 void recordClipIfNecessary(); 295 void recordClipIfNecessary();
296 // Records any trace markers for a command after adding it to the buffer. 296 // Records any trace markers for a command after adding it to the buffer.
297 void recordTraceMarkersIfNecessary(); 297 void recordTraceMarkersIfNecessary();
298 298
299 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; } 299 virtual bool isIssued(uint32_t drawID) { return drawID != fDrawID; }
300 300
301 // TODO: Use a single allocator for commands and records 301 // TODO: Use a single allocator for commands and records
302 enum { 302 enum {
303 kCmdBufferInitialSizeInBytes = 8 * 1024, 303 kCmdBufferInitialSizeInBytes = 8 * 1024,
304 kPathIdxBufferMinReserve = 64,
305 kPathXformBufferMinReserve = 2 * kPathIdxBufferMinReserve,
304 kGeoPoolStatePreAllocCnt = 4, 306 kGeoPoolStatePreAllocCnt = 4,
305 }; 307 };
306 308
307 CmdBuffer fCmdBuffer; 309 CmdBuffer fCmdBuffer;
308 GrDrawState* fLastState; 310 GrDrawState* fLastState;
309 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers; 311 SkTArray<GrTraceMarkerSet, false> fGpuCmdMarkers;
310 GrGpu* fDstGpu; 312 GrGpu* fDstGpu;
311 GrVertexBufferAllocPool& fVertexPool; 313 GrVertexBufferAllocPool& fVertexPool;
312 GrIndexBufferAllocPool& fIndexPool; 314 GrIndexBufferAllocPool& fIndexPool;
315 SkTDArray<uint32_t> fPathIndexBuffer;
316 SkTDArray<float> fPathTransformBuffer;
313 317
314 struct GeometryPoolState { 318 struct GeometryPoolState {
315 const GrVertexBuffer* fPoolVertexBuffer; 319 const GrVertexBuffer* fPoolVertexBuffer;
316 int fPoolStartVertex; 320 int fPoolStartVertex;
317 const GrIndexBuffer* fPoolIndexBuffer; 321 const GrIndexBuffer* fPoolIndexBuffer;
318 int fPoolStartIndex; 322 int fPoolStartIndex;
319 // caller may conservatively over reserve vertices / indices. 323 // caller may conservatively over reserve vertices / indices.
320 // we release unused space back to allocator if possible 324 // we release unused space back to allocator if possible
321 // can only do this if there isn't an intervening pushGeometrySource() 325 // can only do this if there isn't an intervening pushGeometrySource()
322 size_t fUsedPoolVertexBytes; 326 size_t fUsedPoolVertexBytes;
323 size_t fUsedPoolIndexBytes; 327 size_t fUsedPoolIndexBytes;
324 }; 328 };
325 329
326 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateS tack; 330 typedef SkSTArray<kGeoPoolStatePreAllocCnt, GeometryPoolState> GeoPoolStateS tack;
327 331
328 GeoPoolStateStack fGeoPoolStateStack; 332 GeoPoolStateStack fGeoPoolStateStack;
329 bool fFlushing; 333 bool fFlushing;
330 uint32_t fDrawID; 334 uint32_t fDrawID;
331 335
332 typedef GrClipTarget INHERITED; 336 typedef GrClipTarget INHERITED;
333 }; 337 };
334 338
335 #endif 339 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrClipMaskManager.h ('k') | src/gpu/GrInOrderDrawBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698