aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar joshualitt <joshualitt@chromium.org>2014-10-29 18:29:27 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-29 18:29:27 -0700
commit7a6184fdf717a1da0c6e1e37b942b17fdaa236d3 (patch)
tree5821b4b508e0a60992364f87dfc1abf1b93155a1
parent720730762051a87274e497b903123cb7c258501e (diff)
cleanup reentrance logic in CMM
-rw-r--r--src/gpu/GrClipMaskManager.cpp34
-rw-r--r--src/gpu/GrClipMaskManager.h14
-rw-r--r--src/gpu/GrDrawState.h5
-rw-r--r--tests/GLProgramsTest.cpp2
4 files changed, 15 insertions, 40 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 8bd4fabac4..e04d444a54 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -216,6 +216,9 @@ bool GrClipMaskManager::setupClipping(const GrClipData* clipDataIn,
GrDrawState::AutoRestoreStencil* ars,
ScissorState* scissorState) {
fCurrClipMaskType = kNone_ClipMaskType;
+ if (kRespectClip_StencilClipMode == fClipMode) {
+ fClipMode = kIgnoreClip_StencilClipMode;
+ }
GrReducedClip::ElementList elements(16);
int32_t genID;
@@ -743,7 +746,7 @@ bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID,
const Element* element = iter.get();
bool fillInverted = false;
// enabled at bottom of loop
- drawState->disableState(kModifyStencilClip_StateBit);
+ fClipMode = kIgnoreClip_StencilClipMode;
// if the target is MSAA then we want MSAA enabled when the clip is soft
if (rt->isMultisampled()) {
drawState->setState(GrDrawState::kHWAntialias_StateBit, element->isAA());
@@ -822,7 +825,7 @@ bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID,
// now we modify the clip bit by rendering either the clip
// element directly or a bounding rect of the entire clip.
- drawState->enableState(kModifyStencilClip_StateBit);
+ fClipMode = kModifyClip_StencilClipMode;
for (int p = 0; p < passes; ++p) {
*drawState->stencil() = stencilSettings[p];
if (canDrawDirectToClip) {
@@ -845,6 +848,7 @@ bool GrClipMaskManager::createStencilClipMask(int32_t elementsGenID,
// set this last because recursive draws may overwrite it back to kNone.
SkASSERT(kNone_ClipMaskType == fCurrClipMaskType);
fCurrClipMaskType = kStencil_ClipMaskType;
+ fClipMode = kRespectClip_StencilClipMode;
return true;
}
@@ -911,22 +915,12 @@ void GrClipMaskManager::setDrawStateStencil(GrDrawState::AutoRestoreStencil* ars
// use stencil for clipping if clipping is enabled and the clip
// has been written into the stencil.
- GrClipMaskManager::StencilClipMode clipMode;
- if (this->isClipInStencil() && drawState.isClipState()) {
- clipMode = GrClipMaskManager::kRespectClip_StencilClipMode;
- // We can't be modifying the clip and respecting it at the same time.
- SkASSERT(!drawState.isStateFlagEnabled(kModifyStencilClip_StateBit));
- } else if (drawState.isStateFlagEnabled(kModifyStencilClip_StateBit)) {
- clipMode = GrClipMaskManager::kModifyClip_StencilClipMode;
- } else {
- clipMode = GrClipMaskManager::kIgnoreClip_StencilClipMode;
- }
GrStencilSettings settings;
// The GrGpu client may not be using the stencil buffer but we may need to
// enable it in order to respect a stencil clip.
if (drawState.getStencil().isDisabled()) {
- if (GrClipMaskManager::kRespectClip_StencilClipMode == clipMode) {
+ if (GrClipMaskManager::kRespectClip_StencilClipMode == fClipMode) {
settings = basic_apply_stencil_clip_settings();
} else {
return;
@@ -944,7 +938,7 @@ void GrClipMaskManager::setDrawStateStencil(GrDrawState::AutoRestoreStencil* ars
SkASSERT(fClipTarget->caps()->stencilWrapOpsSupport() || !settings.usesWrapOp());
SkASSERT(fClipTarget->caps()->twoSidedStencilSupport() || !settings.isTwoSided());
- this->adjustStencilParams(&settings, clipMode, stencilBits);
+ this->adjustStencilParams(&settings, fClipMode, stencilBits);
ars->set(fClipTarget->drawState());
fClipTarget->drawState()->setStencil(settings);
}
@@ -1116,22 +1110,12 @@ void GrClipMaskManager::setClipTarget(GrClipTarget* clipTarget) {
void GrClipMaskManager::adjustPathStencilParams(GrStencilSettings* settings) {
const GrDrawState& drawState = fClipTarget->getDrawState();
- GrClipMaskManager::StencilClipMode clipMode;
- if (this->isClipInStencil() && drawState.isClipState()) {
- clipMode = GrClipMaskManager::kRespectClip_StencilClipMode;
- // We can't be modifying the clip and respecting it at the same time.
- SkASSERT(!drawState.isStateFlagEnabled(kModifyStencilClip_StateBit));
- } else if (drawState.isStateFlagEnabled(kModifyStencilClip_StateBit)) {
- clipMode = GrClipMaskManager::kModifyClip_StencilClipMode;
- } else {
- clipMode = GrClipMaskManager::kIgnoreClip_StencilClipMode;
- }
// TODO: dynamically attach a stencil buffer
int stencilBits = 0;
GrStencilBuffer* stencilBuffer = drawState.getRenderTarget()->getStencilBuffer();
if (stencilBuffer) {
stencilBits = stencilBuffer->bits();
- this->adjustStencilParams(settings, clipMode, stencilBits);
+ this->adjustStencilParams(settings, fClipMode, stencilBits);
}
}
diff --git a/src/gpu/GrClipMaskManager.h b/src/gpu/GrClipMaskManager.h
index e4d7223c7e..c38e1405b0 100644
--- a/src/gpu/GrClipMaskManager.h
+++ b/src/gpu/GrClipMaskManager.h
@@ -40,7 +40,8 @@ class GrClipMaskManager : SkNoncopyable {
public:
GrClipMaskManager()
: fCurrClipMaskType(kNone_ClipMaskType)
- , fClipTarget(NULL) {
+ , fClipTarget(NULL)
+ , fClipMode(kIgnoreClip_StencilClipMode) {
}
// The state of the scissor is controlled by the clip manager, no one else should set
@@ -94,14 +95,6 @@ public:
void adjustPathStencilParams(GrStencilSettings*);
private:
- enum PrivateDrawStateStateBits {
- kFirstBit = (GrDrawState::kLastPublicStateBit << 1),
-
- kModifyStencilClip_StateBit = kFirstBit, // allows draws to modify
- // stencil bits used for
- // clipping.
- };
-
/**
* Informs the helper function adjustStencilParams() about how the stencil
* buffer clip is being used.
@@ -202,7 +195,8 @@ private:
} fCurrClipMaskType;
GrClipMaskCache fAACache; // cache for the AA path
- GrClipTarget* fClipTarget;
+ GrClipTarget* fClipTarget;
+ StencilClipMode fClipMode;
typedef SkNoncopyable INHERITED;
};
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 71c44d4867..036c4a5172 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -618,10 +618,7 @@ public:
* setBlendFunc() which will use coverage*color as the src color.
*/
kCoverageDrawing_StateBit = 0x10,
-
- // Users of the class may add additional bits to the vector
- kDummyStateBit,
- kLastPublicStateBit = kDummyStateBit-1,
+ kLast_StateBit = kCoverageDrawing_StateBit,
};
uint32_t getFlagBits() const { return fFlagBits; }
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index c9e840e9c1..100752ecd8 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -328,7 +328,7 @@ static void set_random_hints(GrGpuGL* gpu, SkRandom* random) {
static void set_random_state(GrGpuGL* gpu, SkRandom* random) {
int state = 0;
- for (int i = 1; i <= GrDrawState::kLastPublicStateBit; i <<= 1) {
+ for (int i = 1; i <= GrDrawState::kLast_StateBit; i <<= 1) {
state |= random->nextBool() * i;
}
gpu->drawState()->enableState(state);