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

Unified Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 746243002: Create GrOptDrawState directly in the cmd buffer in GrIODB. (Closed) Base URL: https://skia.googlesource.com/skia.git@recorder
Patch Set: Address comments 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
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrOptDrawState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrInOrderDrawBuffer.cpp
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 2f90373c339f581f0b1adf81e4dc251ec04f522a..7fc201fb0bcabda18c6f9c899151f000ef539d9b 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -20,7 +20,7 @@ GrInOrderDrawBuffer::GrInOrderDrawBuffer(GrGpu* gpu,
GrIndexBufferAllocPool* indexPool)
: INHERITED(gpu->getContext())
, fCmdBuffer(kCmdBufferInitialSizeInBytes)
- , fLastState(NULL)
+ , fPrevState(NULL)
, fDstGpu(gpu)
, fVertexPool(*vertexPool)
, fIndexPool(*indexPool)
@@ -435,7 +435,7 @@ void GrInOrderDrawBuffer::reset() {
this->resetIndexSource();
fCmdBuffer.reset();
- fLastState.reset(NULL);
+ fPrevState = NULL;
fVertexPool.reset();
fIndexPool.reset();
reset_data_buffer(&fPathIndexBuffer, kPathIdxBufferMinReserve);
@@ -470,7 +470,7 @@ void GrInOrderDrawBuffer::flush() {
// Updated every time we find a set state cmd to reflect the current state in the playback
// stream.
- SkAutoTUnref<const GrOptDrawState> currentOptState;
+ const GrOptDrawState* currentOptState = NULL;
while (iter.next()) {
GrGpuTraceMarker newMarker("", -1);
@@ -484,9 +484,9 @@ void GrInOrderDrawBuffer::flush() {
if (kSetState_Cmd == strip_trace_bit(iter->fType)) {
SetState* ss = reinterpret_cast<SetState*>(iter.get());
- currentOptState.reset(SkRef(ss->fState.get()));
+ currentOptState = &ss->fState;
} else {
- iter->execute(this, currentOptState.get());
+ iter->execute(this, currentOptState);
}
if (cmd_has_trace_marker(iter->fType)) {
@@ -502,29 +502,32 @@ void GrInOrderDrawBuffer::flush() {
}
void GrInOrderDrawBuffer::Draw::execute(GrInOrderDrawBuffer* buf, const GrOptDrawState* optState) {
+ SkASSERT(optState);
buf->fDstGpu->draw(*optState, fInfo);
}
void GrInOrderDrawBuffer::StencilPath::execute(GrInOrderDrawBuffer* buf,
const GrOptDrawState* optState) {
+ SkASSERT(optState);
buf->fDstGpu->stencilPath(*optState, this->path(), fStencilSettings);
}
void GrInOrderDrawBuffer::DrawPath::execute(GrInOrderDrawBuffer* buf,
const GrOptDrawState* optState) {
+ SkASSERT(optState);
buf->fDstGpu->drawPath(*optState, this->path(), fStencilSettings);
}
void GrInOrderDrawBuffer::DrawPaths::execute(GrInOrderDrawBuffer* buf,
const GrOptDrawState* optState) {
+ SkASSERT(optState);
buf->fDstGpu->drawPaths(*optState, this->pathRange(),
&buf->fPathIndexBuffer[fIndicesLocation], fCount,
&buf->fPathTransformBuffer[fTransformsLocation], fTransformsType,
fStencilSettings);
}
-void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDrawState*) {
-}
+void GrInOrderDrawBuffer::SetState::execute(GrInOrderDrawBuffer*, const GrOptDrawState*) {}
void GrInOrderDrawBuffer::Clear::execute(GrInOrderDrawBuffer* buf, const GrOptDrawState*) {
if (GrColor_ILLEGAL == fColor) {
@@ -727,15 +730,16 @@ bool GrInOrderDrawBuffer::recordStateAndShouldDraw(const GrDrawState& ds,
GrGpu::DrawType drawType,
const GrClipMaskManager::ScissorState& scissor,
const GrDeviceCoordTexture* dstCopy) {
- SkAutoTUnref<GrOptDrawState> optState(
- SkNEW_ARGS(GrOptDrawState, (ds, fDstGpu, scissor, dstCopy, drawType)));
- if (optState->mustSkip()) {
+ SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState,
+ (ds, fDstGpu, scissor, dstCopy, drawType));
+ if (ss->fState.mustSkip()) {
+ fCmdBuffer.pop_back();
return false;
}
- if (!fLastState || *optState != *fLastState) {
- SetState* ss = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, SetState, (optState));
- fLastState.reset(SkRef(optState.get()));
- ss->fDrawType = drawType;
+ if (fPrevState && *fPrevState == ss->fState) {
+ fCmdBuffer.pop_back();
+ } else {
+ fPrevState = &ss->fState;
this->recordTraceMarkersIfNecessary();
}
return true;
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/GrOptDrawState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698