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

Unified Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 739673002: Create GrOptDrawState before recording draw in GrInOrderDrawBuffer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: more Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: src/gpu/GrInOrderDrawBuffer.cpp
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index b0504b75a970e1c19cfbecfc9a32d7129085d488..b34c4accf2b88c88c42116a1a1d0f04b3bd6c2c9 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -11,7 +11,6 @@
#include "GrDefaultGeoProcFactory.h"
#include "GrDrawTargetCaps.h"
#include "GrGpu.h"
-#include "GrOptDrawState.h"
#include "GrTemplates.h"
#include "GrTextStrike.h"
#include "GrTexture.h"
@@ -262,9 +261,11 @@ void GrInOrderDrawBuffer::onDraw(const GrDrawState& ds,
const GrClipMaskManager::ScissorState& scissorState) {
GeometryPoolState& poolState = fGeoPoolStateStack.back();
- this->recordStateIfNecessary(ds,
- GrGpu::PrimTypeToDrawType(info.primitiveType()),
- info.getDstCopy());
+ if (!this->recordStateAndShouldDraw(ds,
+ GrGpu::PrimTypeToDrawType(info.primitiveType()),
egdaniel 2014/11/19 15:00:36 align
bsalomon 2014/11/19 15:09:38 Done.
+ info.getDstCopy())) {
+ return;
+ }
const GrVertexBuffer* vb;
if (kBuffer_GeometrySrcType == this->getGeomSrc().fVertexSrc) {
@@ -316,7 +317,9 @@ void GrInOrderDrawBuffer::onStencilPath(const GrDrawState& ds,
const GrClipMaskManager::ScissorState& scissorState,
const GrStencilSettings& stencilSettings) {
// Only compare the subset of GrDrawState relevant to path stenciling?
- this->recordStateIfNecessary(ds, GrGpu::kStencilPath_DrawType, NULL);
+ if (!this->recordStateAndShouldDraw(ds, GrGpu::kStencilPath_DrawType, NULL)) {
+ return;
+ }
StencilPath* sp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, StencilPath, (path));
sp->fScissorState = scissorState;
sp->fStencilSettings = stencilSettings;
@@ -329,7 +332,9 @@ void GrInOrderDrawBuffer::onDrawPath(const GrDrawState& ds,
const GrStencilSettings& stencilSettings,
const GrDeviceCoordTexture* dstCopy) {
// TODO: Only compare the subset of GrDrawState relevant to path covering?
- this->recordStateIfNecessary(ds, GrGpu::kDrawPath_DrawType, dstCopy);
+ if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, dstCopy)) {
+ return;
+ }
DrawPath* dp = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, DrawPath, (path));
if (dstCopy) {
dp->fDstCopy = *dstCopy;
@@ -352,7 +357,9 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrDrawState& ds,
SkASSERT(indices);
SkASSERT(transforms);
- this->recordStateIfNecessary(ds, GrGpu::kDrawPaths_DrawType, dstCopy);
+ if (!this->recordStateAndShouldDraw(ds, GrGpu::kDrawPath_DrawType, dstCopy)) {
+ return;
+ }
uint32_t* savedIndices = fPathIndexBuffer.append(count, indices);
float* savedTransforms = fPathTransformBuffer.append(count *
@@ -438,7 +445,7 @@ void GrInOrderDrawBuffer::reset() {
this->resetIndexSource();
fCmdBuffer.reset();
- fLastState = NULL;
+ fLastState.reset(NULL);
fVertexPool.reset();
fIndexPool.reset();
reset_data_buffer(&fPathIndexBuffer, kPathIdxBufferMinReserve);
@@ -471,8 +478,8 @@ void GrInOrderDrawBuffer::flush() {
int currCmdMarker = 0;
fDstGpu->saveActiveTraceMarkers();
- // Gpu no longer maintains the current drawstate, so we track the setstate calls below.
- // NOTE: we always record a new drawstate at flush boundaries
+ // Updated every time we find a set state cmd to reflect the current state in the playback
+ // stream.
SkAutoTUnref<const GrOptDrawState> currentOptState;
while (iter.next()) {
@@ -487,10 +494,7 @@ void GrInOrderDrawBuffer::flush() {
if (kSetState_Cmd == strip_trace_bit(iter->fType)) {
SetState* ss = reinterpret_cast<SetState*>(iter.get());
- currentOptState.reset(GrOptDrawState::Create(ss->fState,
- fDstGpu,
- &ss->fDstCopy,
- ss->fDrawType));
+ currentOptState.reset(SkRef(ss->fState.get()));
} else {
iter->execute(this, currentOptState.get());
}
@@ -747,45 +751,23 @@ void GrInOrderDrawBuffer::geometrySourceWillPop(const GeometrySrcState& restored
}
}
-void GrInOrderDrawBuffer::recordStateIfNecessary(const GrDrawState& ds,
- GrGpu::DrawType drawType,
- const GrDeviceCoordTexture* dstCopy) {
- if (!fLastState) {
- SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (ds));
- fLastState = &ss->fState;
+bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
+ GrGpu::DrawType drawType,
+ const GrDeviceCoordTexture* dstCopy) {
+ SkAutoTUnref<GrOptDrawState> optState(GrOptDrawState::Create(ds, fDstGpu, dstCopy, drawType));
+ if (!optState) {
+ return false;
+ }
+ if (!fLastState || *optState != *fLastState) {
+ SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (optState));
+ fLastState.reset(SkRef(optState.get()));
if (dstCopy) {
ss->fDstCopy = *dstCopy;
}
ss->fDrawType = drawType;
- this->convertDrawStateToPendingExec(fLastState);
this->recordTraceMarkersIfNecessary();
- return;
- }
- switch (GrDrawState::CombineIfPossible(*fLastState, ds, *this->caps())) {
- case GrDrawState::kIncompatible_CombinedState: {
- SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (ds));
- fLastState = &ss->fState;
- if (dstCopy) {
- ss->fDstCopy = *dstCopy;
- }
- ss->fDrawType = drawType;
- this->convertDrawStateToPendingExec(fLastState);
- this->recordTraceMarkersIfNecessary();
- break;
- }
- case GrDrawState::kA_CombinedState:
- case GrDrawState::kAOrB_CombinedState: // Treat the same as kA.
- break;
- case GrDrawState::kB_CombinedState:
- // prev has already been converted to pending execution. That is a one-way ticket.
- // So here we just destruct the previous state and reinit with a new copy of curr.
- // Note that this goes away when we move GrIODB over to taking optimized snapshots
- // of draw states.
- fLastState->~GrDrawState();
- SkNEW_PLACEMENT_ARGS(fLastState, GrDrawState, (ds));
- this->convertDrawStateToPendingExec(fLastState);
- break;
}
+ return true;
}
void GrInOrderDrawBuffer::recordTraceMarkersIfNecessary() {

Powered by Google App Engine
This is Rietveld 408576698