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

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

Issue 1386463004: Incrementally flush GrDrawTarget (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 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/GrDrawTarget.h ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrDrawTarget.h" 9 #include "GrDrawTarget.h"
10 10
(...skipping 18 matching lines...) Expand all
29 #include "batches/GrStencilPathBatch.h" 29 #include "batches/GrStencilPathBatch.h"
30 30
31 #include "SkStrokeRec.h" 31 #include "SkStrokeRec.h"
32 32
33 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
34 34
35 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) 35 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider)
36 : fGpu(SkRef(gpu)) 36 : fGpu(SkRef(gpu))
37 , fResourceProvider(resourceProvider) 37 , fResourceProvider(resourceProvider)
38 , fFlushing(false) 38 , fFlushing(false)
39 , fLastFlushToken(0) { 39 , fLastFlushToken(0)
40 , fLastFlushedBatch(0) {
40 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) 41 // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
41 fContext = fGpu->getContext(); 42 fContext = fGpu->getContext();
42 fClipMaskManager.reset(new GrClipMaskManager(this)); 43 fClipMaskManager.reset(new GrClipMaskManager(this));
43 } 44 }
44 45
45 GrDrawTarget::~GrDrawTarget() { 46 GrDrawTarget::~GrDrawTarget() {
46 fGpu->unref(); 47 fGpu->unref();
47 } 48 }
48 49
49 //////////////////////////////////////////////////////////////////////////////// 50 ////////////////////////////////////////////////////////////////////////////////
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if (!copy) { 104 if (!copy) {
104 SkDebugf("Failed to create temporary copy of destination texture.\n"); 105 SkDebugf("Failed to create temporary copy of destination texture.\n");
105 return false; 106 return false;
106 } 107 }
107 SkIPoint dstPoint = {0, 0}; 108 SkIPoint dstPoint = {0, 0};
108 this->copySurface(copy, rt, copyRect, dstPoint); 109 this->copySurface(copy, rt, copyRect, dstPoint);
109 dstTexture->setTexture(copy); 110 dstTexture->setTexture(copy);
110 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop); 111 dstTexture->setOffset(copyRect.fLeft, copyRect.fTop);
111 return true; 112 return true;
112 } 113 }
113 114
robertphillips 2015/10/02 13:02:57 Maybe flushNextN(int N) and just assume 'index' is
114 void GrDrawTarget::flush() { 115 void GrDrawTarget::flushN(int index, int N) {
robertphillips 2015/10/02 13:02:57 SkASSERT(index == fLastFlushedBatch); ?
116 SkASSERT(index + N <= fBatches.count());
115 if (fFlushing) { 117 if (fFlushing) {
116 return; 118 return;
117 } 119 }
118 fFlushing = true; 120 fFlushing = true;
119 121
120 GrBatchFlushState flushState(fGpu, fResourceProvider, fLastFlushToken); 122 GrBatchFlushState flushState(fGpu, fResourceProvider, fLastFlushToken);
121 123
124 int flushTo = index + N;
125
122 // Loop over all batches and generate geometry 126 // Loop over all batches and generate geometry
123 for (int i = 0; i < fBatches.count(); ++i) { 127 for (int i = index; i < flushTo; ++i) {
124 fBatches[i]->prepare(&flushState); 128 fBatches[i]->prepare(&flushState);
125 } 129 }
126 130
127 // Upload all data to the GPU 131 // Upload all data to the GPU
128 flushState.preIssueDraws(); 132 flushState.preIssueDraws();
129 133
130 // Draw all the generated geometry. 134 // Draw all the generated geometry.
131 for (int i = 0; i < fBatches.count(); ++i) { 135 for (int i = index; i < flushTo; ++i) {
132 fBatches[i]->draw(&flushState); 136 fBatches[i]->draw(&flushState);
133 } 137 }
134 138
135 fLastFlushToken = flushState.lastFlushedToken(); 139 fLastFlushToken = flushState.lastFlushedToken();
136 140
137 fFlushing = false; 141 fFlushing = false;
142 }
143
144 void GrDrawTarget::flush() {
145 this->flushN(fLastFlushedBatch, fBatches.count() - fLastFlushedBatch);
138 this->reset(); 146 this->reset();
139 } 147 }
140 148
141 void GrDrawTarget::reset() { 149 void GrDrawTarget::reset() {
150 fLastFlushedBatch = 0;
142 fBatches.reset(); 151 fBatches.reset();
143 } 152 }
144 153
145 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat ch* batch) { 154 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, GrDrawBat ch* batch) {
146 // Setup clip 155 // Setup clip
147 GrScissorState scissorState; 156 GrScissorState scissorState;
148 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps; 157 GrPipelineBuilder::AutoRestoreFragmentProcessorState arfps;
149 GrPipelineBuilder::AutoRestoreStencil ars; 158 GrPipelineBuilder::AutoRestoreStencil ars;
150 if (!fClipMaskManager->setupClipping(pipelineBuilder, &arfps, &ars, &scissor State, 159 if (!fClipMaskManager->setupClipping(pipelineBuilder, &arfps, &ars, &scissor State,
151 &batch->bounds())) { 160 &batch->bounds())) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 ++i; 436 ++i;
428 if (i == maxCandidates) { 437 if (i == maxCandidates) {
429 GrBATCH_INFO("\t\tReached max lookback or beginning of batch arr ay %d\n", i); 438 GrBATCH_INFO("\t\tReached max lookback or beginning of batch arr ay %d\n", i);
430 break; 439 break;
431 } 440 }
432 } 441 }
433 } else { 442 } else {
434 GrBATCH_INFO("\t\tFirstBatch\n"); 443 GrBATCH_INFO("\t\tFirstBatch\n");
435 } 444 }
436 fBatches.push_back().reset(SkRef(batch)); 445 fBatches.push_back().reset(SkRef(batch));
446 if (fBatches.count() > kMaxLookback) {
447 this->flushN(fLastFlushedBatch++, 1);
448 }
437 } 449 }
438 450
439 /////////////////////////////////////////////////////////////////////////////// 451 ///////////////////////////////////////////////////////////////////////////////
440 452
441 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB uilder, 453 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB uilder,
442 const GrScissorState* scissor, 454 const GrScissorState* scissor,
443 GrDrawBatch* batch) { 455 GrDrawBatch* batch) {
444 GrPipeline::CreateArgs args; 456 GrPipeline::CreateArgs args;
445 args.fPipelineBuilder = pipelineBuilder; 457 args.fPipelineBuilder = pipelineBuilder;
446 args.fCaps = this->caps(); 458 args.fCaps = this->caps();
(...skipping 11 matching lines...) Expand all
458 } 470 }
459 471
460 return true; 472 return true;
461 } 473 }
462 474
463 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 475 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
464 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 476 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
465 this->recordBatch(batch); 477 this->recordBatch(batch);
466 batch->unref(); 478 batch->unref();
467 } 479 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698