diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-21 17:11:44 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-21 17:11:44 +0000 |
commit | 4d5f3fe581a50ed5d57121d09faa8e613e47b16d (patch) | |
tree | 86ee3e6768af8c822a71b60c8bdfc88c6ce802e5 /src/gpu/gl | |
parent | de1837bb96b0f72dad7482786d6e577013d4a85b (diff) |
Use tristate in HW AA tracking, fix msaa disabled for non-smoothed lines bug
Review URL: http://codereview.appspot.com/6222051/
git-svn-id: http://skia.googlecode.com/svn/trunk@4015 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu/gl')
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 60 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.h | 14 |
2 files changed, 42 insertions, 32 deletions
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index bc35f50041..341675bc18 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -464,13 +464,11 @@ void GrGpuGL::onResetContext() { fHWDitherEnabled = kUnknown_TriState; if (kDesktop_GrGLBinding == this->glBinding()) { - GL_CALL(Disable(GR_GL_LINE_SMOOTH)); + // we never use point or polygon smoothing + // should we also disable polygon smoothing? GL_CALL(Disable(GR_GL_POINT_SMOOTH)); - GL_CALL(Disable(GR_GL_MULTISAMPLE)); - fHWAAState.fMSAAEnabled = false; - fHWAAState.fSmoothLineEnabled = false; } - + fHWAAState.invalidate(); fHWWriteToColor = kUnknown_TriState; fHWDrawState.resetStateFlags(); @@ -1927,32 +1925,40 @@ void GrGpuGL::flushAAState(GrPrimitiveType type) { if (kDesktop_GrGLBinding == this->glBinding()) { // ES doesn't support toggling GL_MULTISAMPLE and doesn't have // smooth lines. - // we prefer smooth lines over multisampled lines - // msaa should be disabled if drawing smooth lines. + bool smoothLines = false; + if (GrIsPrimTypeLines(type)) { - bool smooth = this->willUseHWAALines(); - if (!fHWAAState.fSmoothLineEnabled && smooth) { - GL_CALL(Enable(GR_GL_LINE_SMOOTH)); - fHWAAState.fSmoothLineEnabled = true; - } else if (fHWAAState.fSmoothLineEnabled && !smooth) { - GL_CALL(Disable(GR_GL_LINE_SMOOTH)); - fHWAAState.fSmoothLineEnabled = false; - } - if (rt->isMultisampled() && - fHWAAState.fMSAAEnabled) { - GL_CALL(Disable(GR_GL_MULTISAMPLE)); - fHWAAState.fMSAAEnabled = false; + smoothLines = this->willUseHWAALines(); + if (smoothLines) { + if (kYes_TriState != fHWAAState.fSmoothLineEnabled) { + GL_CALL(Enable(GR_GL_LINE_SMOOTH)); + fHWAAState.fSmoothLineEnabled = kYes_TriState; + // must disable msaa to use line smoothing + if (rt->isMultisampled() && + kNo_TriState != fHWAAState.fMSAAEnabled) { + GL_CALL(Disable(GR_GL_MULTISAMPLE)); + fHWAAState.fMSAAEnabled = kNo_TriState; + } + } + } else { + if (kNo_TriState != fHWAAState.fSmoothLineEnabled) { + GL_CALL(Disable(GR_GL_LINE_SMOOTH)); + fHWAAState.fSmoothLineEnabled = kNo_TriState; + } } - } else if (rt->isMultisampled() && - this->getDrawState().isHWAntialiasState() != - fHWAAState.fMSAAEnabled) { - if (fHWAAState.fMSAAEnabled) { - GL_CALL(Disable(GR_GL_MULTISAMPLE)); - fHWAAState.fMSAAEnabled = false; + } + if (!smoothLines && rt->isMultisampled()) { + if (this->getDrawState().isHWAntialiasState()) { + if (kYes_TriState != fHWAAState.fMSAAEnabled) { + GL_CALL(Enable(GR_GL_MULTISAMPLE)); + fHWAAState.fMSAAEnabled = kYes_TriState; + } } else { - GL_CALL(Enable(GR_GL_MULTISAMPLE)); - fHWAAState.fMSAAEnabled = true; + if (kNo_TriState != fHWAAState.fMSAAEnabled) { + GL_CALL(Disable(GR_GL_MULTISAMPLE)); + fHWAAState.fMSAAEnabled = kNo_TriState; + } } } } diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h index 4d646cd24c..12b045703c 100644 --- a/src/gpu/gl/GrGpuGL.h +++ b/src/gpu/gl/GrGpuGL.h @@ -64,11 +64,6 @@ protected: bool fArrayPtrsDirty; } fHWGeometryState; - struct AAState { - bool fMSAAEnabled; - bool fSmoothLineEnabled; - } fHWAAState; - enum UnpremulConversion { kUpOnWrite_DownOnRead_UnpremulConversion, kDownOnWrite_UpOnRead_UnpremulConversion @@ -265,6 +260,15 @@ private: } } fHWBlendState; + struct { + TriState fMSAAEnabled; + TriState fSmoothLineEnabled; + void invalidate() { + fMSAAEnabled = kUnknown_TriState; + fSmoothLineEnabled = kUnknown_TriState; + } + } fHWAAState; + GrDrawState::DrawFace fHWDrawFace; TriState fHWWriteToColor; TriState fHWDitherEnabled; |