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

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

Issue 1897203002: Implement instanced rendering for simple shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@upload2_requireHWAA
Patch Set: comments Created 4 years, 7 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"
11 #include "GrCaps.h" 11 #include "GrCaps.h"
12 #include "GrGpu.h" 12 #include "GrGpu.h"
13 #include "GrPath.h" 13 #include "GrPath.h"
14 #include "GrPipeline.h" 14 #include "GrPipeline.h"
15 #include "GrMemoryPool.h" 15 #include "GrMemoryPool.h"
16 #include "GrRenderTarget.h" 16 #include "GrRenderTarget.h"
17 #include "GrResourceProvider.h" 17 #include "GrResourceProvider.h"
18 #include "GrRenderTargetPriv.h" 18 #include "GrRenderTargetPriv.h"
19 #include "GrInstancedRendering.h"
19 #include "GrSurfacePriv.h" 20 #include "GrSurfacePriv.h"
20 #include "GrTexture.h" 21 #include "GrTexture.h"
21 #include "gl/GrGLRenderTarget.h" 22 #include "gl/GrGLRenderTarget.h"
22 23
23 #include "SkStrokeRec.h" 24 #include "SkStrokeRec.h"
24 25
25 #include "batches/GrClearBatch.h" 26 #include "batches/GrClearBatch.h"
26 #include "batches/GrCopySurfaceBatch.h" 27 #include "batches/GrCopySurfaceBatch.h"
27 #include "batches/GrDiscardBatch.h" 28 #include "batches/GrDiscardBatch.h"
28 #include "batches/GrDrawBatch.h" 29 #include "batches/GrDrawBatch.h"
29 #include "batches/GrDrawPathBatch.h" 30 #include "batches/GrDrawPathBatch.h"
30 #include "batches/GrRectBatchFactory.h" 31 #include "batches/GrRectBatchFactory.h"
31 #include "batches/GrStencilPathBatch.h" 32 #include "batches/GrStencilPathBatch.h"
32 33
33 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
34 35
35 // Experimentally we have found that most batching occurs within the first 10 co mparisons. 36 // Experimentally we have found that most batching occurs within the first 10 co mparisons.
36 static const int kDefaultMaxBatchLookback = 10; 37 static const int kDefaultMaxBatchLookback = 10;
37 static const int kDefaultMaxBatchLookahead = 10; 38 static const int kDefaultMaxBatchLookahead = 10;
38 39
39 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider, 40 GrDrawTarget::GrDrawTarget(GrRenderTarget* rt, GrGpu* gpu, GrResourceProvider* r esourceProvider,
40 GrAuditTrail* auditTrail, const Options& options) 41 GrAuditTrail* auditTrail, const Options& options)
41 : fGpu(SkRef(gpu)) 42 : fGpu(SkRef(gpu))
42 , fResourceProvider(resourceProvider) 43 , fResourceProvider(resourceProvider)
43 , fAuditTrail(auditTrail) 44 , fAuditTrail(auditTrail)
44 , fFlags(0) 45 , fFlags(0)
45 , fRenderTarget(rt) { 46 , fRenderTarget(rt)
47 , fInstancedRendering(fGpu->createInstancedRenderingIfSupported()) {
46 // TODO: Stop extracting the context (currently needed by GrClipMaskManager) 48 // TODO: Stop extracting the context (currently needed by GrClipMaskManager)
47 fContext = fGpu->getContext(); 49 fContext = fGpu->getContext();
48 fClipMaskManager.reset(new GrClipMaskManager(this, options.fClipBatchToBound s)); 50 fClipMaskManager.reset(new GrClipMaskManager(this, options.fClipBatchToBound s));
49 51
50 fDrawBatchBounds = options.fDrawBatchBounds; 52 fDrawBatchBounds = options.fDrawBatchBounds;
51 fMaxBatchLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookba ck : 53 fMaxBatchLookback = (options.fMaxBatchLookback < 0) ? kDefaultMaxBatchLookba ck :
52 options.fMaxBatchLookb ack; 54 options.fMaxBatchLookb ack;
53 fMaxBatchLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLook ahead : 55 fMaxBatchLookahead = (options.fMaxBatchLookahead < 0) ? kDefaultMaxBatchLook ahead :
54 options.fMaxBatchLook ahead; 56 options.fMaxBatchLook ahead;
55 57
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // but need to be flushed anyway. Closing such drawTargets here will mean ne w 197 // but need to be flushed anyway. Closing such drawTargets here will mean ne w
196 // drawTargets will be created to replace them if the SkGpuDevice(s) write t o them again. 198 // drawTargets will be created to replace them if the SkGpuDevice(s) write t o them again.
197 this->makeClosed(); 199 this->makeClosed();
198 200
199 // Loop over the batches that haven't yet generated their geometry 201 // Loop over the batches that haven't yet generated their geometry
200 for (int i = 0; i < fBatches.count(); ++i) { 202 for (int i = 0; i < fBatches.count(); ++i) {
201 if (fBatches[i]) { 203 if (fBatches[i]) {
202 fBatches[i]->prepare(flushState); 204 fBatches[i]->prepare(flushState);
203 } 205 }
204 } 206 }
207
208 if (fInstancedRendering) {
209 fInstancedRendering->beginFlush(flushState->resourceProvider());
210 }
205 } 211 }
206 212
207 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) { 213 void GrDrawTarget::drawBatches(GrBatchFlushState* flushState) {
208 // Draw all the generated geometry. 214 // Draw all the generated geometry.
209 SkRandom random; 215 SkRandom random;
210 for (int i = 0; i < fBatches.count(); ++i) { 216 for (int i = 0; i < fBatches.count(); ++i) {
211 if (!fBatches[i]) { 217 if (!fBatches[i]) {
212 continue; 218 continue;
213 } 219 }
214 if (fDrawBatchBounds) { 220 if (fDrawBatchBounds) {
215 const SkRect& bounds = fBatches[i]->bounds(); 221 const SkRect& bounds = fBatches[i]->bounds();
216 SkIRect ibounds; 222 SkIRect ibounds;
217 bounds.roundOut(&ibounds); 223 bounds.roundOut(&ibounds);
218 // In multi-draw buffer all the batches use the same render target a nd we won't need to 224 // In multi-draw buffer all the batches use the same render target a nd we won't need to
219 // get the batchs bounds. 225 // get the batchs bounds.
220 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) { 226 if (GrRenderTarget* rt = fBatches[i]->renderTarget()) {
221 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU() ); 227 fGpu->drawDebugWireRect(rt, ibounds, 0xFF000000 | random.nextU() );
222 } 228 }
223 } 229 }
224 fBatches[i]->draw(flushState); 230 fBatches[i]->draw(flushState);
225 } 231 }
226 232
227 fGpu->finishDrawTarget(); 233 fGpu->finishDrawTarget();
228 } 234 }
229 235
230 void GrDrawTarget::reset() { 236 void GrDrawTarget::reset() {
231 fBatches.reset(); 237 fBatches.reset();
238 if (fInstancedRendering) {
239 fInstancedRendering->endFlush();
240 }
232 } 241 }
233 242
234 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder, 243 void GrDrawTarget::drawBatch(const GrPipelineBuilder& pipelineBuilder,
235 GrDrawBatch* batch, 244 GrDrawBatch* batch,
236 const SkIRect* scissorRect) { 245 const SkIRect* scissorRect) {
237 // Setup clip 246 // Setup clip
238 GrPipelineBuilder::AutoRestoreStencil ars; 247 GrPipelineBuilder::AutoRestoreStencil ars;
239 GrAppliedClip clip; 248 GrAppliedClip clip;
240 249
241 if (scissorRect) { 250 if (scissorRect) {
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 } 607 }
599 608
600 return true; 609 return true;
601 } 610 }
602 611
603 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) { 612 void GrDrawTarget::clearStencilClip(const SkIRect& rect, bool insideClip, GrRend erTarget* rt) {
604 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt); 613 GrBatch* batch = new GrClearStencilClipBatch(rect, insideClip, rt);
605 this->recordBatch(batch); 614 this->recordBatch(batch);
606 batch->unref(); 615 batch->unref();
607 } 616 }
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