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

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

Issue 912413002: Pass in ProcOptInfos into willNeedDstCopy on XPs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "GrInOrderDrawBuffer.h" 8 #include "GrInOrderDrawBuffer.h"
9 9
10 #include "GrBufferAllocPool.h" 10 #include "GrBufferAllocPool.h"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return instancesToConcat; 244 return instancesToConcat;
245 } 245 }
246 246
247 void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder, 247 void GrInOrderDrawBuffer::onDraw(const GrPipelineBuilder& pipelineBuilder,
248 const GrGeometryProcessor* gp, 248 const GrGeometryProcessor* gp,
249 const DrawInfo& info, 249 const DrawInfo& info,
250 const GrScissorState& scissorState) { 250 const GrScissorState& scissorState) {
251 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer())); 251 SkASSERT(info.vertexBuffer() && (!info.isIndexed() || info.indexBuffer()));
252 this->closeBatch(); 252 this->closeBatch();
253 253
254 if (!this->recordStateAndShouldDraw(pipelineBuilder, gp, scissorState, info. getDevBounds())) { 254 if (!this->recordStateAndSetupPipeline(gp, pipelineBuilder, scissorState,
255 info.getDevBounds())) {
255 return; 256 return;
256 } 257 }
257 258
258 Draw* draw; 259 Draw* draw;
259 if (info.isInstanced()) { 260 if (info.isInstanced()) {
260 int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info) ; 261 int instancesConcated = this->concatInstancedDraw(pipelineBuilder, info) ;
261 if (info.instanceCount() > instancesConcated) { 262 if (info.instanceCount() > instancesConcated) {
262 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); 263 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info));
263 draw->fInfo.adjustInstanceCount(-instancesConcated); 264 draw->fInfo.adjustInstanceCount(-instancesConcated);
264 } else { 265 } else {
265 return; 266 return;
266 } 267 }
267 } else { 268 } else {
268 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info)); 269 draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info));
269 } 270 }
270 this->recordTraceMarkersIfNecessary(); 271 this->recordTraceMarkersIfNecessary();
271 } 272 }
272 273
273 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch, 274 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch,
274 const GrPipelineBuilder& pipelineBuilder, 275 const GrPipelineBuilder& pipelineBuilder,
275 const GrScissorState& scissorState, 276 const GrScissorState& scissorState,
276 const SkRect* devBounds) { 277 const SkRect* devBounds) {
277 if (!this->recordStateAndShouldDraw(batch, pipelineBuilder, scissorState, de vBounds)) { 278 if (!this->recordStateAndSetupPipeline(batch, pipelineBuilder, scissorState, devBounds)) {
278 return; 279 return;
279 } 280 }
280 281
281 // Check if there is a Batch Draw we can batch with 282 // Check if there is a Batch Draw we can batch with
282 if (kDrawBatch_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) { 283 if (kDrawBatch_Cmd != strip_trace_bit(fCmdBuffer.back().fType)) {
283 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch)); 284 fDrawBatch = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawBatch, (batch));
284 return; 285 return;
285 } 286 }
286 287
287 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back()); 288 DrawBatch* draw = static_cast<DrawBatch*>(&fCmdBuffer.back());
(...skipping 24 matching lines...) Expand all
312 313
313 void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder, 314 void GrInOrderDrawBuffer::onDrawPath(const GrPipelineBuilder& pipelineBuilder,
314 const GrPathProcessor* pathProc, 315 const GrPathProcessor* pathProc,
315 const GrPath* path, 316 const GrPath* path,
316 const GrScissorState& scissorState, 317 const GrScissorState& scissorState,
317 const GrStencilSettings& stencilSettings, 318 const GrStencilSettings& stencilSettings,
318 const SkRect* devBounds) { 319 const SkRect* devBounds) {
319 this->closeBatch(); 320 this->closeBatch();
320 321
321 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing? 322 // TODO: Only compare the subset of GrPipelineBuilder relevant to path cover ing?
322 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, devBounds)) { 323 if (!this->recordStateAndSetupPipeline(pathProc, pipelineBuilder, scissorSta te, devBounds)) {
323 return; 324 return;
324 } 325 }
325 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path)); 326 DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
326 dp->fStencilSettings = stencilSettings; 327 dp->fStencilSettings = stencilSettings;
327 this->recordTraceMarkersIfNecessary(); 328 this->recordTraceMarkersIfNecessary();
328 } 329 }
329 330
330 void GrInOrderDrawBuffer::onDrawPaths(const GrPipelineBuilder& pipelineBuilder, 331 void GrInOrderDrawBuffer::onDrawPaths(const GrPipelineBuilder& pipelineBuilder,
331 const GrPathProcessor* pathProc, 332 const GrPathProcessor* pathProc,
332 const GrPathRange* pathRange, 333 const GrPathRange* pathRange,
333 const void* indices, 334 const void* indices,
334 PathIndexType indexType, 335 PathIndexType indexType,
335 const float transformValues[], 336 const float transformValues[],
336 PathTransformType transformType, 337 PathTransformType transformType,
337 int count, 338 int count,
338 const GrScissorState& scissorState, 339 const GrScissorState& scissorState,
339 const GrStencilSettings& stencilSettings, 340 const GrStencilSettings& stencilSettings,
340 const SkRect* devBounds) { 341 const SkRect* devBounds) {
341 SkASSERT(pathRange); 342 SkASSERT(pathRange);
342 SkASSERT(indices); 343 SkASSERT(indices);
343 SkASSERT(transformValues); 344 SkASSERT(transformValues);
344 this->closeBatch(); 345 this->closeBatch();
345 346
346 if (!this->recordStateAndShouldDraw(pipelineBuilder, pathProc, scissorState, devBounds)) { 347 if (!this->recordStateAndSetupPipeline(pathProc, pipelineBuilder, scissorSta te, devBounds)) {
347 return; 348 return;
348 } 349 }
349 350
350 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType); 351 int indexBytes = GrPathRange::PathIndexSizeInBytes(indexType);
351 if (int misalign = fPathIndexBuffer.count() % indexBytes) { 352 if (int misalign = fPathIndexBuffer.count() % indexBytes) {
352 // Add padding to the index buffer so the indices are aligned properly. 353 // Add padding to the index buffer so the indices are aligned properly.
353 fPathIndexBuffer.append(indexBytes - misalign); 354 fPathIndexBuffer.append(indexBytes - misalign);
354 } 355 }
355 356
356 char* savedIndices = fPathIndexBuffer.append(count * indexBytes, 357 char* savedIndices = fPathIndexBuffer.append(count * indexBytes,
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 if (getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) { 578 if (getGpu()->canCopySurface(dst, src, srcRect, dstPoint)) {
578 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst , src)); 579 CopySurface* cs = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, CopySurface, (dst , src));
579 cs->fSrcRect = srcRect; 580 cs->fSrcRect = srcRect;
580 cs->fDstPoint = dstPoint; 581 cs->fDstPoint = dstPoint;
581 this->recordTraceMarkersIfNecessary(); 582 this->recordTraceMarkersIfNecessary();
582 return true; 583 return true;
583 } 584 }
584 return false; 585 return false;
585 } 586 }
586 587
587 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrPipelineBuilder& pipe lineBuilder, 588 bool GrInOrderDrawBuffer::recordStateAndSetupPipeline(const GrPrimitiveProcessor * primProc,
588 const GrPrimitiveProcessor* p rimProc, 589 const GrPipelineBuilder& p ipelineBuilder,
589 const GrScissorState& scissor , 590 const GrScissorState& scis sor,
590 const SkRect* devBounds) { 591 const SkRect* devBounds) {
592 const GrProcOptInfo& colorPOI = pipelineBuilder.colorProcInfo(primProc);
593 const GrProcOptInfo& coveragePOI = pipelineBuilder.coverageProcInfo(primProc );
594
591 GrDeviceCoordTexture dstCopy; 595 GrDeviceCoordTexture dstCopy;
592 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) { 596 if (!this->setupDstReadIfNecessary(pipelineBuilder, colorPOI, coveragePOI,
597 &dstCopy, devBounds)) {
593 return false; 598 return false;
594 } 599 }
595 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, 600 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
596 (pipelineBuilder, primProc, *this->g etGpu()->caps(), 601 (pipelineBuilder, colorPOI, coverage POI,
597 scissor, &dstCopy)); 602 *this->getGpu()->caps(), scissor, & dstCopy, primProc));
598 if (ss->fPipeline.mustSkip()) { 603 if (ss->fPipeline.mustSkip()) {
599 fCmdBuffer.pop_back(); 604 fCmdBuffer.pop_back();
600 return false; 605 return false;
601 } 606 }
602 607
603 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker, 608 ss->fPrimitiveProcessor->initBatchTracker(&ss->fBatchTracker,
604 ss->fPipeline.getInitBatchTracker( )); 609 ss->fPipeline.getInitBatchTracker( ));
605 610
606 if (fPrevState && fPrevState->fPrimitiveProcessor.get() && 611 if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
607 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker, 612 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
608 *ss->fPrimitiveProcessor, 613 *ss->fPrimitiveProcessor,
609 ss->fBatchTracker) && 614 ss->fBatchTracker) &&
610 fPrevState->fPipeline.isEqual(ss->fPipeline)) { 615 fPrevState->fPipeline.isEqual(ss->fPipeline)) {
611 fCmdBuffer.pop_back(); 616 fCmdBuffer.pop_back();
612 } else { 617 } else {
613 fPrevState = ss; 618 fPrevState = ss;
614 this->recordTraceMarkersIfNecessary(); 619 this->recordTraceMarkersIfNecessary();
615 } 620 }
616 return true; 621 return true;
617 } 622 }
618 623
619 bool GrInOrderDrawBuffer::recordStateAndShouldDraw(GrBatch* batch, 624 bool GrInOrderDrawBuffer::recordStateAndSetupPipeline(GrBatch* batch,
620 const GrPipelineBuilder& pipe lineBuilder, 625 const GrPipelineBuilder& p ipelineBuilder,
621 const GrScissorState& scissor , 626 const GrScissorState& scis sor,
622 const SkRect* devBounds) { 627 const SkRect* devBounds) {
628 GrBatchOpt batchOpt;
bsalomon 2015/02/11 15:38:03 seems weird that we're doing this here.
egdaniel 2015/02/11 16:48:08 So the reason we are doing this here is that we ne
bsalomon 2015/02/11 16:51:23 It seems to like everything from 628 to 643 should
629 batchOpt.fCanTweakAlphaForCoverage = pipelineBuilder.canTweakAlphaForCoverag e();
630 batch->initBatchOpt(batchOpt);
631
632 const GrProcOptInfo& colorPOI = pipelineBuilder.colorProcInfo(batch);
633 const GrProcOptInfo& coveragePOI = pipelineBuilder.coverageProcInfo(batch);
634
623 GrDeviceCoordTexture dstCopy; 635 GrDeviceCoordTexture dstCopy;
624 if (!this->setupDstReadIfNecessary(pipelineBuilder, &dstCopy, devBounds)) { 636 if (!this->setupDstReadIfNecessary(pipelineBuilder, colorPOI, coveragePOI,
637 &dstCopy, devBounds)) {
625 return false; 638 return false;
626 } 639 }
627 // TODO this gets much simpler when we have batches everywhere. 640 // TODO this gets much simpler when we have batches everywhere.
628 // If the previous command is also a set state, then we check to see if it h as a Batch. If so, 641 // If the previous command is also a set state, then we check to see if it h as a Batch. If so,
629 // and we can make the two batches equal, and we can combine the states, the n we make them equal 642 // and we can make the two batches equal, and we can combine the states, the n we make them equal
630 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, 643 SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
631 (batch, pipelineBuilder, *this->getG pu()->caps(), scissor, 644 (pipelineBuilder, colorPOI, coverage POI,
632 &dstCopy)); 645 *this->getGpu()->caps(), scissor, & dstCopy));
633 if (ss->fPipeline.mustSkip()) { 646 if (ss->fPipeline.mustSkip()) {
634 fCmdBuffer.pop_back(); 647 fCmdBuffer.pop_back();
635 return false; 648 return false;
636 } 649 }
637 650
638 batch->initBatchTracker(ss->fPipeline.getInitBatchTracker()); 651 batch->initBatchTracker(ss->fPipeline.getInitBatchTracker());
639 652
640 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() && 653 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
641 fPrevState->fPipeline.isEqual(ss->fPipeline)) { 654 fPrevState->fPipeline.isEqual(ss->fPipeline)) {
642 fCmdBuffer.pop_back(); 655 fCmdBuffer.pop_back();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 int vcount = vertexCount; 695 int vcount = vertexCount;
683 int icount = indexCount; 696 int icount = indexCount;
684 697
685 if (!insideGeoPush && 698 if (!insideGeoPush &&
686 !unreleasedVertexSpace && 699 !unreleasedVertexSpace &&
687 !unreleasedIndexSpace && 700 !unreleasedIndexSpace &&
688 this->geometryHints(vertexStride, &vcount, &icount)) { 701 this->geometryHints(vertexStride, &vcount, &icount)) {
689 this->flush(); 702 this->flush();
690 } 703 }
691 } 704 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698