| 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 "GrBufferedDrawTarget.h" | 8 #include "GrBufferedDrawTarget.h" |
| 9 | 9 |
| 10 // We will use the reordering buffer, unless we have NVPR. | 10 // We will use the reordering buffer, unless we have NVPR. |
| 11 // TODO move NVPR to batch so we can reorder | 11 // TODO move NVPR to batch so we can reorder |
| 12 static inline bool allow_reordering(const GrCaps* caps) { | 12 static inline bool allow_reordering(const GrCaps* caps) { |
| 13 return caps && caps->shaderCaps() && !caps->shaderCaps()->pathRenderingSuppo
rt(); | 13 return caps && caps->shaderCaps() && !caps->shaderCaps()->pathRenderingSuppo
rt(); |
| 14 } | 14 } |
| 15 | 15 |
| 16 GrBufferedDrawTarget::GrBufferedDrawTarget(GrContext* context) | 16 GrBufferedDrawTarget::GrBufferedDrawTarget(GrContext* context) |
| 17 : INHERITED(context) | 17 : INHERITED(context) |
| 18 , fCommands(GrCommandBuilder::Create(context->getGpu(), allow_reordering(con
text->caps()))) | 18 , fCommands(GrCommandBuilder::Create(context->getGpu(), allow_reordering(con
text->caps()))) |
| 19 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) | 19 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) |
| 20 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) | 20 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) |
| 21 , fPipelineBuffer(kPipelineBufferMinReserve) | 21 , fPipelineBuffer(kPipelineBufferMinReserve) |
| 22 , fDrawID(0) { | 22 , fDrawID(0) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 GrBufferedDrawTarget::~GrBufferedDrawTarget() { | 25 GrBufferedDrawTarget::~GrBufferedDrawTarget() { |
| 26 this->reset(); | 26 this->reset(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) { | 29 void GrBufferedDrawTarget::onDrawBatch(GrBatch* batch) { |
| 30 fCommands->recordXferBarrierIfNecessary(*batch->pipeline(), *this->caps()); | 30 fCommands->recordDrawBatch(batch, *this->caps()); |
| 31 fCommands->recordDrawBatch(batch); | |
| 32 } | 31 } |
| 33 | 32 |
| 34 void GrBufferedDrawTarget::onStencilPath(const GrPipelineBuilder& pipelineBuilde
r, | 33 void GrBufferedDrawTarget::onStencilPath(const GrPipelineBuilder& pipelineBuilde
r, |
| 35 const GrPathProcessor* pathProc, | 34 const GrPathProcessor* pathProc, |
| 36 const GrPath* path, | 35 const GrPath* path, |
| 37 const GrScissorState& scissorState, | 36 const GrScissorState& scissorState, |
| 38 const GrStencilSettings& stencilSetting
s) { | 37 const GrStencilSettings& stencilSetting
s) { |
| 39 fCommands->recordStencilPath(pipelineBuilder, pathProc, path, scissorState,
stencilSettings); | 38 fCommands->recordStencilPath(pipelineBuilder, pathProc, path, scissorState,
stencilSettings); |
| 40 } | 39 } |
| 41 | 40 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 this->unallocState(state); | 123 this->unallocState(state); |
| 125 return NULL; | 124 return NULL; |
| 126 } | 125 } |
| 127 | 126 |
| 128 state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker, *opts); | 127 state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker, *opts); |
| 129 | 128 |
| 130 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && | 129 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && |
| 131 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, | 130 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, |
| 132 *state->fPrimitiveProcesso
r, | 131 *state->fPrimitiveProcesso
r, |
| 133 state->fBatchTracker) && | 132 state->fBatchTracker) && |
| 134 fPrevState->getPipeline()->isEqual(*state->getPipeline())) { | 133 GrPipeline::AreEqual(*fPrevState->getPipeline(), *state->getPipeline(),
false)) { |
| 135 this->unallocState(state); | 134 this->unallocState(state); |
| 136 } else { | 135 } else { |
| 137 fPrevState.reset(state); | 136 fPrevState.reset(state); |
| 138 } | 137 } |
| 139 | 138 |
| 140 fCommands->recordXferBarrierIfNecessary(*fPrevState->getPipeline(), *this->c
aps()); | |
| 141 return fPrevState; | 139 return fPrevState; |
| 142 } | 140 } |
| OLD | NEW |