aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrDrawState.h
diff options
context:
space:
mode:
authorGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-04 16:34:52 +0000
committerGravatar robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-04 16:34:52 +0000
commit28b4bce1b13bf2e2b2e27d293a319133c17831cf (patch)
tree7ec84844780bda44c54df092933c4121b8f0697b /src/gpu/GrDrawState.h
parentc1992933f1d97edd3f2f4c7dcbd81ffea6f6c1d8 (diff)
Fix for performance regression due to r3832
Diffstat (limited to 'src/gpu/GrDrawState.h')
-rw-r--r--src/gpu/GrDrawState.h39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 63134088af..386aebdfe0 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -80,6 +80,7 @@ public:
fSrcBlend = kOne_BlendCoeff;
fDstBlend = kZero_BlendCoeff;
fViewMatrix.reset();
+ fBehaviorBits = 0;
// ensure values that will be memcmp'ed in == but not memset in reset()
// are tightly packed
@@ -170,7 +171,7 @@ public:
void setTexture(int stage, GrTexture* texture) {
GrAssert((unsigned)stage < kNumStages);
- if (isStateFlagEnabled(kTexturesNeedRef_StateBit)) {
+ if (isBehaviorEnabled(kTexturesNeedRef_BehaviorBit)) {
// If we don't clear out the current texture before unreffing
// it we can get into an infinite loop as the GrGLTexture's
// onRelease method recursively calls setTexture
@@ -669,10 +670,6 @@ public:
* ignored.
*/
kColorMatrix_StateBit = 0x20,
- /**
- * Calls to setTexture will ref/unref the texture
- */
- kTexturesNeedRef_StateBit = 0x40,
// Users of the class may add additional bits to the vector
kDummyStateBit,
@@ -729,6 +726,28 @@ public:
fFlagBits = ds.fFlagBits;
}
+ /**
+ * Flags that do not affect rendering.
+ */
+ enum GrBehaviorBits {
+ /**
+ * Calls to setTexture will ref/unref the texture
+ */
+ kTexturesNeedRef_BehaviorBit = 0x01,
+ };
+
+ void enableBehavior(uint32_t behaviorBits) {
+ fBehaviorBits |= behaviorBits;
+ }
+
+ void disableBehavior(uint32_t behaviorBits) {
+ fBehaviorBits &= ~(behaviorBits);
+ }
+
+ bool isBehaviorEnabled(uint32_t behaviorBits) const {
+ return 0 != (behaviorBits & fBehaviorBits);
+ }
+
/// @}
///////////////////////////////////////////////////////////////////////////
@@ -771,6 +790,14 @@ public:
return false;
}
+ // kTexturesNeedRef is an internal flag for altering the draw state's
+ // behavior rather than a property that will impact drawing - ignore it
+ // here
+ if ((fBehaviorBits & ~kTexturesNeedRef_BehaviorBit) !=
+ (s.fBehaviorBits & ~kTexturesNeedRef_BehaviorBit)) {
+ return false;
+ }
+
for (int i = 0; i < kNumStages; i++) {
if (fTextures[i] &&
this->fSamplerStates[i] != s.fSamplerStates[i]) {
@@ -795,6 +822,7 @@ public:
memcpy(this->podStart(), s.podStart(), this->podSize());
fViewMatrix = s.fViewMatrix;
+ fBehaviorBits = s.fBehaviorBits;
GrAssert(0 == s.fEdgeAANumEdges);
fEdgeAANumEdges = 0;
@@ -865,6 +893,7 @@ private:
};
// @}
+ uint32_t fBehaviorBits;
GrMatrix fViewMatrix;
// @{ Data for GrTesselatedPathRenderer