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

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

Issue 1498653002: Add option to control maximum GrBatch lookback (Closed) Base URL: https://skia.googlesource.com/skia.git@drect
Patch Set: fix rebase Created 5 years 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 14 matching lines...) Expand all
25 #include "batches/GrDiscardBatch.h" 25 #include "batches/GrDiscardBatch.h"
26 #include "batches/GrDrawBatch.h" 26 #include "batches/GrDrawBatch.h"
27 #include "batches/GrDrawPathBatch.h" 27 #include "batches/GrDrawPathBatch.h"
28 #include "batches/GrRectBatchFactory.h" 28 #include "batches/GrRectBatchFactory.h"
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 // Experimentally we have found that most batching occurs within the first 10 co mparisons.
36 static const int kDefaultMaxBatchLookback = 10;
37
35 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider, 38 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider,
36 const Options& options) 39 const Options& options)
37 : fGpu(SkRef(gpu)) 40 : fGpu(SkRef(gpu))
38 , fResourceProvider(resourceProvider) 41 , fResourceProvider(resourceProvider)
39 , fFlushing(false) 42 , fFlushing(false)
40 , fFlags(0) 43 , fFlags(0)
41 , fRenderTarget(rt) { 44 , fRenderTarget(rt) {
42 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) 45 // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
43 fContext = fGpu->getContext(); 46 fContext = fGpu->getContext();
44 fClipMaskManager.reset(new GrClipMaskManager(this, options.fClipBatchToBound s)); 47 fClipMaskManager.reset(new GrClipMaskManager(this, options.fClipBatchToBound s));
45 48
46 fDrawBatchBounds = options.fDrawBatchBounds; 49 fDrawBatchBounds = options.fDrawBatchBounds;
50 fMaxBatchLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookba ck :
51 options.fMaxBatchLookb ack;
47 52
48 rt->setLastDrawTarget(this); 53 rt->setLastDrawTarget(this);
49 54
50 #ifdef SK_DEBUG 55 #ifdef SK_DEBUG
51 static int debugID = 0; 56 static int debugID = 0;
52 fDebugID = debugID++; 57 fDebugID = debugID++;
53 #endif 58 #endif
54 } 59 }
55 60
56 GrDrawTarget::~GrDrawTarget() { 61 GrDrawTarget::~GrDrawTarget() {
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 467 }
463 468
464 void GrDrawTarget::recordBatch(GrBatch* batch) { 469 void GrDrawTarget::recordBatch(GrBatch* batch) {
465 // A closed drawTarget should never receive new/more batches 470 // A closed drawTarget should never receive new/more batches
466 SkASSERT(!this->isClosed()); 471 SkASSERT(!this->isClosed());
467 472
468 // Check if there is a Batch Draw we can batch with by linearly searching ba ck until we either 473 // Check if there is a Batch Draw we can batch with by linearly searching ba ck until we either
469 // 1) check every draw 474 // 1) check every draw
470 // 2) intersect with something 475 // 2) intersect with something
471 // 3) find a 'blocker' 476 // 3) find a 'blocker'
472 // Experimentally we have found that most batching occurs within the first 1 0 comparisons.
473 static const int kMaxLookback = 10;
474 477
475 GrBATCH_INFO("Re-Recording (%s, B%u)\n" 478 GrBATCH_INFO("Re-Recording (%s, B%u)\n"
476 "\tBounds LRTB (%f, %f, %f, %f)\n", 479 "\tBounds LRTB (%f, %f, %f, %f)\n",
477 batch->name(), 480 batch->name(),
478 batch->uniqueID(), 481 batch->uniqueID(),
479 batch->bounds().fLeft, batch->bounds().fRight, 482 batch->bounds().fLeft, batch->bounds().fRight,
480 batch->bounds().fTop, batch->bounds().fBottom); 483 batch->bounds().fTop, batch->bounds().fBottom);
481 GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str()); 484 GrBATCH_INFO(SkTabString(batch->dumpInfo(), 1).c_str());
482 GrBATCH_INFO("\tOutcome:\n"); 485 GrBATCH_INFO("\tOutcome:\n");
483 int maxCandidates = SkTMin(kMaxLookback, fBatches.count()); 486 int maxCandidates = SkTMin(fMaxBatchLookback, fBatches.count());
484 if (maxCandidates) { 487 if (maxCandidates) {
485 int i = 0; 488 int i = 0;
486 while (true) { 489 while (true) {
487 GrBatch* candidate = fBatches.fromBack(i); 490 GrBatch* candidate = fBatches.fromBack(i);
488 // We cannot continue to search backwards if the render target chang es 491 // We cannot continue to search backwards if the render target chang es
489 if (candidate->renderTargetUniqueID() != batch->renderTargetUniqueID ()) { 492 if (candidate->renderTargetUniqueID() != batch->renderTargetUniqueID ()) {
490 GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n", 493 GrBATCH_INFO("\t\tBreaking because of (%s, B%u) Rendertarget\n",
491 candidate->name(), candidate->uniqueID()); 494 candidate->name(), candidate->uniqueID());
492 break; 495 break;
493 } 496 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 } 544 }
542 545
543 return true; 546 return true;
544 } 547 }
545 548
546 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 549 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
547 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 550 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
548 this->recordBatch(batch); 551 this->recordBatch(batch);
549 batch->unref(); 552 batch->unref();
550 } 553 }
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