| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "GrDrawTarget.h" | 8 #include "GrDrawTarget.h" |
| 9 | 9 |
| 10 #include "GrAuditTrail.h" | 10 #include "GrAuditTrail.h" |
| 11 #include "GrCaps.h" | 11 #include "GrCaps.h" |
| 12 #include "GrDrawContext.h" | 12 #include "GrDrawContext.h" |
| 13 #include "GrGpu.h" | 13 #include "GrGpu.h" |
| 14 #include "GrGpuCommandBuffer.h" |
| 14 #include "GrPath.h" | 15 #include "GrPath.h" |
| 15 #include "GrPipeline.h" | 16 #include "GrPipeline.h" |
| 16 #include "GrMemoryPool.h" | 17 #include "GrMemoryPool.h" |
| 17 #include "GrRenderTarget.h" | 18 #include "GrRenderTarget.h" |
| 18 #include "GrResourceProvider.h" | 19 #include "GrResourceProvider.h" |
| 19 #include "GrRenderTargetPriv.h" | 20 #include "GrRenderTargetPriv.h" |
| 20 #include "GrStencilAttachment.h" | 21 #include "GrStencilAttachment.h" |
| 21 #include "GrSurfacePriv.h" | 22 #include "GrSurfacePriv.h" |
| 22 #include "GrTexture.h" | 23 #include "GrTexture.h" |
| 23 #include "gl/GrGLRenderTarget.h" | 24 #include "gl/GrGLRenderTarget.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 for (int i = 0; i < fBatches.count(); ++i) { | 203 for (int i = 0; i < fBatches.count(); ++i) { |
| 203 if (fBatches[i]) { | 204 if (fBatches[i]) { |
| 204 fBatches[i]->prepare(flushState); | 205 fBatches[i]->prepare(flushState); |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 } | 208 } |
| 208 | 209 |
| 209 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { | 210 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { |
| 210 // Draw all the generated geometry. | 211 // Draw all the generated geometry. |
| 211 SkRandom random; | 212 SkRandom random; |
| 213 GrRenderTarget* currentRT = nullptr; |
| 214 SkAutoTDelete<GrGpuCommandBuffer> commandBuffer; |
| 212 for (int i = 0; i < fBatches.count(); ++i) { | 215 for (int i = 0; i < fBatches.count(); ++i) { |
| 213 if (!fBatches[i]) { | 216 if (!fBatches[i]) { |
| 214 continue; | 217 continue; |
| 215 } | 218 } |
| 219 if (fBatches[i]->renderTarget() != currentRT) { |
| 220 if (commandBuffer) { |
| 221 commandBuffer->end(); |
| 222 // For now just use size of whole render target, but this should
be updated to |
| 223 // only be the actual bounds of the various draws. |
| 224 SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->
height()); |
| 225 commandBuffer->submit(bounds); |
| 226 commandBuffer.reset(); |
| 227 } |
| 228 currentRT = fBatches[i]->renderTarget(); |
| 229 if (currentRT) { |
| 230 static const GrGpuCommandBuffer::LoadAndStoreOp kBasicLoadStoreO
p = |
| 231 GrGpuCommandBuffer::kLoadAndStore_LoadAndStoreOp; |
| 232 static const GrColor kClearValue = GrColor_ILLEGAL; |
| 233 commandBuffer.reset(fGpu->createCommandBuffer(currentRT, |
| 234 kBasicLoadStoreOp,
// Color |
| 235 kClearValue,
// Color clear |
| 236 kBasicLoadStoreOp,
// Stencil |
| 237 kClearValue));
// Stencil clear |
| 238 } |
| 239 } |
| 216 if (fDrawBatchBounds) { | 240 if (fDrawBatchBounds) { |
| 217 const SkRect& bounds = fBatches[i]->bounds(); | 241 const SkRect& bounds = fBatches[i]->bounds(); |
| 218 SkIRect ibounds; | 242 SkIRect ibounds; |
| 219 bounds.roundOut(&ibounds); | 243 bounds.roundOut(&ibounds); |
| 220 // In multi-draw buffer all the batches use the same render target a
nd we won't need to | 244 // In multi-draw buffer all the batches use the same render target a
nd we won't need to |
| 221 // get the batchs bounds. | 245 // get the batchs bounds. |
| 222 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { | 246 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { |
| 223 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU()
); | 247 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU()
); |
| 224 } | 248 } |
| 225 } | 249 } |
| 226 fBatches[i]->draw(flushState); | 250 fBatches[i]->draw(flushState, commandBuffer); |
| 251 } |
| 252 if (commandBuffer) { |
| 253 commandBuffer->end(); |
| 254 // For now just use size of whole render target, but this should be upda
ted to |
| 255 // only be the actual bounds of the various draws. |
| 256 SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->height()
); |
| 257 commandBuffer->submit(bounds); |
| 227 } | 258 } |
| 228 | 259 |
| 229 fGpu->finishDrawTarget(); | 260 fGpu->finishDrawTarget(); |
| 230 } | 261 } |
| 231 | 262 |
| 232 void GrDrawTarget::reset() { | 263 void GrDrawTarget::reset() { |
| 233 fBatches.reset(); | 264 fBatches.reset(); |
| 234 } | 265 } |
| 235 | 266 |
| 236 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, | 267 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 } | 555 } |
| 525 } | 556 } |
| 526 | 557 |
| 527 /////////////////////////////////////////////////////////////////////////////// | 558 /////////////////////////////////////////////////////////////////////////////// |
| 528 | 559 |
| 529 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { | 560 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend
erTarget* rt) { |
| 530 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); | 561 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); |
| 531 this->recordBatch(batch); | 562 this->recordBatch(batch); |
| 532 batch->unref(); | 563 batch->unref(); |
| 533 } | 564 } |
| OLD | NEW |