Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Side by Side Diff: src/gpu/GrDrawTarget.cpp

Issue 2078483002: Start using GrGpuCommandBuffer in GrDrawTarget. (Closed) Base URL: https://skia.googlesource.com/skia.git@memoryWAR
Patch Set: remove errant lines Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrBatchFlushState.cpp ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
231 { GrGpuCommandBuffer::LoadOp::kLoad,GrGpuCommandBuffer::Stor eOp::kStore,
232 GrColor_ILLEGAL };
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
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 }
OLDNEW
« no previous file with comments | « src/gpu/GrBatchFlushState.cpp ('k') | src/gpu/GrGpu.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698