| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 return instancesToConcat; | 238 return instancesToConcat; |
| 239 } | 239 } |
| 240 | 240 |
| 241 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, | 241 void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds, |
| 242 const GrGeometryProcessor* gp, | 242 const GrGeometryProcessor* gp, |
| 243 const DrawInfo& info, | 243 const DrawInfo& info, |
| 244 const GrScissorState& scissorState, | 244 const GrScissorState& scissorState, |
| 245 const GrDeviceCoordTexture* dstCopy) { | 245 const GrDeviceCoordTexture* dstCopy) { |
| 246 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); | 246 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); |
| 247 | 247 |
| 248 if (!this->recordStateAndShouldDraw(ds, gp, NULL, | 248 if (!this->recordStateAndShouldDraw(ds, gp, |
| 249 GrGpu::PrimTypeToDrawType(info.primitive
Type()), | 249 GrGpu::PrimTypeToDrawType(info.primitive
Type()), |
| 250 scissorState, dstCopy)) { | 250 scissorState, dstCopy)) { |
| 251 return; | 251 return; |
| 252 } | 252 } |
| 253 | 253 |
| 254 Draw* draw; | 254 Draw* draw; |
| 255 if (info.isInstanced()) { | 255 if (info.isInstanced()) { |
| 256 int instancesConcated = this->concatInstancedDraw(ds, info); | 256 int instancesConcated = this->concatInstancedDraw(ds, info); |
| 257 if (info.instanceCount() > instancesConcated) { | 257 if (info.instanceCount() > instancesConcated) { |
| 258 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); | 258 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 280 this->recordTraceMarkersIfNecessary(); | 280 this->recordTraceMarkersIfNecessary(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, | 283 void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds, |
| 284 const GrPathProcessor* pathProc, | 284 const GrPathProcessor* pathProc, |
| 285 const GrPath* path, | 285 const GrPath* path, |
| 286 const GrScissorState& scissorState, | 286 const GrScissorState& scissorState, |
| 287 const GrStencilSettings& stencilSettings, | 287 const GrStencilSettings& stencilSettings, |
| 288 const GrDeviceCoordTexture* dstCopy) { | 288 const GrDeviceCoordTexture* dstCopy) { |
| 289 // TODO: Only compare the subset of GrDrawState relevant to path covering? | 289 // TODO: Only compare the subset of GrDrawState relevant to path covering? |
| 290 if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_Dra
wType, | 290 if (!this->recordStateAndShouldDraw(ds, pathProc, GrGpu::kDrawPath_DrawType, |
| 291 scissorState, dstCopy)) { | 291 scissorState, dstCopy)) { |
| 292 return; | 292 return; |
| 293 } | 293 } |
| 294 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); | 294 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); |
| 295 dp->fStencilSettings = stencilSettings; | 295 dp->fStencilSettings = stencilSettings; |
| 296 this->recordTraceMarkersIfNecessary(); | 296 this->recordTraceMarkersIfNecessary(); |
| 297 } | 297 } |
| 298 | 298 |
| 299 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, | 299 void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds, |
| 300 const GrPathProcessor* pathProc, | 300 const GrPathProcessor* pathProc, |
| 301 const GrPathRange* pathRange, | 301 const GrPathRange* pathRange, |
| 302 const void* indices, | 302 const void* indices, |
| 303 PathIndexType indexType, | 303 PathIndexType indexType, |
| 304 const float transformValues[], | 304 const float transformValues[], |
| 305 PathTransformType transformType, | 305 PathTransformType transformType, |
| 306 int count, | 306 int count, |
| 307 const GrScissorState& scissorState, | 307 const GrScissorState& scissorState, |
| 308 const GrStencilSettings& stencilSettings, | 308 const GrStencilSettings& stencilSettings, |
| 309 const GrDeviceCoordTexture* dstCopy) { | 309 const GrDeviceCoordTexture* dstCopy) { |
| 310 SkASSERT(pathRange); | 310 SkASSERT(pathRange); |
| 311 SkASSERT(indices); | 311 SkASSERT(indices); |
| 312 SkASSERT(transformValues); | 312 SkASSERT(transformValues); |
| 313 | 313 |
| 314 if (!this->recordStateAndShouldDraw(ds, NULL, pathProc, GrGpu::kDrawPath_Dra
wType, scissorState, | 314 if (!this->recordStateAndShouldDraw(ds, pathProc, GrGpu::kDrawPath_DrawType,
scissorState, |
| 315 dstCopy)) { | 315 dstCopy)) { |
| 316 return; | 316 return; |
| 317 } | 317 } |
| 318 | 318 |
| 319 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); | 319 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); |
| 320 if (int misalign = fPathIndexBuffer.count() % indexBytes) { | 320 if (int misalign = fPathIndexBuffer.count() % indexBytes) { |
| 321 // Add padding to the index buffer so the indices are aligned properly. | 321 // Add padding to the index buffer so the indices are aligned properly. |
| 322 fPathIndexBuffer.append(indexBytes - misalign); | 322 fPathIndexBuffer.append(indexBytes - misalign); |
| 323 } | 323 } |
| 324 | 324 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); | 506 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst
, src)); |
| 507 cs->fSrcRect = srcRect; | 507 cs->fSrcRect = srcRect; |
| 508 cs->fDstPoint = dstPoint; | 508 cs->fDstPoint = dstPoint; |
| 509 this->recordTraceMarkersIfNecessary(); | 509 this->recordTraceMarkersIfNecessary(); |
| 510 return true; | 510 return true; |
| 511 } | 511 } |
| 512 return false; | 512 return false; |
| 513 } | 513 } |
| 514 | 514 |
| 515 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds, | 515 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds, |
| 516 const GrGeometryProcessor* gp
, | 516 const GrPrimitiveProcessor* p
rimProc, |
| 517 const GrPathProcessor* pathPr
oc, | |
| 518 GrGpu::DrawType drawType, | 517 GrGpu::DrawType drawType, |
| 519 const GrScissorState& scissor
, | 518 const GrScissorState& scissor
, |
| 520 const GrDeviceCoordTexture* d
stCopy) { | 519 const GrDeviceCoordTexture* d
stCopy) { |
| 521 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, | 520 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, |
| 522 (ds, gp, pathProc, *this->getGpu()->
caps(), scissor, | 521 (ds, primProc, *this->getGpu()->caps
(), scissor, |
| 523 dstCopy, drawType)); | 522 dstCopy, drawType)); |
| 524 if (ss->fState.mustSkip()) { | 523 if (ss->fState.mustSkip()) { |
| 525 fCmdBuffer.pop_back(); | 524 fCmdBuffer.pop_back(); |
| 526 return false; | 525 return false; |
| 527 } | 526 } |
| 528 if (fPrevState && fPrevState->combineIfPossible(ss->fState)) { | 527 if (fPrevState && fPrevState->combineIfPossible(ss->fState)) { |
| 529 fCmdBuffer.pop_back(); | 528 fCmdBuffer.pop_back(); |
| 530 } else { | 529 } else { |
| 531 fPrevState = &ss->fState; | 530 fPrevState = &ss->fState; |
| 532 this->recordTraceMarkersIfNecessary(); | 531 this->recordTraceMarkersIfNecessary(); |
| 533 } | 532 } |
| 534 return true; | 533 return true; |
| 535 } | 534 } |
| 536 | 535 |
| 537 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { | 536 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() { |
| 538 SkASSERT(!fCmdBuffer.empty()); | 537 SkASSERT(!fCmdBuffer.empty()); |
| 539 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); | 538 SkASSERT(!cmd_has_trace_marker(fCmdBuffer.back().fType)); |
| 540 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 539 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
| 541 if (activeTraceMarkers.count() > 0) { | 540 if (activeTraceMarkers.count() > 0) { |
| 542 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); | 541 fCmdBuffer.back().fType = add_trace_bit(fCmdBuffer.back().fType); |
| 543 fGpuCmdMarkers.push_back(activeTraceMarkers); | 542 fGpuCmdMarkers.push_back(activeTraceMarkers); |
| 544 } | 543 } |
| 545 } | 544 } |
| OLD | NEW |