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

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

Issue 1119353002: Revert of Move state management to GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@batchownsbounds
Patch Set: Created 5 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/GrInOrderDrawBuffer.h ('k') | src/gpu/GrTargetCommands.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 * 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 "GrDefaultGeoProcFactory.h" 10 #include "GrDefaultGeoProcFactory.h"
11 #include "GrTemplates.h" 11 #include "GrTemplates.h"
12 12
13 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context, 13 GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrContext* context,
14 GrVertexBufferAllocPool* vertexPool, 14 GrVertexBufferAllocPool* vertexPool,
15 GrIndexBufferAllocPool* indexPool) 15 GrIndexBufferAllocPool* indexPool)
16 : INHERITED(context, vertexPool, indexPool) 16 : INHERITED(context, vertexPool, indexPool)
17 , fCommands(context->getGpu(), vertexPool, indexPool) 17 , fCommands(context->getGpu(), vertexPool, indexPool)
18 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4) 18 , fPathIndexBuffer(kPathIdxBufferMinReserve * sizeof(char)/4)
19 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4) 19 , fPathTransformBuffer(kPathXformBufferMinReserve * sizeof(float)/4)
20 , fPipelineBuffer(kPipelineBufferMinReserve)
21 , fDrawID(0) { 20 , fDrawID(0) {
22 21
23 SkASSERT(vertexPool); 22 SkASSERT(vertexPool);
24 SkASSERT(indexPool); 23 SkASSERT(indexPool);
25 } 24 }
26 25
27 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() { 26 GrInOrderDrawBuffer::~GrInOrderDrawBuffer() {
28 this->reset(); 27 this->reset();
29 } 28 }
30 29
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 } else { 293 } else {
295 geometry.fHasLocalMatrix = false; 294 geometry.fHasLocalMatrix = false;
296 } 295 }
297 296
298 SkAutoTUnref<GrBatch> batch(RectBatch::Create(geometry)); 297 SkAutoTUnref<GrBatch> batch(RectBatch::Create(geometry));
299 this->drawBatch(pipelineBuilder, batch); 298 this->drawBatch(pipelineBuilder, batch);
300 } 299 }
301 300
302 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch, 301 void GrInOrderDrawBuffer::onDrawBatch(GrBatch* batch,
303 const PipelineInfo& pipelineInfo) { 302 const PipelineInfo& pipelineInfo) {
304 State* state = this->setupPipelineAndShouldDraw(batch, pipelineInfo); 303 GrTargetCommands::Cmd* cmd = fCommands.recordDrawBatch(this, batch, pipeline Info);
305 if (!state) {
306 return;
307 }
308
309 GrTargetCommands::Cmd* cmd = fCommands.recordDrawBatch(state, batch);
310 this->recordTraceMarkersIfNecessary(cmd); 304 this->recordTraceMarkersIfNecessary(cmd);
311 } 305 }
312 306
313 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder , 307 void GrInOrderDrawBuffer::onStencilPath(const GrPipelineBuilder& pipelineBuilder ,
314 const GrPathProcessor* pathProc, 308 const GrPathProcessor* pathProc,
315 const GrPath* path, 309 const GrPath* path,
316 const GrScissorState& scissorState, 310 const GrScissorState& scissorState,
317 const GrStencilSettings& stencilSettings ) { 311 const GrStencilSettings& stencilSettings ) {
318 GrTargetCommands::Cmd* cmd = fCommands.recordStencilPath(pipelineBuilder, 312 GrTargetCommands::Cmd* cmd = fCommands.recordStencilPath(this, pipelineBuild er,
319 pathProc, path, sci ssorState, 313 pathProc, path, sci ssorState,
320 stencilSettings); 314 stencilSettings);
321 this->recordTraceMarkersIfNecessary(cmd); 315 this->recordTraceMarkersIfNecessary(cmd);
322 } 316 }
323 317
324 void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc, 318 void GrInOrderDrawBuffer::onDrawPath(const GrPathProcessor* pathProc,
325 const GrPath* path, 319 const GrPath* path,
326 const GrStencilSettings& stencilSettings, 320 const GrStencilSettings& stencilSettings,
327 const PipelineInfo& pipelineInfo) { 321 const PipelineInfo& pipelineInfo) {
328 State* state = this->setupPipelineAndShouldDraw(pathProc, pipelineInfo); 322 GrTargetCommands::Cmd* cmd = fCommands.recordDrawPath(this, pathProc,
329 if (!state) { 323 path, stencilSettings,
330 return; 324 pipelineInfo);
331 }
332 GrTargetCommands::Cmd* cmd = fCommands.recordDrawPath(state, pathProc, path, stencilSettings);
333 this->recordTraceMarkersIfNecessary(cmd); 325 this->recordTraceMarkersIfNecessary(cmd);
334 } 326 }
335 327
336 void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc, 328 void GrInOrderDrawBuffer::onDrawPaths(const GrPathProcessor* pathProc,
337 const GrPathRange* pathRange, 329 const GrPathRange* pathRange,
338 const void* indices, 330 const void* indices,
339 PathIndexType indexType, 331 PathIndexType indexType,
340 const float transformValues[], 332 const float transformValues[],
341 PathTransformType transformType, 333 PathTransformType transformType,
342 int count, 334 int count,
343 const GrStencilSettings& stencilSettings, 335 const GrStencilSettings& stencilSettings,
344 const PipelineInfo& pipelineInfo) { 336 const PipelineInfo& pipelineInfo) {
345 State* state = this->setupPipelineAndShouldDraw(pathProc, pipelineInfo); 337 GrTargetCommands::Cmd* cmd = fCommands.recordDrawPaths(this, pathProc, pathR ange,
346 if (!state) {
347 return;
348 }
349 GrTargetCommands::Cmd* cmd = fCommands.recordDrawPaths(state, this, pathProc , pathRange,
350 indices, indexType, t ransformValues, 338 indices, indexType, t ransformValues,
351 transformType, count, 339 transformType, count,
352 stencilSettings, pipe lineInfo); 340 stencilSettings, pipe lineInfo);
353 this->recordTraceMarkersIfNecessary(cmd); 341 this->recordTraceMarkersIfNecessary(cmd);
354 } 342 }
355 343
356 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color, 344 void GrInOrderDrawBuffer::onClear(const SkIRect* rect, GrColor color,
357 bool canIgnoreRect, GrRenderTarget* renderTarg et) { 345 bool canIgnoreRect, GrRenderTarget* renderTarg et) {
358 GrTargetCommands::Cmd* cmd = fCommands.recordClear(rect, color, canIgnoreRec t, renderTarget); 346 GrTargetCommands::Cmd* cmd = fCommands.recordClear(this, rect, color,
347 canIgnoreRect, renderTarg et);
359 this->recordTraceMarkersIfNecessary(cmd); 348 this->recordTraceMarkersIfNecessary(cmd);
360 } 349 }
361 350
362 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect, 351 void GrInOrderDrawBuffer::clearStencilClip(const SkIRect& rect,
363 bool insideClip, 352 bool insideClip,
364 GrRenderTarget* renderTarget) { 353 GrRenderTarget* renderTarget) {
365 GrTargetCommands::Cmd* cmd = fCommands.recordClearStencilClip(rect, insideCl ip, renderTarget); 354 GrTargetCommands::Cmd* cmd = fCommands.recordClearStencilClip(this, rect,
355 insideClip, re nderTarget);
366 this->recordTraceMarkersIfNecessary(cmd); 356 this->recordTraceMarkersIfNecessary(cmd);
367 } 357 }
368 358
369 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) { 359 void GrInOrderDrawBuffer::discard(GrRenderTarget* renderTarget) {
370 if (!this->caps()->discardRenderTargetSupport()) { 360 if (!this->caps()->discardRenderTargetSupport()) {
371 return; 361 return;
372 } 362 }
373 363
374 GrTargetCommands::Cmd* cmd = fCommands.recordDiscard(renderTarget); 364 GrTargetCommands::Cmd* cmd = fCommands.recordDiscard(this, renderTarget);
375 this->recordTraceMarkersIfNecessary(cmd); 365 this->recordTraceMarkersIfNecessary(cmd);
376 } 366 }
377 367
378 void GrInOrderDrawBuffer::onReset() { 368 void GrInOrderDrawBuffer::onReset() {
379 fCommands.reset(); 369 fCommands.reset();
380 fPathIndexBuffer.rewind(); 370 fPathIndexBuffer.rewind();
381 fPathTransformBuffer.rewind(); 371 fPathTransformBuffer.rewind();
382 fGpuCmdMarkers.reset(); 372 fGpuCmdMarkers.reset();
383
384 fPrevState.reset(NULL);
385 // Note, fPrevState points into fPipelineBuffer's allocation, so we have to reset first.
386 // Furthermore, we have to reset fCommands before fPipelineBuffer too.
387 if (fDrawID % kPipelineBufferHighWaterMark) {
388 fPipelineBuffer.rewind();
389 } else {
390 fPipelineBuffer.reset();
391 }
392 } 373 }
393 374
394 void GrInOrderDrawBuffer::onFlush() { 375 void GrInOrderDrawBuffer::onFlush() {
395 fCommands.flush(this); 376 fCommands.flush(this);
396 ++fDrawID; 377 ++fDrawID;
397 } 378 }
398 379
399 void GrInOrderDrawBuffer::onCopySurface(GrSurface* dst, 380 void GrInOrderDrawBuffer::onCopySurface(GrSurface* dst,
400 GrSurface* src, 381 GrSurface* src,
401 const SkIRect& srcRect, 382 const SkIRect& srcRect,
(...skipping 10 matching lines...) Expand all
412 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers(); 393 const GrTraceMarkerSet& activeTraceMarkers = this->getActiveTraceMarkers();
413 if (activeTraceMarkers.count() > 0) { 394 if (activeTraceMarkers.count() > 0) {
414 if (cmd->isTraced()) { 395 if (cmd->isTraced()) {
415 fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers); 396 fGpuCmdMarkers[cmd->markerID()].addSet(activeTraceMarkers);
416 } else { 397 } else {
417 cmd->setMarkerID(fGpuCmdMarkers.count()); 398 cmd->setMarkerID(fGpuCmdMarkers.count());
418 fGpuCmdMarkers.push_back(activeTraceMarkers); 399 fGpuCmdMarkers.push_back(activeTraceMarkers);
419 } 400 }
420 } 401 }
421 } 402 }
422
423 GrTargetCommands::State*
424 GrInOrderDrawBuffer::setupPipelineAndShouldDraw(const GrPrimitiveProcessor* prim Proc,
425 const GrDrawTarget::PipelineInfo & pipelineInfo) {
426 State* state = this->allocState();
427 this->setupPipeline(pipelineInfo, state->pipelineLocation());
428
429 if (state->getPipeline()->mustSkip()) {
430 this->unallocState(state);
431 return NULL;
432 }
433
434 state->fPrimitiveProcessor->initBatchTracker(&state->fBatchTracker,
435 state->getPipeline()->getInitBa tchTracker());
436
437 if (fPrevState && fPrevState->fPrimitiveProcessor.get() &&
438 fPrevState->fPrimitiveProcessor->canMakeEqual(fPrevState->fBatchTracker,
439 *state->fPrimitiveProcesso r,
440 state->fBatchTracker) &&
441 fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
442 this->unallocState(state);
443 } else {
444 fPrevState.reset(state);
445 }
446
447 fCommands.recordXferBarrierIfNecessary(*fPrevState->getPipeline(), this);
448 return fPrevState;
449 }
450
451 GrTargetCommands::State*
452 GrInOrderDrawBuffer::setupPipelineAndShouldDraw(GrBatch* batch,
453 const GrDrawTarget::PipelineInfo & pipelineInfo) {
454 State* state = this->allocState();
455 this->setupPipeline(pipelineInfo, state->pipelineLocation());
456
457 if (state->getPipeline()->mustSkip()) {
458 this->unallocState(state);
459 return NULL;
460 }
461
462 batch->initBatchTracker(state->getPipeline()->getInitBatchTracker());
463
464 if (fPrevState && !fPrevState->fPrimitiveProcessor.get() &&
465 fPrevState->getPipeline()->isEqual(*state->getPipeline())) {
466 this->unallocState(state);
467 } else {
468 fPrevState.reset(state);
469 }
470
471 fCommands.recordXferBarrierIfNecessary(*fPrevState->getPipeline(), this);
472 return fPrevState;
473 }
OLDNEW
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrTargetCommands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698