aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrInOrderDrawBuffer.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-08-05 07:15:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-05 07:15:57 -0700
commit838f62db0a77487f6732ed13a0972a1e646ae16a (patch)
tree5f238953a08113c57fce626f79ea28db2a4f4697 /src/gpu/GrInOrderDrawBuffer.cpp
parent7d4f40a9d125efc7d43f4c5b0665efaea58fad6c (diff)
Replace op== with CombineIfPossible in GrDrawState.
R=egdaniel@google.com, robertphillips@google.com Author: bsalomon@google.com Review URL: https://codereview.chromium.org/439853002
Diffstat (limited to 'src/gpu/GrInOrderDrawBuffer.cpp')
-rw-r--r--src/gpu/GrInOrderDrawBuffer.cpp43
1 files changed, 24 insertions, 19 deletions
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 0cab19ff04..6e447590b0 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);