Fix for performance regression due to r3832
http://codereview.appspot.com/6188045/ git-svn-id: http://skia.googlecode.com/svn/trunk@3840 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
c1992933f1
commit
28b4bce1b1
@ -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
|
||||
|
@ -469,7 +469,7 @@ void GrInOrderDrawBuffer::reset() {
|
||||
|
||||
// GrInOrderDrawBuffer is no longer managing the refs/unrefs
|
||||
// for the stored GrDrawStates
|
||||
fStates[i].disableState(GrDrawState::kTexturesNeedRef_StateBit);
|
||||
fStates[i].disableBehavior(GrDrawState::kTexturesNeedRef_BehaviorBit);
|
||||
}
|
||||
int numDraws = fDraws.count();
|
||||
for (int d = 0; d < numDraws; ++d) {
|
||||
@ -789,7 +789,7 @@ void GrInOrderDrawBuffer::pushState() {
|
||||
|
||||
// Any textures that are added to the stored state need to be
|
||||
// reffed so the unref in reset doesn't inappropriately free them
|
||||
fStates.back().enableState(GrDrawState::kTexturesNeedRef_StateBit);
|
||||
fStates.back().enableBehavior(GrDrawState::kTexturesNeedRef_BehaviorBit);
|
||||
}
|
||||
|
||||
bool GrInOrderDrawBuffer::needsNewClip() const {
|
||||
|
@ -2239,8 +2239,10 @@ bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) {
|
||||
// relies on detecting when the kModifyStencilClip_StateBit state has
|
||||
// changed since the last draw.
|
||||
fHWDrawState.copyStateFlags(*drawState);
|
||||
|
||||
// TODO: may no longer need this
|
||||
// only GrInOrderDrawBuffer ever needs to ref/unref the textures
|
||||
fHWDrawState.disableState(GrDrawState::kTexturesNeedRef_StateBit);
|
||||
fHWDrawState.disableBehavior(GrDrawState::kTexturesNeedRef_BehaviorBit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user