OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGpuGL.h" | 9 #include "GrGpuGL.h" |
10 #include "GrGLStencilBuffer.h" | 10 #include "GrGLStencilBuffer.h" |
(...skipping 1901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 } else { | 1912 } else { |
1913 if (kNo_TriState != fMSAAEnabled) { | 1913 if (kNo_TriState != fMSAAEnabled) { |
1914 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 1914 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
1915 fMSAAEnabled = kNo_TriState; | 1915 fMSAAEnabled = kNo_TriState; |
1916 } | 1916 } |
1917 } | 1917 } |
1918 } | 1918 } |
1919 } | 1919 } |
1920 } | 1920 } |
1921 | 1921 |
1922 void GrGpuGL::flushBlend(const GrOptDrawState& optState, bool isLines, | 1922 void GrGpuGL::flushBlend(const GrOptDrawState& optState) { |
1923 GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { | |
1924 // Any optimization to disable blending should have already been applied and | 1923 // Any optimization to disable blending should have already been applied and |
1925 // tweaked the coeffs to (1, 0). | 1924 // tweaked the coeffs to (1, 0). |
| 1925 |
| 1926 GrXferProcessor::BlendInfo blendInfo; |
| 1927 optState.getXferProcessor()->getBlendInfo(&blendInfo); |
| 1928 GrBlendCoeff srcCoeff = blendInfo.fSrcBlend; |
| 1929 GrBlendCoeff dstCoeff = blendInfo.fDstBlend; |
1926 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; | 1930 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; |
1927 if (blendOff) { | 1931 if (blendOff) { |
1928 if (kNo_TriState != fHWBlendState.fEnabled) { | 1932 if (kNo_TriState != fHWBlendState.fEnabled) { |
1929 GL_CALL(Disable(GR_GL_BLEND)); | 1933 GL_CALL(Disable(GR_GL_BLEND)); |
1930 fHWBlendState.fEnabled = kNo_TriState; | 1934 fHWBlendState.fEnabled = kNo_TriState; |
1931 } | 1935 } |
1932 } else { | 1936 } else { |
1933 if (kYes_TriState != fHWBlendState.fEnabled) { | 1937 if (kYes_TriState != fHWBlendState.fEnabled) { |
1934 GL_CALL(Enable(GR_GL_BLEND)); | 1938 GL_CALL(Enable(GR_GL_BLEND)); |
1935 fHWBlendState.fEnabled = kYes_TriState; | 1939 fHWBlendState.fEnabled = kYes_TriState; |
1936 } | 1940 } |
1937 if (fHWBlendState.fSrcCoeff != srcCoeff || | 1941 if (fHWBlendState.fSrcCoeff != srcCoeff || |
1938 fHWBlendState.fDstCoeff != dstCoeff) { | 1942 fHWBlendState.fDstCoeff != dstCoeff) { |
1939 GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff], | 1943 GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff], |
1940 gXfermodeCoeff2Blend[dstCoeff])); | 1944 gXfermodeCoeff2Blend[dstCoeff])); |
1941 fHWBlendState.fSrcCoeff = srcCoeff; | 1945 fHWBlendState.fSrcCoeff = srcCoeff; |
1942 fHWBlendState.fDstCoeff = dstCoeff; | 1946 fHWBlendState.fDstCoeff = dstCoeff; |
1943 } | 1947 } |
1944 GrColor blendConst = optState.getBlendConstant(); | 1948 GrColor blendConst = blendInfo.fBlendConstant; |
1945 if ((BlendCoeffReferencesConstant(srcCoeff) || | 1949 if ((BlendCoeffReferencesConstant(srcCoeff) || |
1946 BlendCoeffReferencesConstant(dstCoeff)) && | 1950 BlendCoeffReferencesConstant(dstCoeff)) && |
1947 (!fHWBlendState.fConstColorValid || | 1951 (!fHWBlendState.fConstColorValid || |
1948 fHWBlendState.fConstColor != blendConst)) { | 1952 fHWBlendState.fConstColor != blendConst)) { |
1949 GrGLfloat c[4]; | 1953 GrGLfloat c[4]; |
1950 GrColorToRGBAFloat(blendConst, c); | 1954 GrColorToRGBAFloat(blendConst, c); |
1951 GL_CALL(BlendColor(c[0], c[1], c[2], c[3])); | 1955 GL_CALL(BlendColor(c[0], c[1], c[2], c[3])); |
1952 fHWBlendState.fConstColor = blendConst; | 1956 fHWBlendState.fConstColor = blendConst; |
1953 fHWBlendState.fConstColorValid = true; | 1957 fHWBlendState.fConstColorValid = true; |
1954 } | 1958 } |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2583 this->setVertexArrayID(gpu, 0); | 2587 this->setVertexArrayID(gpu, 0); |
2584 } | 2588 } |
2585 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2589 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2586 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2590 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2587 fDefaultVertexArrayAttribState.resize(attrCount); | 2591 fDefaultVertexArrayAttribState.resize(attrCount); |
2588 } | 2592 } |
2589 attribState = &fDefaultVertexArrayAttribState; | 2593 attribState = &fDefaultVertexArrayAttribState; |
2590 } | 2594 } |
2591 return attribState; | 2595 return attribState; |
2592 } | 2596 } |
OLD | NEW |