OLD | NEW |
---|---|
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
181 SkIPoint fDstPoint; | 181 SkIPoint fDstPoint; |
182 SkIRect fSrcRect; | 182 SkIRect fSrcRect; |
183 | 183 |
184 private: | 184 private: |
185 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; | 185 GrPendingIOResource<GrSurface, kWrite_GrIOType> fDst; |
186 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; | 186 GrPendingIOResource<GrSurface, kRead_GrIOType> fSrc; |
187 }; | 187 }; |
188 | 188 |
189 // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed | 189 // TODO: rename to SetPipeline once pp, batch tracker, and desc are removed |
190 struct SetState : public Cmd { | 190 struct SetState : public Cmd { |
191 // TODO get rid of the prim proc version of this when we use batch every where | 191 // TODO get rid of the prim proc parameter when we use batch everywhere |
192 SetState(const GrPipelineBuilder& pipelineBuilder, const GrPrimitiveProc essor* primProc, | 192 SetState(const GrPrimitiveProcessor* primProc = NULL) |
193 const GrDrawTargetCaps& caps, | |
194 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC opy) | |
195 : Cmd(kSetState_Cmd) | 193 : Cmd(kSetState_Cmd) |
196 , fPrimitiveProcessor(primProc) | 194 , fPrimitiveProcessor(primProc) {} |
197 , fPipeline(pipelineBuilder, primProc, caps, scissor, dstCopy) {} | |
198 | 195 |
199 SetState(GrBatch* batch, | 196 ~SetState() { |
bsalomon
2015/02/12 21:39:26
one line?
| |
200 const GrPipelineBuilder& pipelineBuilder, | 197 reinterpret_cast<GrPipeline*>(fPipeline.get())->~GrPipeline(); |
201 const GrDrawTargetCaps& caps, | 198 } |
202 const GrScissorState& scissor, const GrDeviceCoordTexture* dstC opy) | 199 |
203 : Cmd(kSetState_Cmd) | 200 GrPipeline* getPipeline() { return reinterpret_cast<GrPipeline*>(fPipeli ne.get()); } |
bsalomon
2015/02/12 21:39:26
pipelineLocation()? comment that this is just for
| |
204 , fPipeline(batch, pipelineBuilder, caps, scissor, dstCopy) {} | 201 const GrPipeline* getPipeline() const { |
202 return reinterpret_cast<const GrPipeline*>(fPipeline.get()); | |
203 } | |
205 | 204 |
206 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; | 205 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
207 | 206 |
208 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor; | 207 typedef GrPendingProgramElement<const GrPrimitiveProcessor> ProgramPrimi tiveProcessor; |
209 ProgramPrimitiveProcessor fPrimitiveProcessor; | 208 ProgramPrimitiveProcessor fPrimitiveProcessor; |
210 const GrPipeline fPipeline; | 209 SkAlignedSStorage<sizeof(GrPipeline)> fPipeline; |
211 GrProgramDesc fDesc; | 210 GrProgramDesc fDesc; |
212 GrBatchTracker fBatchTracker; | 211 GrBatchTracker fBatchTracker; |
213 }; | 212 }; |
214 | 213 |
215 struct DrawBatch : public Cmd { | 214 struct DrawBatch : public Cmd { |
216 DrawBatch(GrBatch* batch) : Cmd(kDrawBatch_Cmd), fBatch(SkRef(batch)) { | 215 DrawBatch(GrBatch* batch) : Cmd(kDrawBatch_Cmd), fBatch(SkRef(batch)) { |
217 SkASSERT(!batch->isUsed()); | 216 SkASSERT(!batch->isUsed()); |
218 } | 217 } |
219 | 218 |
220 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; | 219 void execute(GrInOrderDrawBuffer*, const SetState*) SK_OVERRIDE; |
221 | 220 |
222 // TODO it wouldn't be too hard to let batches allocate in the cmd buffe r | 221 // TODO it wouldn't be too hard to let batches allocate in the cmd buffe r |
223 SkAutoTUnref<GrBatch> fBatch; | 222 SkAutoTUnref<GrBatch> fBatch; |
224 }; | 223 }; |
225 | 224 |
226 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. | 225 typedef void* TCmdAlign; // This wouldn't be enough align if a command used long double. |
227 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; | 226 typedef GrTRecorder<Cmd, TCmdAlign> CmdBuffer; |
228 | 227 |
229 void onReset() SK_OVERRIDE; | 228 void onReset() SK_OVERRIDE; |
230 void onFlush() SK_OVERRIDE; | 229 void onFlush() SK_OVERRIDE; |
231 | 230 |
232 // overrides from GrDrawTarget | 231 // overrides from GrDrawTarget |
233 void onDraw(const GrPipelineBuilder&, | 232 void onDraw(const GrGeometryProcessor*, |
bsalomon
2015/02/12 21:39:26
one line?
| |
234 const GrGeometryProcessor*, | |
235 const DrawInfo&, | 233 const DrawInfo&, |
236 const GrScissorState&) SK_OVERRIDE; | 234 const PipelineInfo&) SK_OVERRIDE; |
237 void onDrawBatch(GrBatch*, | 235 void onDrawBatch(GrBatch*, |
238 const GrPipelineBuilder&, | 236 const PipelineInfo&) SK_OVERRIDE; |
239 const GrScissorState&, | |
240 const SkRect* devBounds) SK_OVERRIDE; | |
241 void onDrawRect(GrPipelineBuilder*, | 237 void onDrawRect(GrPipelineBuilder*, |
242 GrColor, | 238 GrColor, |
243 const SkMatrix& viewMatrix, | 239 const SkMatrix& viewMatrix, |
244 const SkRect& rect, | 240 const SkRect& rect, |
245 const SkRect* localRect, | 241 const SkRect* localRect, |
246 const SkMatrix* localMatrix) SK_OVERRIDE; | 242 const SkMatrix* localMatrix) SK_OVERRIDE; |
247 | 243 |
248 void onStencilPath(const GrPipelineBuilder&, | 244 void onStencilPath(const GrPipelineBuilder&, |
249 const GrPathProcessor*, | 245 const GrPathProcessor*, |
250 const GrPath*, | 246 const GrPath*, |
251 const GrScissorState&, | 247 const GrScissorState&, |
252 const GrStencilSettings&) SK_OVERRIDE; | 248 const GrStencilSettings&) SK_OVERRIDE; |
253 void onDrawPath(const GrPipelineBuilder&, | 249 void onDrawPath(const GrPathProcessor*, |
254 const GrPathProcessor*, | |
255 const GrPath*, | 250 const GrPath*, |
256 const GrScissorState&, | |
257 const GrStencilSettings&, | 251 const GrStencilSettings&, |
258 const SkRect* devBounds) SK_OVERRIDE; | 252 const PipelineInfo&) SK_OVERRIDE; |
259 void onDrawPaths(const GrPipelineBuilder&, | 253 void onDrawPaths(const GrPathProcessor*, |
260 const GrPathProcessor*, | |
261 const GrPathRange*, | 254 const GrPathRange*, |
262 const void* indices, | 255 const void* indices, |
263 PathIndexType, | 256 PathIndexType, |
264 const float transformValues[], | 257 const float transformValues[], |
265 PathTransformType, | 258 PathTransformType, |
266 int count, | 259 int count, |
267 const GrScissorState&, | |
268 const GrStencilSettings&, | 260 const GrStencilSettings&, |
269 const SkRect* devBounds) SK_OVERRIDE; | 261 const PipelineInfo&) SK_OVERRIDE; |
270 void onClear(const SkIRect* rect, | 262 void onClear(const SkIRect* rect, |
271 GrColor color, | 263 GrColor color, |
272 bool canIgnoreRect, | 264 bool canIgnoreRect, |
273 GrRenderTarget* renderTarget) SK_OVERRIDE; | 265 GrRenderTarget* renderTarget) SK_OVERRIDE; |
274 bool onCopySurface(GrSurface* dst, | 266 bool onCopySurface(GrSurface* dst, |
275 GrSurface* src, | 267 GrSurface* src, |
276 const SkIRect& srcRect, | 268 const SkIRect& srcRect, |
277 const SkIPoint& dstPoint) SK_OVERRIDE; | 269 const SkIPoint& dstPoint) SK_OVERRIDE; |
278 | 270 |
279 // Attempts to concat instances from info onto the previous draw. info must represent an | 271 // Attempts to concat instances from info onto the previous draw. info must represent an |
280 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary. | 272 // instanced draw. The caller must have already recorded a new draw state an d clip if necessary. |
281 int concatInstancedDraw(const GrPipelineBuilder&, const DrawInfo&); | 273 int concatInstancedDraw(const DrawInfo&); |
282 | 274 |
283 // Determines whether the current draw operation requires a new GrPipeline a nd if so | 275 // Determines whether the current draw operation requires a new GrPipeline a nd if so |
284 // records it. If the draw can be skipped false is returned and no new GrPip eline is | 276 // records it. If the draw can be skipped false is returned and no new GrPip eline is |
285 // recorded. | 277 // recorded. |
286 // TODO delete the primproc variant when we have batches everywhere | 278 // TODO delete the primproc variant when we have batches everywhere |
287 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(const GrPipelineBuilder& , | 279 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(const GrPrimitiveProce ssor*, |
288 const GrPrimitiveProcess or*, | 280 const PipelineInfo&); |
289 const GrScissorState&, | 281 bool SK_WARN_UNUSED_RESULT setupPipelineAndShouldDraw(GrBatch*, const Pipeli neInfo&); |
290 const SkRect*); | |
291 bool SK_WARN_UNUSED_RESULT recordStateAndShouldDraw(GrBatch*, | |
292 const GrPipelineBuilder& , | |
293 const GrScissorState&, | |
294 const SkRect*); | |
295 | 282 |
296 // We lazily record clip changes in order to skip clips that have no effect. | 283 // We lazily record clip changes in order to skip clips that have no effect. |
297 void recordClipIfNecessary(); | 284 void recordClipIfNecessary(); |
298 // Records any trace markers for a command after adding it to the buffer. | 285 // Records any trace markers for a command after adding it to the buffer. |
299 void recordTraceMarkersIfNecessary(); | 286 void recordTraceMarkersIfNecessary(); |
300 | 287 |
301 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } | 288 bool isIssued(uint32_t drawID) SK_OVERRIDE { return drawID != fDrawID; } |
302 | 289 |
303 GrBatchTarget* getBatchTarget() { return &fBatchTarget; } | 290 GrBatchTarget* getBatchTarget() { return &fBatchTarget; } |
304 | 291 |
(...skipping 22 matching lines...) Expand all Loading... | |
327 fDrawBatch->execute(this, fPrevState); | 314 fDrawBatch->execute(this, fPrevState); |
328 fDrawBatch->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); | 315 fDrawBatch->fBatch->setNumberOfDraws(fBatchTarget.numberOfDraws()); |
329 fDrawBatch = NULL; | 316 fDrawBatch = NULL; |
330 } | 317 } |
331 } | 318 } |
332 | 319 |
333 typedef GrFlushToGpuDrawTarget INHERITED; | 320 typedef GrFlushToGpuDrawTarget INHERITED; |
334 }; | 321 }; |
335 | 322 |
336 #endif | 323 #endif |
OLD | NEW |