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
This commit is contained in:
parent
9f7827fcd9
commit
d5d69ffaea
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user