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" |
11 #include "GrTemplates.h" | 11 #include "GrTemplates.h" |
12 | 12 |
13 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu, | 13 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context, |
14 GrVertexBufferAllocPool* vertexPool, | 14 GrVertexBufferAllocPool* vertexPool, |
15 GrIndexBufferAllocPool* indexPool) | 15 GrIndexBufferAllocPool* indexPool) |
16 : INHERITED(gpu, vertexPool, indexPool) | 16 : INHERITED(context, vertexPool, indexPool) |
17 , fCommands(gpu, vertexPool, indexPool) | 17 , fCommands(context->getGpu(), vertexPool, indexPool) |
18 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) | 18 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) |
19 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) | 19 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) |
20 , fDrawID(0) { | 20 , fDrawID(0) { |
21 | 21 |
22 SkASSERT(vertexPool); | 22 SkASSERT(vertexPool); |
23 SkASSERT(indexPool); | 23 SkASSERT(indexPool); |
24 } | 24 } |
25 | 25 |
26 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() { | 26 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() { |
27 this->reset(); | 27 this->reset(); |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 fPathIndexBuffer.rewind(); | 369 fPathIndexBuffer.rewind(); |
370 fPathTransformBuffer.rewind(); | 370 fPathTransformBuffer.rewind(); |
371 fGpuCmdMarkers.reset(); | 371 fGpuCmdMarkers.reset(); |
372 } | 372 } |
373 | 373 |
374 void GrInOrderDrawBuffer::onFlush() { | 374 void GrInOrderDrawBuffer::onFlush() { |
375 fCommands.flush(this); | 375 fCommands.flush(this); |
376 ++fDrawID; | 376 ++fDrawID; |
377 } | 377 } |
378 | 378 |
379 bool GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, | 379 void GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, |
380 GrSurface* src, | 380 GrSurface* src, |
381 const SkIRect& srcRect, | 381 const SkIRect& srcRect, |
382 const SkIPoint& dstPoint) { | 382 const SkIPoint& dstPoint) { |
383 GrTargetCommands::Cmd* cmd = fCommands.recordCopySurface(this, dst, src, | 383 SkASSERT(this->getGpu()->canCopySurface(dst, src, srcRect, dstPoint)); |
384 srcRect, dstPoint); | 384 GrTargetCommands::Cmd* cmd = fCommands.recordCopySurface(dst, src, srcRect,
dstPoint); |
385 this->recordTraceMarkersIfNecessary(cmd); | 385 this->recordTraceMarkersIfNecessary(cmd); |
386 return SkToBool(cmd); | |
387 } | 386 } |
388 | 387 |
389 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary(GrTargetCommands::Cmd* c
md) { | 388 void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary(GrTargetCommands::Cmd* c
md) { |
390 if (!cmd) { | 389 if (!cmd) { |
391 return; | 390 return; |
392 } | 391 } |
393 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); | 392 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); |
394 if (activeTraceMarkers.count() > 0) { | 393 if (activeTraceMarkers.count() > 0) { |
395 if (cmd->isTraced()) { | 394 if (cmd->isTraced()) { |
396 fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers); | 395 fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers); |
397 } else { | 396 } else { |
398 cmd->setMarkerID(fGpuCmdMarkers.count()); | 397 cmd->setMarkerID(fGpuCmdMarkers.count()); |
399 fGpuCmdMarkers.push_back(activeTraceMarkers); | 398 fGpuCmdMarkers.push_back(activeTraceMarkers); |
400 } | 399 } |
401 } | 400 } |
402 } | 401 } |
OLD | NEW |