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::LoadAndStoreInfo kBasicLoadStor eInfo = | |
bsalomon
2016/06/23 02:12:55
A slightly more terse version of this would be:
s
egdaniel
2016/06/23 13:57:08
Done.
| |
231 GrGpuCommandBuffer::LoadAndStoreInfo(GrGpuCommandBuffer::kLo ad_LoadOp, | |
232 GrGpuCommandBuffer::kSt ore_StoreOp); | |
233 commandBuffer.reset(fGpu->createCommandBuffer(currentRT, | |
234 kBasicLoadStoreInf o, // Color | |
235 kBasicLoadStoreInf o)); // Stencil | |
236 } | |
237 flushState->setCommandBuffer(commandBuffer); | |
238 } | |
216 if (fDrawBatchBounds) { | 239 if (fDrawBatchBounds) { |
217 const SkRect& bounds = fBatches[i]->bounds(); | 240 const SkRect& bounds = fBatches[i]->bounds(); |
218 SkIRect ibounds; | 241 SkIRect ibounds; |
219 bounds.roundOut(&ibounds); | 242 bounds.roundOut(&ibounds); |
220 // In multi-draw buffer all the batches use the same render target a nd we won't need to | 243 // In multi-draw buffer all the batches use the same render target a nd we won't need to |
221 // get the batchs bounds. | 244 // get the batchs bounds. |
222 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { | 245 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { |
223 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU() ); | 246 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU() ); |
224 } | 247 } |
225 } | 248 } |
226 fBatches[i]->draw(flushState); | 249 fBatches[i]->draw(flushState); |
227 } | 250 } |
251 if (commandBuffer) { | |
252 commandBuffer->end(); | |
253 // For now just use size of whole render target, but this should be upda ted to | |
254 // only be the actual bounds of the various draws. | |
255 SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->height() ); | |
256 commandBuffer->submit(bounds); | |
257 flushState->setCommandBuffer(nullptr); | |
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, |
237 GrDrawContext* drawContext, | 268 GrDrawContext* drawContext, |
(...skipping 286 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 |