aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-04 19:42:00 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-10-04 19:42:00 +0000
commitd5d69ffaea117428972db48796f7e75f0d1dab34 (patch)
tree1bfbf31d49a04916898fd3730377ab41f932c96c /src
parent9f7827fcd9268a6f3066dd05117293950e467720 (diff)
Add convenience function on GrDrawState to set state bit based on a bool.
R=robertphillips@google.com Review URL: https://codereview.appspot.com/6615044 git-svn-id: http://skia.googlecode.com/svn/trunk@5815 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrClipMaskManager.cpp6
-rw-r--r--src/gpu/GrContext.cpp19
-rw-r--r--src/gpu/GrDrawState.h18
3 files changed, 21 insertions, 22 deletions
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index 5ca714a577..f40c265031 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -785,11 +785,7 @@ bool GrClipMaskManager::createStencilClipMask(const GrClipData& clipDataIn,
drawState->disableState(GrGpu::kModifyStencilClip_StateBit);
// if the target is MSAA then we want MSAA enabled when the clip is soft
if (rt->isMultisampled()) {
- if (clip->fDoAA) {
- drawState->enableState(GrDrawState::kHWAntialias_StateBit);
- } else {
- drawState->disableState(GrDrawState::kHWAntialias_StateBit);
- }
+ drawState->setState(GrDrawState::kHWAntialias_StateBit, clip->fDoAA);
}
// Can the clip element be drawn directly to the stencil buffer
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 26bef45d42..b038a9d26d 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -570,11 +570,7 @@ const GrClipData* GrContext::getClip() const {
void GrContext::setClip(const GrClipData* clipData) {
fGpu->setClip(clipData);
- if (clipData->fClipStack->isWideOpen()) {
- fDrawState->disableState(GrDrawState::kClip_StateBit);
- } else {
- fDrawState->enableState(GrDrawState::kClip_StateBit);
- }
+ fDrawState->setState(GrDrawState::kClip_StateBit, !clipData->fClipStack->isWideOpen());
}
////////////////////////////////////////////////////////////////////////////////
@@ -1618,16 +1614,9 @@ void GrContext::setPaint(const GrPaint& paint) {
fDrawState->setColor(paint.fColor);
- if (paint.fDither) {
- fDrawState->enableState(GrDrawState::kDither_StateBit);
- } else {
- fDrawState->disableState(GrDrawState::kDither_StateBit);
- }
- if (paint.fAntiAlias) {
- fDrawState->enableState(GrDrawState::kHWAntialias_StateBit);
- } else {
- fDrawState->disableState(GrDrawState::kHWAntialias_StateBit);
- }
+ fDrawState->setState(GrDrawState::kDither_StateBit, paint.fDither);
+ fDrawState->setState(GrDrawState::kHWAntialias_StateBit, paint.fAntiAlias);
+
if (paint.fColorMatrixEnabled) {
fDrawState->enableState(GrDrawState::kColorMatrix_StateBit);
fDrawState->setColorMatrix(paint.fColorMatrix);
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index b38a177051..05da3df0e0 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -674,7 +674,7 @@ public:
/**
* Enable render state settings.
*
- * @param flags bitfield of StateBits specifing the states to enable
+ * @param stateBits bitfield of StateBits specifing the states to enable
*/
void enableState(uint32_t stateBits) {
fFlagBits |= stateBits;
@@ -683,12 +683,26 @@ public:
/**
* Disable render state settings.
*
- * @param flags bitfield of StateBits specifing the states to disable
+ * @param stateBits bitfield of StateBits specifing the states to disable
*/
void disableState(uint32_t stateBits) {
fFlagBits &= ~(stateBits);
}
+ /**
+ * Enable or disable stateBits based on a boolean.
+ *
+ * @param stateBits bitfield of StateBits to enable or disablt
+ * @param enable if true enable stateBits, otherwise disable
+ */
+ void setState(uint32_t stateBits, bool enable) {
+ if (enable) {
+ this->enableState(stateBits);
+ } else {
+ this->disableState(stateBits);
+ }
+ }
+
bool isDitherState() const {
return 0 != (fFlagBits & kDither_StateBit);
}