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

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

Issue 1421853002: Add immediate mode option for gpu configs in dm (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add assert 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') | src/gpu/GrDrawingManager.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 /* 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 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider) 35 GrDrawTarget::GrDrawTarget(GrGpu* gpu, GrResourceProvider* resourceProvider,
36 const Options& options)
36 : fGpu(SkRef(gpu)) 37 : fGpu(SkRef(gpu))
37 , fResourceProvider(resourceProvider) 38 , fResourceProvider(resourceProvider)
38 , fFlushState(fGpu, fResourceProvider, 0) 39 , fFlushState(fGpu, fResourceProvider, 0)
39 , fFlushing(false) 40 , fFlushing(false)
40 , fFirstUnpreparedBatch(0) 41 , fFirstUnpreparedBatch(0)
41 , fFlags(0) { 42 , fFlags(0)
43 , fOptions(options) {
42 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) 44 // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
43 fContext = fGpu->getContext(); 45 fContext = fGpu->getContext();
44 fClipMaskManager.reset(new GrClipMaskManager(this)); 46 fClipMaskManager.reset(new GrClipMaskManager(this));
45 47
46 #ifdef SK_DEBUG 48 #ifdef SK_DEBUG
47 static int debugID = 0; 49 static int debugID = 0;
48 fDebugID = debugID++; 50 fDebugID = debugID++;
49 #endif 51 #endif
50 } 52 }
51 53
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 467
466 template <class Left, class Right> static bool intersect(const Left& a, const Ri ght& b) { 468 template <class Left, class Right> static bool intersect(const Left& a, const Ri ght& b) {
467 SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom && 469 SkASSERT(a.fLeft <= a.fRight && a.fTop <= a.fBottom &&
468 b.fLeft <= b.fRight && b.fTop <= b.fBottom); 470 b.fLeft <= b.fRight && b.fTop <= b.fBottom);
469 return a.fLeft < b.fRight && b.fLeft < a.fRight && a.fTop < b.fBottom && b.f Top < a.fBottom; 471 return a.fLeft < b.fRight && b.fLeft < a.fRight && a.fTop < b.fBottom && b.f Top < a.fBottom;
470 } 472 }
471 473
472 void GrDrawTarget::recordBatch(GrBatch* batch) { 474 void GrDrawTarget::recordBatch(GrBatch* batch) {
473 // A closed drawTarget should never receive new/more batches 475 // A closed drawTarget should never receive new/more batches
474 SkASSERT(!this->isClosed()); 476 SkASSERT(!this->isClosed());
477 // Should never have batches queued up when in immediate mode.
478 SkASSERT(!fOptions.fImmediateMode || !fBatches.count());
475 479
476 // Check if there is a Batch Draw we can batch with by linearly searching ba ck until we either 480 // Check if there is a Batch Draw we can batch with by linearly searching ba ck until we either
477 // 1) check every draw 481 // 1) check every draw
478 // 2) intersect with something 482 // 2) intersect with something
479 // 3) find a 'blocker' 483 // 3) find a 'blocker'
480 // Experimentally we have found that most batching occurs within the first 1 0 comparisons. 484 // Experimentally we have found that most batching occurs within the first 1 0 comparisons.
481 static const int kMaxLookback = 10; 485 static const int kMaxLookback = 10;
482 486
483 GrBATCH_INFO("Re-Recording (%s, B%u)\n" 487 GrBATCH_INFO("Re-Recording (%s, B%u)\n"
484 "\tBounds LRTB (%f, %f, %f, %f)\n", 488 "\tBounds LRTB (%f, %f, %f, %f)\n",
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 } 521 }
518 } 522 }
519 } else { 523 } else {
520 GrBATCH_INFO("\t\tFirstBatch\n"); 524 GrBATCH_INFO("\t\tFirstBatch\n");
521 } 525 }
522 fBatches.push_back().reset(SkRef(batch)); 526 fBatches.push_back().reset(SkRef(batch));
523 if (fBatches.count() > kMaxLookback) { 527 if (fBatches.count() > kMaxLookback) {
524 SkASSERT(fBatches.count() - kMaxLookback - fFirstUnpreparedBatch == 1); 528 SkASSERT(fBatches.count() - kMaxLookback - fFirstUnpreparedBatch == 1);
525 fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState); 529 fBatches[fFirstUnpreparedBatch++]->prepare(&fFlushState);
526 } 530 }
531 if (fOptions.fImmediateMode) {
532 this->flush();
533 }
527 } 534 }
528 535
529 /////////////////////////////////////////////////////////////////////////////// 536 ///////////////////////////////////////////////////////////////////////////////
530 537
531 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB uilder, 538 bool GrDrawTarget::installPipelineInDrawBatch(const GrPipelineBuilder* pipelineB uilder,
532 const GrScissorState* scissor, 539 const GrScissorState* scissor,
533 GrDrawBatch* batch) { 540 GrDrawBatch* batch) {
534 GrPipeline::CreateArgs args; 541 GrPipeline::CreateArgs args;
535 args.fPipelineBuilder = pipelineBuilder; 542 args.fPipelineBuilder = pipelineBuilder;
536 args.fCaps = this->caps(); 543 args.fCaps = this->caps();
(...skipping 11 matching lines...) Expand all
548 } 555 }
549 556
550 return true; 557 return true;
551 } 558 }
552 559
553 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 560 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
554 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 561 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
555 this->recordBatch(batch); 562 this->recordBatch(batch);
556 batch->unref(); 563 batch->unref();
557 } 564 }
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrDrawingManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698