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 #include "GrInOrderDrawBuffer.h" | 8 #include "GrInOrderDrawBuffer.h" |
9 | 9 |
10 #include "GrBufferAllocPool.h" | 10 #include "GrBufferAllocPool.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 for (int i = 0; i < 4; ++i) { | 183 for (int i = 0; i < 4; ++i) { |
184 *vertColor = color; | 184 *vertColor = color; |
185 vertColor = (GrColor*) ((intptr_t) vertColor + vstride); | 185 vertColor = (GrColor*) ((intptr_t) vertColor + vstride); |
186 } | 186 } |
187 | 187 |
188 this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer()); | 188 this->setIndexSourceToBuffer(this->getContext()->getQuadIndexBuffer()); |
189 this->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType,
1, 4, 6, | 189 this->drawIndexedInstances(pipelineBuilder, gp, kTriangles_GrPrimitiveType,
1, 4, 6, |
190 &devBounds); | 190 &devBounds); |
191 } | 191 } |
192 | 192 |
193 int GrInOrderDrawBuffer::concatInstancedDraw(const GrPipelineBuilder& pipelineBu
ilder, | 193 int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) { |
194 const DrawInfo& info) { | |
195 SkASSERT(!fCmdBuffer.empty()); | 194 SkASSERT(!fCmdBuffer.empty()); |
196 SkASSERT(info.isInstanced()); | 195 SkASSERT(info.isInstanced()); |
197 | 196 |
198 const GeometrySrcState& geomSrc = this->getGeomSrc(); | 197 const GeometrySrcState& geomSrc = this->getGeomSrc(); |
199 | 198 |
200 // we only attempt to concat the case when reserved verts are used with a cl
ient-specified index | 199 // we only attempt to concat the case when reserved verts are used with a cl
ient-specified index |
201 // buffer. To make this work with client-specified VBs we'd need to know if
the VB was updated | 200 // buffer. To make this work with client-specified VBs we'd need to know if
the VB was updated |
202 // between draws. | 201 // between draws. |
203 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || | 202 if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || |
204 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { | 203 kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 fGpuCmdMarkers.back().addSet(this->getActiveTraceMarkers()); | 236 fGpuCmdMarkers.back().addSet(this->getActiveTraceMarkers()); |
238 } else { | 237 } else { |
239 fGpuCmdMarkers.push_back(this->getActiveTraceMarkers()); | 238 fGpuCmdMarkers.push_back(this->getActiveTraceMarkers()); |
240 draw->fType = add_trace_bit(draw->fType); | 239 draw->fType = add_trace_bit(draw->fType); |
241 } | 240 } |
242 } | 241 } |
243 | 242 |
244 return instancesToConcat; | 243 return instancesToConcat; |
245 } | 244 } |
246 | 245 |
247 void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder, | 246 void GrInOrderDrawBuffer::onDraw(const GrGeometryProcessor* gp, |
248 const GrGeometryProcessor* gp, | |
249 const DrawInfo& info, | 247 const DrawInfo& info, |
250 const GrScissorState& scissorState) { | 248 const PipelineInfo& pipelineInfo) { |
251 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); | 249 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); |
252 this->closeBatch(); | 250 this->closeBatch(); |
253 | 251 |
254 if (!this->recordStateAndShouldDraw(pipelineBuilder, gp, scissorState, info.
getDevBounds())) { | 252 if (!this->setupPipelineAndShouldDraw(gp, pipelineInfo)) { |
255 return; | 253 return; |
256 } | 254 } |
257 | 255 |
258 Draw* draw; | 256 Draw* draw; |
259 if (info.isInstanced()) { | 257 if (info.isInstanced()) { |
260 int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info)
; | 258 int instancesConcated = this->concatInstancedDraw(info); |
261 if (info.instanceCount() > instancesConcated) { | 259 if (info.instanceCount() > instancesConcated) { |
262 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 260 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
263 draw->fInfo.adjustInstanceCount(-instancesConcated); | 261 draw->fInfo.adjustInstanceCount(-instancesConcated); |
264 } else { | 262 } else { |
265 return; | 263 return; |
266 } | 264 } |
267 } else { | 265 } else { |
268 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 266 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
269 } | 267 } |
270 this->recordTraceMarkersIfNecessary(); | 268 this->recordTraceMarkersIfNecessary(); |
271 } | 269 } |
272 | 270 |
273 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch, | 271 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch, |
274 const GrPipelineBuilder& pipelineBuilder, | 272 const PipelineInfo& pipelineInfo) { |
275 const GrScissorState& scissorState, | 273 if (!this->setupPipelineAndShouldDraw(batch, pipelineInfo)) { |
276 const SkRect* devBounds) { | |
277 if (!this->recordStateAndShouldDraw(batch, pipelineBuilder, scissorState, de
vBounds)) { | |
278 return; | 274 return; |
279 } | 275 } |
280 | 276 |
281 // Check if there is a Batch Draw we can batch with | 277 // Check if there is a Batch Draw we can batch with |
282 if (kDrawBatch_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) { | 278 if (kDrawBatch_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) { |
283 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch)); | 279 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch)); |
284 return; | 280 return; |
285 } | 281 } |
286 | 282 |
287 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back()); | 283 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back()); |
(...skipping 15 matching lines...) Expand all Loading... |
303 | 299 |
304 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, | 300 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, |
305 (path, pipelineBuilder.getRenderT
arget())); | 301 (path, pipelineBuilder.getRenderT
arget())); |
306 sp->fScissor = scissorState; | 302 sp->fScissor = scissorState; |
307 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); | 303 sp->fUseHWAA = pipelineBuilder.isHWAntialias(); |
308 sp->fViewMatrix = pathProc->viewMatrix(); | 304 sp->fViewMatrix = pathProc->viewMatrix(); |
309 sp->fStencil = stencilSettings; | 305 sp->fStencil = stencilSettings; |
310 this->recordTraceMarkersIfNecessary(); | 306 this->recordTraceMarkersIfNecessary(); |
311 } | 307 } |
312 | 308 |
313 void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder, | 309 void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc, |
314 const GrPathProcessor* pathProc, | |
315 const GrPath* path, | 310 const GrPath* path, |
316 const GrScissorState& scissorState, | |
317 const GrStencilSettings& stencilSettings, | 311 const GrStencilSettings& stencilSettings, |
318 const SkRect* devBounds) { | 312 const PipelineInfo& pipelineInfo) { |
319 this->closeBatch(); | 313 this->closeBatch(); |
320 | 314 |
321 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover
ing? | 315 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover
ing? |
322 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState,
devBounds)) { | 316 if (!this->setupPipelineAndShouldDraw(pathProc, pipelineInfo)) { |
323 return; | 317 return; |
324 } | 318 } |
325 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); | 319 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
326 dp->fStencilSettings = stencilSettings; | 320 dp->fStencilSettings = stencilSettings; |
327 this->recordTraceMarkersIfNecessary(); | 321 this->recordTraceMarkersIfNecessary(); |
328 } | 322 } |
329 | 323 |
330 void GrInOrderDrawBuffer::onDrawPaths(const GrPipelineBuilder& pipelineBuilder, | 324 void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc, |
331 const GrPathProcessor* pathProc, | |
332 const GrPathRange* pathRange, | 325 const GrPathRange* pathRange, |
333 const void* indices, | 326 const void* indices, |
334 PathIndexType indexType, | 327 PathIndexType indexType, |
335 const float transformValues[], | 328 const float transformValues[], |
336 PathTransformType transformType, | 329 PathTransformType transformType, |
337 int count, | 330 int count, |
338 const GrScissorState& scissorState, | |
339 const GrStencilSettings& stencilSettings, | 331 const GrStencilSettings& stencilSettings, |
340 const SkRect* devBounds) { | 332 const PipelineInfo& pipelineInfo) { |
341 SkASSERT(pathRange); | 333 SkASSERT(pathRange); |
342 SkASSERT(indices); | 334 SkASSERT(indices); |
343 SkASSERT(transformValues); | 335 SkASSERT(transformValues); |
344 this->closeBatch(); | 336 this->closeBatch(); |
345 | 337 |
346 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState,
devBounds)) { | 338 if (!this->setupPipelineAndShouldDraw(pathProc, pipelineInfo)) { |
347 return; | 339 return; |
348 } | 340 } |
349 | 341 |
350 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); | 342 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); |
351 if (int misalign = fPathIndexBuffer.count() % indexBytes) { | 343 if (int misalign = fPathIndexBuffer.count() % indexBytes) { |
352 // Add padding to the index buffer so the indices are aligned properly. | 344 // Add padding to the index buffer so the indices are aligned properly. |
353 fPathIndexBuffer.append(indexBytes - misalign); | 345 fPathIndexBuffer.append(indexBytes - misalign); |
354 } | 346 } |
355 | 347 |
356 char* savedIndices = fPathIndexBuffer.append(count * indexBytes, | 348 char* savedIndices = fPathIndexBuffer.append(count * indexBytes, |
357 reinterpret_cast<const char*>(i
ndices)); | 349 reinterpret_cast<const char*>(i
ndices)); |
358 float* savedTransforms = fPathTransformBuffer.append( | 350 float* savedTransforms = fPathTransformBuffer.append( |
359 count * GrPathRendering::PathTransformSize(tran
sformType), | 351 count * GrPathRendering::PathTransformSize(tran
sformType), |
360 transformValues); | 352 transformValues); |
361 | 353 |
362 if (kDrawPaths_Cmd == strip_trace_bit(fCmdBuffer.back().fType)) { | 354 if (kDrawPaths_Cmd == strip_trace_bit(fCmdBuffer.back().fType)) { |
363 // The previous command was also DrawPaths. Try to collapse this call in
to the one | 355 // The previous command was also DrawPaths. Try to collapse this call in
to the one |
364 // before. Note that stenciling all the paths at once, then covering, ma
y not be | 356 // before. Note that stenciling all the paths at once, then covering, ma
y not be |
365 // equivalent to two separate draw calls if there is overlap. Blending w
on't work, | 357 // equivalent to two separate draw calls if there is overlap. Blending w
on't work, |
366 // and the combined calls may also cancel each other's winding numbers i
n some | 358 // and the combined calls may also cancel each other's winding numbers i
n some |
367 // places. For now the winding numbers are only an issue if the fill is
even/odd, | 359 // places. For now the winding numbers are only an issue if the fill is
even/odd, |
368 // because DrawPaths is currently only used for glyphs, and glyphs in th
e same | 360 // because DrawPaths is currently only used for glyphs, and glyphs in th
e same |
369 // font tend to all wind in the same direction. | 361 // font tend to all wind in the same direction. |
370 DrawPaths* previous = static_cast<DrawPaths*>(&fCmdBuffer.back()); | 362 DrawPaths* previous = static_cast<DrawPaths*>(&fCmdBuffer.back()); |
371 if (pathRange == previous->pathRange() && | 363 if (pathRange == previous->pathRange() && |
372 indexType == previous->fIndexType && | 364 indexType == previous->fIndexType && |
373 transformType == previous->fTransformType && | 365 transformType == previous->fTransformType && |
374 stencilSettings == previous->fStencilSettings && | 366 stencilSettings == previous->fStencilSettings && |
375 path_fill_type_is_winding(stencilSettings) && | 367 path_fill_type_is_winding(stencilSettings) && |
376 !pipelineBuilder.willBlendWithDst(pathProc)) { | 368 !pipelineInfo.willBlendWithDst(pathProc)) { |
377 // Fold this DrawPaths call into the one previous. | 369 // Fold this DrawPaths call into the one previous. |
378 previous->fCount += count; | 370 previous->fCount += count; |
379 return; | 371 return; |
380 } | 372 } |
381 } | 373 } |
382 | 374 |
383 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange))
; | 375 DrawPaths* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPaths, (pathRange))
; |
384 dp->fIndicesLocation = SkToU32(savedIndices - fPathIndexBuffer.begin()); | 376 dp->fIndicesLocation = SkToU32(savedIndices - fPathIndexBuffer.begin()); |
385 dp->fIndexType = indexType; | 377 dp->fIndexType = indexType; |
386 dp->fTransformsLocation = SkToU32(savedTransforms - fPathTransformBuffer.beg
in()); | 378 dp->fTransformsLocation = SkToU32(savedTransforms - fPathTransformBuffer.beg
in()); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 } | 477 } |
486 | 478 |
487 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType); | 479 bool isSetState = kSetState_Cmd == strip_trace_bit(iter->fType); |
488 if (isSetState) { | 480 if (isSetState) { |
489 SetState* ss = reinterpret_cast<SetState*>(iter.get()); | 481 SetState* ss = reinterpret_cast<SetState*>(iter.get()); |
490 | 482 |
491 // TODO sometimes we have a prim proc, othertimes we have a GrBatch.
Eventually we will | 483 // TODO sometimes we have a prim proc, othertimes we have a GrBatch.
Eventually we will |
492 // only have GrBatch and we can delete this | 484 // only have GrBatch and we can delete this |
493 if (ss->fPrimitiveProcessor) { | 485 if (ss->fPrimitiveProcessor) { |
494 this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProc
essor, | 486 this->getGpu()->buildProgramDesc(&ss->fDesc, *ss->fPrimitiveProc
essor, |
495 ss->fPipeline, | 487 *ss->getPipeline(), |
496 ss->fBatchTracker); | 488 ss->fBatchTracker); |
497 } | 489 } |
498 currentState = ss; | 490 currentState = ss; |
499 } else { | 491 } else { |
500 iter->execute(this, currentState); | 492 iter->execute(this, currentState); |
501 } | 493 } |
502 | 494 |
503 if (cmd_has_trace_marker(iter->fType)) { | 495 if (cmd_has_trace_marker(iter->fType)) { |
504 this->getGpu()->removeGpuTraceMarker(&newMarker); | 496 this->getGpu()->removeGpuTraceMarker(&newMarker); |
505 } | 497 } |
506 } | 498 } |
507 | 499 |
508 // TODO see copious notes about hack | 500 // TODO see copious notes about hack |
509 fBatchTarget.postFlush(); | 501 fBatchTarget.postFlush(); |
510 | 502 |
511 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); | 503 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); |
512 ++fDrawID; | 504 ++fDrawID; |
513 } | 505 } |
514 | 506 |
515 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const SetState
* state) { | 507 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const SetState
* state) { |
516 SkASSERT(state); | 508 SkASSERT(state); |
517 DrawArgs args(state->fPrimitiveProcessor.get(), &state->fPipeline, &state->f
Desc, | 509 DrawArgs args(state->fPrimitiveProcessor.get(), state->getPipeline(), &state
->fDesc, |
518 &state->fBatchTracker); | 510 &state->fBatchTracker); |
519 buf->getGpu()->draw(args, fInfo); | 511 buf->getGpu()->draw(args, fInfo); |
520 } | 512 } |
521 | 513 |
522 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, const S
etState*) { | 514 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, const S
etState*) { |
523 GrGpu::StencilPathState state; | 515 GrGpu::StencilPathState state; |
524 state.fRenderTarget = fRenderTarget.get(); | 516 state.fRenderTarget = fRenderTarget.get(); |
525 state.fScissor = &fScissor; | 517 state.fScissor = &fScissor; |
526 state.fStencil = &fStencil; | 518 state.fStencil = &fStencil; |
527 state.fUseHWAA = fUseHWAA; | 519 state.fUseHWAA = fUseHWAA; |
528 state.fViewMatrix = &fViewMatrix; | 520 state.fViewMatrix = &fViewMatrix; |
529 | 521 |
530 buf->getGpu()->stencilPath(this->path(), state); | 522 buf->getGpu()->stencilPath(this->path(), state); |
531 } | 523 } |
532 | 524 |
533 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, const SetS
tate* state) { | 525 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, const SetS
tate* state) { |
534 SkASSERT(state); | 526 SkASSERT(state); |
535 DrawArgs args(state->fPrimitiveProcessor.get(), &state->fPipeline, &state->f
Desc, | 527 DrawArgs args(state->fPrimitiveProcessor.get(), state->getPipeline(), &state
->fDesc, |
536 &state->fBatchTracker); | 528 &state->fBatchTracker); |
537 buf->getGpu()->drawPath(args, this->path(), fStencilSettings); | 529 buf->getGpu()->drawPath(args, this->path(), fStencilSettings); |
538 } | 530 } |
539 | 531 |
540 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, const Set
State* state) { | 532 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, const Set
State* state) { |
541 SkASSERT(state); | 533 SkASSERT(state); |
542 DrawArgs args(state->fPrimitiveProcessor.get(), &state->fPipeline, &state->f
Desc, | 534 DrawArgs args(state->fPrimitiveProcessor.get(), state->getPipeline(), &state
->fDesc, |
543 &state->fBatchTracker); | 535 &state->fBatchTracker); |
544 buf->getGpu()->drawPaths(args, this->pathRange(), | 536 buf->getGpu()->drawPaths(args, this->pathRange(), |
545 &buf->fPathIndexBuffer[fIndicesLocation], fIndexType
, | 537 &buf->fPathIndexBuffer[fIndicesLocation], fIndexType
, |
546 &buf->fPathTransformBuffer[fTransformsLocation], fTr
ansformType, | 538 &buf->fPathTransformBuffer[fTransformsLocation], fTr
ansformType, |
547 fCount, fStencilSettings); | 539 fCount, fStencilSettings); |
548 } | 540 } |
549 | 541 |
550 void GrInOrderDrawBuffer::DrawBatch::execute(GrInOrderDrawBuffer* buf, const Set
State* state) { | 542 void GrInOrderDrawBuffer::DrawBatch::execute(GrInOrderDrawBuffer* buf, const Set
State* state) { |
551 SkASSERT(state); | 543 SkASSERT(state); |
552 fBatch->generateGeometry(buf->getBatchTarget(), &state->fPipeline); | 544 fBatch->generateGeometry(buf->getBatchTarget(), state->getPipeline()); |
553 } | 545 } |
554 | 546 |
555 void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const SetState
*) {} | 547 void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const SetState
*) {} |
556 | 548 |
557 void GrInOrderDrawBuffer::Clear::execute(GrInOrderDrawBuffer* buf, const SetStat
e*) { | 549 void GrInOrderDrawBuffer::Clear::execute(GrInOrderDrawBuffer* buf, const SetStat
e*) { |
558 if (GrColor_ILLEGAL == fColor) { | 550 if (GrColor_ILLEGAL == fColor) { |
559 buf->getGpu()->discard(this->renderTarget()); | 551 buf->getGpu()->discard(this->renderTarget()); |
560 } else { | 552 } else { |
561 buf->getGpu()->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget(
)); | 553 buf->getGpu()->clear(&fRect, fColor, fCanIgnoreRect, this->renderTarget(
)); |
562 } | 554 } |
(...skipping 15 matching lines...) Expand all Loading... |
578 this->closeBatch(); | 570 this->closeBatch(); |
579 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); | 571 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); |
580 cs->fSrcRect = srcRect; | 572 cs->fSrcRect = srcRect; |
581 cs->fDstPoint = dstPoint; | 573 cs->fDstPoint = dstPoint; |
582 this->recordTraceMarkersIfNecessary(); | 574 this->recordTraceMarkersIfNecessary(); |
583 return true; | 575 return true; |
584 } | 576 } |
585 return false; | 577 return false; |
586 } | 578 } |
587 | 579 |
588 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrPipelineBuilder& pipe
lineBuilder, | 580 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor*
primProc, |
589 const GrPrimitiveProcessor* p
rimProc, | 581 const PipelineInfo& pipelin
eInfo) { |
590 const GrScissorState& scissor
, | 582 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (primProc)); |
591 const SkRect* devBounds) { | 583 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); |
592 GrDeviceCoordTexture dstCopy; | 584 |
593 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) { | 585 if (ss->getPipeline()->mustSkip()) { |
594 return false; | |
595 } | |
596 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, | |
597 (pipelineBuilder, primProc, *this->g
etGpu()->caps(), | |
598 scissor, &dstCopy)); | |
599 if (ss->fPipeline.mustSkip()) { | |
600 fCmdBuffer.pop_back(); | 586 fCmdBuffer.pop_back(); |
601 return false; | 587 return false; |
602 } | 588 } |
603 | 589 |
604 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, | 590 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, |
605 ss->fPipeline.getInitBatchTracker(
)); | 591 ss->getPipeline()->getInitBatchTra
cker()); |
606 | 592 |
607 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && | 593 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && |
608 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, | 594 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, |
609 *ss->fPrimitiveProcessor, | 595 *ss->fPrimitiveProcessor, |
610 ss->fBatchTracker) && | 596 ss->fBatchTracker) && |
611 fPrevState->fPipeline.isEqual(ss->fPipeline)) { | 597 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
612 fCmdBuffer.pop_back(); | 598 fCmdBuffer.pop_back(); |
613 } else { | 599 } else { |
614 fPrevState = ss; | 600 fPrevState = ss; |
615 this->recordTraceMarkersIfNecessary(); | 601 this->recordTraceMarkersIfNecessary(); |
616 } | 602 } |
617 return true; | 603 return true; |
618 } | 604 } |
619 | 605 |
620 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(GrBatch* batch, | 606 bool GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch, |
621 const GrPipelineBuilder& pipe
lineBuilder, | 607 const PipelineInfo& pipelin
eInfo) { |
622 const GrScissorState& scissor
, | 608 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, ()); |
623 const SkRect* devBounds) { | 609 this->setupPipeline(pipelineInfo, ss->pipelineLocation()); |
624 GrDeviceCoordTexture dstCopy; | 610 |
625 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) { | 611 if (ss->getPipeline()->mustSkip()) { |
626 return false; | |
627 } | |
628 // TODO this gets much simpler when we have batches everywhere. | |
629 // If the previous command is also a set state, then we check to see if it h
as a Batch. If so, | |
630 // and we can make the two batches equal, and we can combine the states, the
n we make them equal | |
631 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, | |
632 (batch, pipelineBuilder, *this->getG
pu()->caps(), scissor, | |
633 &dstCopy)); | |
634 if (ss->fPipeline.mustSkip()) { | |
635 fCmdBuffer.pop_back(); | 612 fCmdBuffer.pop_back(); |
636 return false; | 613 return false; |
637 } | 614 } |
638 | 615 |
639 batch->initBatchTracker(ss->fPipeline.getInitBatchTracker()); | 616 batch->initBatchTracker(ss->getPipeline()->getInitBatchTracker()); |
640 | 617 |
641 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && | 618 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && |
642 fPrevState->fPipeline.isEqual(ss->fPipeline)) { | 619 fPrevState->getPipeline()->isEqual(*ss->getPipeline())) { |
643 fCmdBuffer.pop_back(); | 620 fCmdBuffer.pop_back(); |
644 } else { | 621 } else { |
645 this->closeBatch(); | 622 this->closeBatch(); |
646 fPrevState = ss; | 623 fPrevState = ss; |
647 this->recordTraceMarkersIfNecessary(); | 624 this->recordTraceMarkersIfNecessary(); |
648 } | 625 } |
649 return true; | 626 return true; |
650 } | 627 } |
651 | 628 |
652 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 629 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { |
(...skipping 30 matching lines...) Expand all Loading... |
683 int vcount = vertexCount; | 660 int vcount = vertexCount; |
684 int icount = indexCount; | 661 int icount = indexCount; |
685 | 662 |
686 if (!insideGeoPush && | 663 if (!insideGeoPush && |
687 !unreleasedVertexSpace && | 664 !unreleasedVertexSpace && |
688 !unreleasedIndexSpace && | 665 !unreleasedIndexSpace && |
689 this->geometryHints(vertexStride, &vcount, &icount)) { | 666 this->geometryHints(vertexStride, &vcount, &icount)) { |
690 this->flush(); | 667 this->flush(); |
691 } | 668 } |
692 } | 669 } |
OLD | NEW |