diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-21 14:45:49 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-21 14:45:49 +0000 |
commit | 978c8c61ba1e792567e9d8e6629c2c4ee59727b7 (patch) | |
tree | 9ded2ffe5063173be4b754c9e8c7343553b2a57f /src/gpu/gl | |
parent | e9bbee397ce96aa6642a42823feb1d7c4a8ffd8b (diff) |
Stop using GrDrawState to track draw face, dither, and color mask
Review URL: http://codereview.appspot.com/6215071/
git-svn-id: http://skia.googlecode.com/svn/trunk@4009 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 44 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.h | 4 |
2 files changed, 28 insertions, 20 deletions
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index 805d5134e8..975b252576 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -460,11 +460,9 @@ void GrGpuGL::onResetContext() { GL_CALL(Disable(GR_GL_DEPTH_TEST)); GL_CALL(DepthMask(GR_GL_FALSE)); - GL_CALL(Disable(GR_GL_CULL_FACE)); - GL_CALL(FrontFace(GR_GL_CCW)); - fHWDrawState.setDrawFace(GrDrawState::kBoth_DrawFace); + fHWDrawFace = GrDrawState::kInvalid_DrawFace; + fHWDitherEnabled = kUnknown_TriState; - GL_CALL(Disable(GR_GL_DITHER)); if (kDesktop_GrGLBinding == this->glBinding()) { GL_CALL(Disable(GR_GL_LINE_SMOOTH)); GL_CALL(Disable(GR_GL_POINT_SMOOTH)); @@ -473,7 +471,7 @@ void GrGpuGL::onResetContext() { fHWAAState.fSmoothLineEnabled = false; } - GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); + fHWWriteToColor = kUnknown_TriState; fHWDrawState.resetStateFlags(); // we only ever use lines in hairline mode @@ -1368,7 +1366,7 @@ void GrGpuGL::onClear(const GrIRect* rect, GrColor color) { b = GrColorUnpackB(color) * scaleRGB; GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); - fHWDrawState.disableState(GrDrawState::kNoColorWrites_StateBit); + fHWWriteToColor = kYes_TriState; GL_CALL(ClearColor(r, g, b, a)); GL_CALL(Clear(GR_GL_COLOR_BUFFER_BIT)); } @@ -2178,27 +2176,33 @@ bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) { } this->flushRenderTarget(rect); this->flushAAState(type); - - if (drawState->isDitherState() != fHWDrawState.isDitherState()) { - if (drawState->isDitherState()) { + + if (drawState->isDitherState()) { + if (kYes_TriState != fHWDitherEnabled) { GL_CALL(Enable(GR_GL_DITHER)); - } else { + fHWDitherEnabled = kYes_TriState; + } + } else { + if (kNo_TriState != fHWDitherEnabled) { GL_CALL(Disable(GR_GL_DITHER)); + fHWDitherEnabled = kNo_TriState; } } - if (drawState->isColorWriteDisabled() != - fHWDrawState.isColorWriteDisabled()) { - GrGLenum mask; - if (drawState->isColorWriteDisabled()) { - mask = GR_GL_FALSE; - } else { - mask = GR_GL_TRUE; + if (drawState->isColorWriteDisabled()) { + if (kNo_TriState != fHWWriteToColor) { + GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE, + GR_GL_FALSE, GR_GL_FALSE)); + fHWWriteToColor = kNo_TriState; + } + } else { + if (kYes_TriState != fHWWriteToColor) { + GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); + fHWWriteToColor = kYes_TriState; } - GL_CALL(ColorMask(mask, mask, mask, mask)); } - if (fHWDrawState.getDrawFace() != drawState->getDrawFace()) { + if (fHWDrawFace != drawState->getDrawFace()) { switch (this->getDrawState().getDrawFace()) { case GrDrawState::kCCW_DrawFace: GL_CALL(Enable(GR_GL_CULL_FACE)); @@ -2214,7 +2218,7 @@ bool GrGpuGL::flushGLStateCommon(GrPrimitiveType type) { default: GrCrash("Unknown draw face."); } - fHWDrawState.setDrawFace(drawState->getDrawFace()); + fHWDrawFace = drawState->getDrawFace(); } #if GR_DEBUG diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index d5c9c27fa5..1c5046a0da 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -265,6 +265,10 @@ private: } } fHWBlendState; + GrDrawState::DrawFace fHWDrawFace; + TriState fHWWriteToColor; + TriState fHWDitherEnabled; + // we record what stencil format worked last time to hopefully exit early // from our loop that tries stencil formats and calls check fb status. int fLastSuccessfulStencilFmtIdx; |