aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/gl/GrGpuGL.cpp
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-21 13:21:46 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-05-21 13:21:46 +0000
commita4d8fc24736e77fd8c588c4be63e3c15a4154860 (patch)
tree2c36e4f0211dacb8db61561ca5700386ebc521be /src/gpu/gl/GrGpuGL.cpp
parentb45a1b46ee25e9b19800b028bb1ca925212ac7b4 (diff)
Stop using GrDrawState to track GPU's blend state
git-svn-id: http://skia.googlecode.com/svn/trunk@4007 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl/GrGpuGL.cpp')
-rw-r--r--src/gpu/gl/GrGpuGL.cpp48
1 files changed, 22 insertions, 26 deletions
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index 2966f59633..805d5134e8 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -456,10 +456,6 @@ void GrGpuGL::onResetContext() {
this->glCaps().print();
}
- // We detect cases when blending is effectively off
- fHWBlendDisabled = false;
- GL_CALL(Enable(GR_GL_BLEND));
-
// we don't use the zb at all
GL_CALL(Disable(GR_GL_DEPTH_TEST));
GL_CALL(DepthMask(GR_GL_FALSE));
@@ -486,11 +482,7 @@ void GrGpuGL::onResetContext() {
// invalid
fActiveTextureUnitIdx = -1;
- // illegal values
- fHWDrawState.setBlendFunc((GrBlendCoeff)0xFF, (GrBlendCoeff)0xFF);
-
- fHWDrawState.setBlendConstant(0x00000000);
- GL_CALL(BlendColor(0,0,0,0));
+ fHWBlendState.invalidate();
fHWDrawState.setColor(GrColor_ILLEGAL);
@@ -1976,15 +1968,16 @@ void GrGpuGL::flushBlend(GrPrimitiveType type,
GrBlendCoeff srcCoeff,
GrBlendCoeff dstCoeff) {
if (GrIsPrimTypeLines(type) && this->willUseHWAALines()) {
- if (fHWBlendDisabled) {
+ if (kYes_TriState != fHWBlendState.fEnabled) {
GL_CALL(Enable(GR_GL_BLEND));
- fHWBlendDisabled = false;
+ fHWBlendState.fEnabled = kYes_TriState;
}
- if (kSA_BlendCoeff != fHWDrawState.getSrcBlendCoeff() ||
- kISA_BlendCoeff != fHWDrawState.getDstBlendCoeff()) {
+ if (kSA_BlendCoeff != fHWBlendState.fSrcCoeff ||
+ kISA_BlendCoeff != fHWBlendState.fDstCoeff) {
GL_CALL(BlendFunc(gXfermodeCoeff2Blend[kSA_BlendCoeff],
gXfermodeCoeff2Blend[kISA_BlendCoeff]));
- fHWDrawState.setBlendFunc(kSA_BlendCoeff, kISA_BlendCoeff);
+ fHWBlendState.fSrcCoeff = kSA_BlendCoeff;
+ fHWBlendState.fDstCoeff = kISA_BlendCoeff;
}
} else {
// any optimization to disable blending should
@@ -1992,25 +1985,28 @@ void GrGpuGL::flushBlend(GrPrimitiveType type,
// to (1, 0).
bool blendOff = kOne_BlendCoeff == srcCoeff &&
kZero_BlendCoeff == dstCoeff;
- if (fHWBlendDisabled != blendOff) {
- if (blendOff) {
+ if (blendOff) {
+ if (kNo_TriState != fHWBlendState.fEnabled) {
GL_CALL(Disable(GR_GL_BLEND));
- } else {
+ fHWBlendState.fEnabled = kNo_TriState;
+ }
+ } else {
+ if (kYes_TriState != fHWBlendState.fEnabled) {
GL_CALL(Enable(GR_GL_BLEND));
+ fHWBlendState.fEnabled = kYes_TriState;
}
- fHWBlendDisabled = blendOff;
- }
- if (!blendOff) {
- if (fHWDrawState.getSrcBlendCoeff() != srcCoeff ||
- fHWDrawState.getDstBlendCoeff() != dstCoeff) {
+ if (fHWBlendState.fSrcCoeff != srcCoeff ||
+ fHWBlendState.fDstCoeff != dstCoeff) {
GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff],
gXfermodeCoeff2Blend[dstCoeff]));
- fHWDrawState.setBlendFunc(srcCoeff, dstCoeff);
+ fHWBlendState.fSrcCoeff = srcCoeff;
+ fHWBlendState.fDstCoeff = dstCoeff;
}
GrColor blendConst = this->getDrawState().getBlendConstant();
if ((BlendCoeffReferencesConstant(srcCoeff) ||
BlendCoeffReferencesConstant(dstCoeff)) &&
- fHWDrawState.getBlendConstant() != blendConst) {
+ (!fHWBlendState.fConstColorValid ||
+ fHWBlendState.fConstColor != blendConst)) {
float c[] = {
GrColorUnpackR(blendConst) / 255.f,
@@ -2019,12 +2015,12 @@ void GrGpuGL::flushBlend(GrPrimitiveType type,
GrColorUnpackA(blendConst) / 255.f
};
GL_CALL(BlendColor(c[0], c[1], c[2], c[3]));
- fHWDrawState.setBlendConstant(blendConst);
+ fHWBlendState.fConstColor = blendConst;
+ fHWBlendState.fConstColorValid = true;
}
}
}
}
-
namespace {
unsigned gr_to_gl_filter(GrSamplerState::Filter filter) {