Chromium Code Reviews| 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 "GrDefaultGeoProcFactory.h" | 10 #include "GrDefaultGeoProcFactory.h" |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 draw->fType = add_trace_bit(draw->fType); | 215 draw->fType = add_trace_bit(draw->fType); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 return instancesToConcat; | 219 return instancesToConcat; |
| 220 } | 220 } |
| 221 | 221 |
| 222 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, | 222 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, |
| 223 const GrGeometryProcessor* gp, | 223 const GrGeometryProcessor* gp, |
| 224 const DrawInfo& info, | 224 const DrawInfo& info, |
| 225 const ScissorState& scissorState, | 225 const GrScissorState& scissorState, |
| 226 const GrDeviceCoordTexture* dstCopy) { | 226 const GrDeviceCoordTexture* dstCopy) { |
| 227 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); | 227 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); |
| 228 | 228 |
| 229 if (!this->recordStateAndShouldDraw(ds, gp, NULL, | 229 if (!this->recordStateAndShouldDraw(ds, gp, NULL, |
| 230 GrGpu::PrimTypeToDrawType(info.primitive Type()), | 230 GrGpu::PrimTypeToDrawType(info.primitive Type()), |
| 231 scissorState, dstCopy)) { | 231 scissorState, dstCopy)) { |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 | 234 |
| 235 Draw* draw; | 235 Draw* draw; |
| 236 if (info.isInstanced()) { | 236 if (info.isInstanced()) { |
| 237 int instancesConcated = this->concatInstancedDraw(ds, info); | 237 int instancesConcated = this->concatInstancedDraw(ds, info); |
| 238 if (info.instanceCount() > instancesConcated) { | 238 if (info.instanceCount() > instancesConcated) { |
| 239 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 239 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
| 240 draw->fInfo.adjustInstanceCount(-instancesConcated); | 240 draw->fInfo.adjustInstanceCount(-instancesConcated); |
| 241 } else { | 241 } else { |
| 242 return; | 242 return; |
| 243 } | 243 } |
| 244 } else { | 244 } else { |
| 245 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 245 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
| 246 } | 246 } |
| 247 this->recordTraceMarkersIfNecessary(); | 247 this->recordTraceMarkersIfNecessary(); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds, | 250 void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds, |
| 251 const GrPathProcessor* pathProc, | 251 const GrPathProcessor* pathProc, |
| 252 const GrPath* path, | 252 const GrPath* path, |
| 253 const GrClipMaskManager::ScissorState& s cissorState, | 253 const GrScissorState& scissorState, |
| 254 const GrStencilSettings& stencilSettings ) { | 254 const GrStencilSettings& stencilSettings ) { |
| 255 // Only compare the subset of GrDrawState relevant to path stenciling? | 255 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, |
| 256 if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kStencilPath_ DrawType, | 256 (path, ds.getRenderTarget())); |
| 257 scissorState, NULL)) { | 257 sp->fScissor = scissorState; |
| 258 return; | 258 sp->fUseHWAA = ds.isHWAntialias(); |
| 259 } | 259 sp->fViewMatrix = ds.getViewMatrix(); |
| 260 StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, (path)); | 260 sp->fStencil = stencilSettings; |
| 261 sp->fStencilSettings = stencilSettings; | |
| 262 this->recordTraceMarkersIfNecessary(); | 261 this->recordTraceMarkersIfNecessary(); |
| 263 } | 262 } |
| 264 | 263 |
| 265 void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, | 264 void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, |
| 266 const GrPathProcessor* pathProc, | 265 const GrPathProcessor* pathProc, |
| 267 const GrPath* path, | 266 const GrPath* path, |
| 268 const GrClipMaskManager::ScissorState& scis sorState, | 267 const GrScissorState& scissorState, |
| 269 const GrStencilSettings& stencilSettings, | 268 const GrStencilSettings& stencilSettings, |
| 270 const GrDeviceCoordTexture* dstCopy) { | 269 const GrDeviceCoordTexture* dstCopy) { |
| 271 // TODO: Only compare the subset of GrDrawState relevant to path covering? | 270 // TODO: Only compare the subset of GrDrawState relevant to path covering? |
| 272 if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_Dra wType, | 271 if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_Dra wType, |
| 273 scissorState, dstCopy)) { | 272 scissorState, dstCopy)) { |
| 274 return; | 273 return; |
| 275 } | 274 } |
| 276 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); | 275 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
| 277 dp->fStencilSettings = stencilSettings; | 276 dp->fStencilSettings = stencilSettings; |
| 278 this->recordTraceMarkersIfNecessary(); | 277 this->recordTraceMarkersIfNecessary(); |
| 279 } | 278 } |
| 280 | 279 |
| 281 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, | 280 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, |
| 282 const GrPathProcessor* pathProc, | 281 const GrPathProcessor* pathProc, |
| 283 const GrPathRange* pathRange, | 282 const GrPathRange* pathRange, |
| 284 const void* indices, | 283 const void* indices, |
| 285 PathIndexType indexType, | 284 PathIndexType indexType, |
| 286 const float transformValues[], | 285 const float transformValues[], |
| 287 PathTransformType transformType, | 286 PathTransformType transformType, |
| 288 int count, | 287 int count, |
| 289 const GrClipMaskManager::ScissorState& sci ssorState, | 288 const GrScissorState& scissorState, |
| 290 const GrStencilSettings& stencilSettings, | 289 const GrStencilSettings& stencilSettings, |
| 291 const GrDeviceCoordTexture* dstCopy) { | 290 const GrDeviceCoordTexture* dstCopy) { |
| 292 SkASSERT(pathRange); | 291 SkASSERT(pathRange); |
| 293 SkASSERT(indices); | 292 SkASSERT(indices); |
| 294 SkASSERT(transformValues); | 293 SkASSERT(transformValues); |
| 295 | 294 |
| 296 if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_Dra wType, scissorState, | 295 if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_Dra wType, scissorState, |
| 297 dstCopy)) { | 296 dstCopy)) { |
| 298 return; | 297 return; |
| 299 } | 298 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 428 | 427 |
| 429 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); | 428 SkASSERT(fGpuCmdMarkers.count() == currCmdMarker); |
| 430 ++fDrawID; | 429 ++fDrawID; |
| 431 } | 430 } |
| 432 | 431 |
| 433 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const GrOptDra wState* optState) { | 432 void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const GrOptDra wState* optState) { |
| 434 SkASSERT(optState); | 433 SkASSERT(optState); |
| 435 buf->getGpu()->draw(*optState, fInfo); | 434 buf->getGpu()->draw(*optState, fInfo); |
| 436 } | 435 } |
| 437 | 436 |
| 438 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, | 437 void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf, const G rOptDrawState*) { |
| 439 const GrOptDrawState* optState) { | 438 GrGpu::StencilPathState state; |
| 440 SkASSERT(optState); | 439 state.fRenderTarget = fRenderTarget.get(); |
| 441 buf->getGpu()->stencilPath(*optState, this->path(), fStencilSettings); | 440 state.fScissor = &fScissor; |
| 441 state.fStencil = &fStencil; | |
| 442 state.fUseHWAA = fUseHWAA; | |
| 443 state.fViewMatrix = &fViewMatrix; | |
| 444 | |
|
joshualitt
2014/12/17 21:22:37
Is there any reason StencilPathCmd doesn't just ho
| |
| 445 buf->getGpu()->stencilPath(this->path(), state); | |
| 442 } | 446 } |
| 443 | 447 |
| 444 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, | 448 void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf, |
| 445 const GrOptDrawState* optState) { | 449 const GrOptDrawState* optState) { |
| 446 SkASSERT(optState); | 450 SkASSERT(optState); |
| 447 buf->getGpu()->drawPath(*optState, this->path(), fStencilSettings); | 451 buf->getGpu()->drawPath(*optState, this->path(), fStencilSettings); |
| 448 } | 452 } |
| 449 | 453 |
| 450 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, | 454 void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf, |
| 451 const GrOptDrawState* optState) { | 455 const GrOptDrawState* optState) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 486 this->recordTraceMarkersIfNecessary(); | 490 this->recordTraceMarkersIfNecessary(); |
| 487 return true; | 491 return true; |
| 488 } | 492 } |
| 489 return false; | 493 return false; |
| 490 } | 494 } |
| 491 | 495 |
| 492 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds, | 496 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds, |
| 493 const GrGeometryProcessor* gp , | 497 const GrGeometryProcessor* gp , |
| 494 const GrPathProcessor* pathPr oc, | 498 const GrPathProcessor* pathPr oc, |
| 495 GrGpu::DrawType drawType, | 499 GrGpu::DrawType drawType, |
| 496 const GrClipMaskManager::Scis sorState& scissor, | 500 const GrScissorState& scissor , |
| 497 const GrDeviceCoordTexture* d stCopy) { | 501 const GrDeviceCoordTexture* d stCopy) { |
| 498 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, | 502 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, |
| 499 (ds, gp, pathProc, *this->getGpu()-> caps(), scissor, | 503 (ds, gp, pathProc, *this->getGpu()-> caps(), scissor, |
| 500 dstCopy, drawType)); | 504 dstCopy, drawType)); |
| 501 if (ss->fState.mustSkip()) { | 505 if (ss->fState.mustSkip()) { |
| 502 fCmdBuffer.pop_back(); | 506 fCmdBuffer.pop_back(); |
| 503 return false; | 507 return false; |
| 504 } | 508 } |
| 505 if (fPrevState && fPrevState->combineIfPossible(ss->fState)) { | 509 if (fPrevState && fPrevState->combineIfPossible(ss->fState)) { |
| 506 fCmdBuffer.pop_back(); | 510 fCmdBuffer.pop_back(); |
| 507 } else { | 511 } else { |
| 508 fPrevState = &ss->fState; | 512 fPrevState = &ss->fState; |
| 509 this->recordTraceMarkersIfNecessary(); | 513 this->recordTraceMarkersIfNecessary(); |
| 510 } | 514 } |
| 511 return true; | 515 return true; |
| 512 } | 516 } |
| 513 | 517 |
| 514 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 518 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { |
| 515 SkASSERT(!fCmdBuffer.empty()); | 519 SkASSERT(!fCmdBuffer.empty()); |
| 516 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); | 520 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); |
| 517 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 521 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
| 518 if (activeTraceMarkers.count() > 0) { | 522 if (activeTraceMarkers.count() > 0) { |
| 519 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 523 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
| 520 fGpuCmdMarkers.push_back(activeTraceMarkers); | 524 fGpuCmdMarkers.push_back(activeTraceMarkers); |
| 521 } | 525 } |
| 522 } | 526 } |
| OLD | NEW |