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

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

Issue 2123693002: Revert of Begin instanced rendering for simple shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrDrawTarget.h ('k') | src/gpu/GrDrawingManager.cpp » ('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"
(...skipping 15 matching lines...) Expand all
26 #include "SkStrokeRec.h" 26 #include "SkStrokeRec.h"
27 27
28 #include "batches/GrClearBatch.h" 28 #include "batches/GrClearBatch.h"
29 #include "batches/GrCopySurfaceBatch.h" 29 #include "batches/GrCopySurfaceBatch.h"
30 #include "batches/GrDiscardBatch.h" 30 #include "batches/GrDiscardBatch.h"
31 #include "batches/GrDrawBatch.h" 31 #include "batches/GrDrawBatch.h"
32 #include "batches/GrDrawPathBatch.h" 32 #include "batches/GrDrawPathBatch.h"
33 #include "batches/GrRectBatchFactory.h" 33 #include "batches/GrRectBatchFactory.h"
34 #include "batches/GrStencilPathBatch.h" 34 #include "batches/GrStencilPathBatch.h"
35 35
36 #include "instanced/InstancedRendering.h"
37
38 //////////////////////////////////////////////////////////////////////////////// 36 ////////////////////////////////////////////////////////////////////////////////
39 37
40 // Experimentally we have found that most batching occurs within the first 10 co mparisons. 38 // Experimentally we have found that most batching occurs within the first 10 co mparisons.
41 static const int kDefaultMaxBatchLookback = 10; 39 static const int kDefaultMaxBatchLookback = 10;
42 static const int kDefaultMaxBatchLookahead = 10; 40 static const int kDefaultMaxBatchLookahead = 10;
43 41
44 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider, 42 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider,
45 GrAuditTrail* auditTrail, const Options& options) 43 GrAuditTrail* auditTrail, const Options& options)
46 : fGpu(SkRef(gpu)) 44 : fGpu(SkRef(gpu))
47 , fResourceProvider(resourceProvider) 45 , fResourceProvider(resourceProvider)
48 , fAuditTrail(auditTrail) 46 , fAuditTrail(auditTrail)
49 , fFlags(0) 47 , fFlags(0)
50 , fRenderTarget(rt) 48 , fRenderTarget(rt) {
51 , fInstancedRendering(fGpu->createInstancedRenderingIfSupported()) {
52 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) 49 // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
53 fContext = fGpu->getContext(); 50 fContext = fGpu->getContext();
54 51
55 fClipBatchToBounds = options.fClipBatchToBounds; 52 fClipBatchToBounds = options.fClipBatchToBounds;
56 fDrawBatchBounds = options.fDrawBatchBounds; 53 fDrawBatchBounds = options.fDrawBatchBounds;
57 fMaxBatchLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookba ck : 54 fMaxBatchLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookba ck :
58 options.fMaxBatchLookb ack; 55 options.fMaxBatchLookb ack;
59 fMaxBatchLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLook ahead : 56 fMaxBatchLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLook ahead :
60 options.fMaxBatchLook ahead; 57 options.fMaxBatchLook ahead;
61 58
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // but need to be flushed anyway. Closing such drawTargets here will mean ne w 194 // but need to be flushed anyway. Closing such drawTargets here will mean ne w
198 // drawTargets will be created to replace them if the SkGpuDevice(s) write t o them again. 195 // drawTargets will be created to replace them if the SkGpuDevice(s) write t o them again.
199 this->makeClosed(); 196 this->makeClosed();
200 197
201 // Loop over the batches that haven't yet generated their geometry 198 // Loop over the batches that haven't yet generated their geometry
202 for (int i = 0; i < fBatches.count(); ++i) { 199 for (int i = 0; i < fBatches.count(); ++i) {
203 if (fBatches[i]) { 200 if (fBatches[i]) {
204 fBatches[i]->prepare(flushState); 201 fBatches[i]->prepare(flushState);
205 } 202 }
206 } 203 }
207
208 if (fInstancedRendering) {
209 fInstancedRendering->beginFlush(flushState->resourceProvider());
210 }
211 } 204 }
212 205
213 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { 206 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
214 // Draw all the generated geometry. 207 // Draw all the generated geometry.
215 SkRandom random; 208 SkRandom random;
216 GrRenderTarget* currentRT = nullptr; 209 GrRenderTarget* currentRT = nullptr;
217 SkAutoTDelete<GrGpuCommandBuffer> commandBuffer; 210 SkAutoTDelete<GrGpuCommandBuffer> commandBuffer;
218 for (int i = 0; i < fBatches.count(); ++i) { 211 for (int i = 0; i < fBatches.count(); ++i) {
219 if (!fBatches[i]) { 212 if (!fBatches[i]) {
220 continue; 213 continue;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->height() ); 251 SkIRect bounds = SkIRect::MakeWH(currentRT->width(), currentRT->height() );
259 commandBuffer->submit(bounds); 252 commandBuffer->submit(bounds);
260 flushState->setCommandBuffer(nullptr); 253 flushState->setCommandBuffer(nullptr);
261 } 254 }
262 255
263 fGpu->finishDrawTarget(); 256 fGpu->finishDrawTarget();
264 } 257 }
265 258
266 void GrDrawTarget::reset() { 259 void GrDrawTarget::reset() {
267 fBatches.reset(); 260 fBatches.reset();
268 if (fInstancedRendering) {
269 fInstancedRendering->endFlush();
270 }
271 } 261 }
272 262
273 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, 263 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
274 GrDrawContext* drawContext, 264 GrDrawContext* drawContext,
275 const GrClip& clip, 265 const GrClip& clip,
276 GrDrawBatch* batch) { 266 GrDrawBatch* batch) {
277 // Setup clip 267 // Setup clip
278 GrAppliedClip appliedClip; 268 GrAppliedClip appliedClip;
279 if (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a ppliedClip)) { 269 if (!clip.apply(fContext, pipelineBuilder, drawContext, &batch->bounds(), &a ppliedClip)) {
280 return; 270 return;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 } 551 }
562 } 552 }
563 553
564 /////////////////////////////////////////////////////////////////////////////// 554 ///////////////////////////////////////////////////////////////////////////////
565 555
566 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 556 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
567 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 557 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
568 this->recordBatch(batch); 558 this->recordBatch(batch);
569 batch->unref(); 559 batch->unref();
570 } 560 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrDrawingManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698