aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrClipMaskManager.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-18 13:44:51 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-06-18 13:44:51 +0000
commitc8f7f47afaf8f9471e6d111655c5610a8bd210a2 (patch)
treecb9246aa3bc832623891fbcce8ce86d777b1b58a /src/gpu/GrClipMaskManager.cpp
parentb702c0fcc0d5c85cb326b38fd34d535b9352512e (diff)
Store clip mask location in GrClipMaskManager as a enum rather than two bools
Review URL: http://codereview.appspot.com/6306092/ git-svn-id: http://skia.googlecode.com/svn/trunk@4274 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/GrClipMaskManager.cpp')
-rw-r--r--src/gpu/GrClipMaskManager.cpp34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index ee1bcaeb03..55a8192c3f 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -119,9 +119,9 @@ bool GrClipMaskManager::createClipMask(const GrClip& clipIn,
GrAssert(scissorSettings);
scissorSettings->fEnableScissoring = false;
- fClipMaskInStencil = false;
- fClipMaskInAlpha = false;
+ fCurrClipMaskType = kNone_ClipMaskType;
+
GrDrawState* drawState = fGpu->drawState();
if (!drawState->isClipState()) {
return true;
@@ -143,8 +143,6 @@ bool GrClipMaskManager::createClipMask(const GrClip& clipIn,
GrTexture* result = NULL;
GrIRect bound;
if (this->createSoftwareClipMask(fGpu, clipIn, &result, &bound)) {
- fClipMaskInAlpha = true;
-
setup_drawstate_aaclip(fGpu, result, bound);
return true;
}
@@ -165,8 +163,6 @@ bool GrClipMaskManager::createClipMask(const GrClip& clipIn,
GrTexture* result = NULL;
GrIRect bound;
if (this->createAlphaClipMask(fGpu, clipIn, &result, &bound)) {
- fClipMaskInAlpha = true;
-
setup_drawstate_aaclip(fGpu, result, bound);
return true;
}
@@ -208,10 +204,10 @@ bool GrClipMaskManager::createClipMask(const GrClip& clipIn,
scissorSettings->fEnableScissoring = true;
// use the stencil clip if we can't represent the clip as a rectangle.
- fClipMaskInStencil = !clipIn.isRect() && !clipIn.isEmpty() &&
- !bounds.isEmpty();
+ bool useStencil = !clipIn.isRect() && !clipIn.isEmpty() &&
+ !bounds.isEmpty();
- if (fClipMaskInStencil) {
+ if (useStencil) {
return this->createStencilClipMask(clipIn, bounds, scissorSettings);
}
@@ -546,13 +542,15 @@ bool GrClipMaskManager::createAlphaClipMask(const GrClip& clipIn,
GrTexture** result,
GrIRect *resultBounds) {
+ GrAssert(kNone_ClipMaskType == fCurrClipMaskType);
+
if (this->clipMaskPreamble(clipIn, result, resultBounds)) {
+ fCurrClipMaskType = kAlpha_ClipMaskType;
return true;
}
GrTexture* accum = fAACache.getLastMask();
if (NULL == accum) {
- fClipMaskInAlpha = false;
fAACache.reset();
return false;
}
@@ -613,7 +611,6 @@ bool GrClipMaskManager::createAlphaClipMask(const GrClip& clipIn,
getTemp(*resultBounds, &temp);
if (NULL == temp.texture()) {
- fClipMaskInAlpha = false;
fAACache.reset();
return false;
}
@@ -659,7 +656,7 @@ bool GrClipMaskManager::createAlphaClipMask(const GrClip& clipIn,
}
*result = accum;
-
+ fCurrClipMaskType = kAlpha_ClipMaskType;
return true;
}
@@ -669,7 +666,7 @@ bool GrClipMaskManager::createStencilClipMask(const GrClip& clipIn,
const GrRect& bounds,
ScissoringSettings* scissorSettings) {
- GrAssert(fClipMaskInStencil);
+ GrAssert(kNone_ClipMaskType == fCurrClipMaskType);
GrDrawState* drawState = fGpu->drawState();
GrAssert(drawState->isClipState());
@@ -758,7 +755,6 @@ bool GrClipMaskManager::createStencilClipMask(const GrClip& clipIn,
fill, fGpu, false,
true);
if (NULL == pr) {
- fClipMaskInStencil = false;
fGpu->setClip(clipCopy); // restore to the original
return false;
}
@@ -824,11 +820,10 @@ bool GrClipMaskManager::createStencilClipMask(const GrClip& clipIn,
}
// restore clip
fGpu->setClip(clipCopy);
- // recusive draws would have disabled this since they drew with
- // the clip bounds as clip.
- fClipMaskInStencil = true;
}
-
+ // set this last because recursive draws may overwrite it back to kNone.
+ GrAssert(kNone_ClipMaskType == fCurrClipMaskType);
+ fCurrClipMaskType = kStencil_ClipMaskType;
return true;
}
@@ -950,6 +945,7 @@ GrPathFill invert_fill(GrPathFill fill) {
bool GrClipMaskManager::createSoftwareClipMask(const GrClip& clipIn,
GrTexture** result,
GrIRect *resultBounds) {
+ GrAssert(kNone_ClipMaskType == fCurrClipMaskType);
if (this->clipMaskPreamble(clipIn, result, resultBounds)) {
return true;
@@ -957,7 +953,6 @@ bool GrClipMaskManager::createSoftwareClipMask(const GrClip& clipIn,
GrTexture* accum = fAACache.getLastMask();
if (NULL == accum) {
- fClipMaskInAlpha = false;
fAACache.reset();
return false;
}
@@ -1057,6 +1052,7 @@ bool GrClipMaskManager::createSoftwareClipMask(const GrClip& clipIn,
*result = accum;
+ fCurrClipMaskType = kAlpha_ClipMaskType;
return true;
}