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