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

Unified Diff: src/gpu/GrInOrderDrawBuffer.cpp

Issue 439853002: Replace op== with CombineIfPossible in GrDrawState. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('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 0cab19ff04fd82eb61c5971ff1a0cc086c080302..6e447590b01720462a50224feafd723aa128888c 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -350,9 +350,7 @@ void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) {
if (this->needsNewClip()) {
this->recordClip();
}
- if (this->needsNewState()) {
- this->recordState();
- }
+ this->recordStateIfNecessary();
DrawRecord* draw;
if (info.isInstanced()) {
@@ -424,9 +422,7 @@ void GrInOrderDrawBuffer::onStencilPath(const GrPath* path, SkPath::FillType fil
this->recordClip();
}
// Only compare the subset of GrDrawState relevant to path stenciling?
- if (this->needsNewState()) {
- this->recordState();
- }
+ this->recordStateIfNecessary();
StencilPath* sp = this->recordStencilPath();
sp->fPath.reset(path);
path->ref();
@@ -439,9 +435,7 @@ void GrInOrderDrawBuffer::onDrawPath(const GrPath* path,
this->recordClip();
}
// TODO: Only compare the subset of GrDrawState relevant to path covering?
- if (this->needsNewState()) {
- this->recordState();
- }
+ this->recordStateIfNecessary();
DrawPath* cp = this->recordDrawPath();
cp->fPath.reset(path);
path->ref();
@@ -462,9 +456,7 @@ void GrInOrderDrawBuffer::onDrawPaths(const GrPathRange* pathRange,
if (this->needsNewClip()) {
this->recordClip();
}
- if (this->needsNewState()) {
- this->recordState();
- }
+ this->recordStateIfNecessary();
DrawPaths* dp = this->recordDrawPaths();
dp->fPathRange.reset(SkRef(pathRange));
dp->fIndices = SkNEW_ARRAY(uint32_t, count); // TODO: Accomplish this without a malloc
@@ -919,8 +911,26 @@ void GrInOrderDrawBuffer::geometrySourceWillPop(
}
}
-bool GrInOrderDrawBuffer::needsNewState() const {
- return fStates.empty() || fStates.back() != this->getDrawState();
+void GrInOrderDrawBuffer::recordStateIfNecessary() {
+ if (fStates.empty()) {
+ fStates.push_back() = this->getDrawState();
+ this->addToCmdBuffer(kSetState_Cmd);
+ return;
+ }
+ const GrDrawState& curr = this->getDrawState();
+ GrDrawState& prev = fStates.back();
+ switch (GrDrawState::CombineIfPossible(prev, curr)) {
+ case GrDrawState::kIncompatible_CombinedState:
+ fStates.push_back() = this->getDrawState();
+ this->addToCmdBuffer(kSetState_Cmd);
+ break;
+ case GrDrawState::kA_CombinedState:
+ case GrDrawState::kAOrB_CombinedState: // Treat the same as kA.
+ break;
+ case GrDrawState::kB_CombinedState:
+ prev = curr;
+ break;
+ }
}
bool GrInOrderDrawBuffer::needsNewClip() const {
@@ -953,11 +963,6 @@ void GrInOrderDrawBuffer::recordClip() {
this->addToCmdBuffer(kSetClip_Cmd);
}
-void GrInOrderDrawBuffer::recordState() {
- fStates.push_back() = this->getDrawState();
- this->addToCmdBuffer(kSetState_Cmd);
-}
-
GrInOrderDrawBuffer::DrawRecord* GrInOrderDrawBuffer::recordDraw(const DrawInfo& info) {
this->addToCmdBuffer(kDraw_Cmd);
return &fDraws.push_back(info);
« no previous file with comments | « src/gpu/GrInOrderDrawBuffer.h ('k') | src/gpu/effects/GrBicubicEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698