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 1913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 set_gl_stencil(this->glInterface(), | 1924 set_gl_stencil(this->glInterface(), |
1925 fStencilSettings, | 1925 fStencilSettings, |
1926 GR_GL_FRONT_AND_BACK, | 1926 GR_GL_FRONT_AND_BACK, |
1927 GrStencilSettings::kFront_Face); | 1927 GrStencilSettings::kFront_Face); |
1928 } | 1928 } |
1929 } | 1929 } |
1930 fHWStencilSettings = fStencilSettings; | 1930 fHWStencilSettings = fStencilSettings; |
1931 } | 1931 } |
1932 } | 1932 } |
1933 | 1933 |
1934 void GrGpuGL::flushAAState(DrawType type) { | 1934 void GrGpuGL::flushAAState(const GrOptDrawState& optState, DrawType type) { |
1935 // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA st
ate is enabled but | 1935 // At least some ATI linux drivers will render GL_LINES incorrectly when MSAA st
ate is enabled but |
1936 // the target is not multisampled. Single pixel wide lines are rendered thicker
than 1 pixel wide. | 1936 // the target is not multisampled. Single pixel wide lines are rendered thicker
than 1 pixel wide. |
1937 #if 0 | 1937 #if 0 |
1938 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe
r a relevant concern | 1938 // Replace RT_HAS_MSAA with this definition once this driver bug is no longe
r a relevant concern |
1939 #define RT_HAS_MSAA rt->isMultisampled() | 1939 #define RT_HAS_MSAA rt->isMultisampled() |
1940 #else | 1940 #else |
1941 #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type) | 1941 #define RT_HAS_MSAA (rt->isMultisampled() || kDrawLines_DrawType == type) |
1942 #endif | 1942 #endif |
1943 | 1943 |
1944 const GrRenderTarget* rt = this->getDrawState().getRenderTarget(); | 1944 const GrRenderTarget* rt = optState.getRenderTarget(); |
1945 if (kGL_GrGLStandard == this->glStandard()) { | 1945 if (kGL_GrGLStandard == this->glStandard()) { |
1946 if (RT_HAS_MSAA) { | 1946 if (RT_HAS_MSAA) { |
1947 // FIXME: GL_NV_pr doesn't seem to like MSAA disabled. The paths | 1947 // FIXME: GL_NV_pr doesn't seem to like MSAA disabled. The paths |
1948 // convex hulls of each segment appear to get filled. | 1948 // convex hulls of each segment appear to get filled. |
1949 bool enableMSAA = kStencilPath_DrawType == type || | 1949 bool enableMSAA = kStencilPath_DrawType == type || |
1950 this->getDrawState().isHWAntialiasState(); | 1950 optState.isHWAntialiasState(); |
1951 if (enableMSAA) { | 1951 if (enableMSAA) { |
1952 if (kYes_TriState != fMSAAEnabled) { | 1952 if (kYes_TriState != fMSAAEnabled) { |
1953 GL_CALL(Enable(GR_GL_MULTISAMPLE)); | 1953 GL_CALL(Enable(GR_GL_MULTISAMPLE)); |
1954 fMSAAEnabled = kYes_TriState; | 1954 fMSAAEnabled = kYes_TriState; |
1955 } | 1955 } |
1956 } else { | 1956 } else { |
1957 if (kNo_TriState != fMSAAEnabled) { | 1957 if (kNo_TriState != fMSAAEnabled) { |
1958 GL_CALL(Disable(GR_GL_MULTISAMPLE)); | 1958 GL_CALL(Disable(GR_GL_MULTISAMPLE)); |
1959 fMSAAEnabled = kNo_TriState; | 1959 fMSAAEnabled = kNo_TriState; |
1960 } | 1960 } |
1961 } | 1961 } |
1962 } | 1962 } |
1963 } | 1963 } |
1964 } | 1964 } |
1965 | 1965 |
1966 void GrGpuGL::flushBlend(bool isLines, | 1966 void GrGpuGL::flushBlend(const GrOptDrawState& optState, bool isLines, |
1967 GrBlendCoeff srcCoeff, | 1967 GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { |
1968 GrBlendCoeff dstCoeff) { | |
1969 // Any optimization to disable blending should have already been applied and | 1968 // Any optimization to disable blending should have already been applied and |
1970 // tweaked the coeffs to (1, 0). | 1969 // tweaked the coeffs to (1, 0). |
1971 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; | 1970 bool blendOff = kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCo
eff; |
1972 if (blendOff) { | 1971 if (blendOff) { |
1973 if (kNo_TriState != fHWBlendState.fEnabled) { | 1972 if (kNo_TriState != fHWBlendState.fEnabled) { |
1974 GL_CALL(Disable(GR_GL_BLEND)); | 1973 GL_CALL(Disable(GR_GL_BLEND)); |
1975 fHWBlendState.fEnabled = kNo_TriState; | 1974 fHWBlendState.fEnabled = kNo_TriState; |
1976 } | 1975 } |
1977 } else { | 1976 } else { |
1978 if (kYes_TriState != fHWBlendState.fEnabled) { | 1977 if (kYes_TriState != fHWBlendState.fEnabled) { |
1979 GL_CALL(Enable(GR_GL_BLEND)); | 1978 GL_CALL(Enable(GR_GL_BLEND)); |
1980 fHWBlendState.fEnabled = kYes_TriState; | 1979 fHWBlendState.fEnabled = kYes_TriState; |
1981 } | 1980 } |
1982 if (fHWBlendState.fSrcCoeff != srcCoeff || | 1981 if (fHWBlendState.fSrcCoeff != srcCoeff || |
1983 fHWBlendState.fDstCoeff != dstCoeff) { | 1982 fHWBlendState.fDstCoeff != dstCoeff) { |
1984 GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff], | 1983 GL_CALL(BlendFunc(gXfermodeCoeff2Blend[srcCoeff], |
1985 gXfermodeCoeff2Blend[dstCoeff])); | 1984 gXfermodeCoeff2Blend[dstCoeff])); |
1986 fHWBlendState.fSrcCoeff = srcCoeff; | 1985 fHWBlendState.fSrcCoeff = srcCoeff; |
1987 fHWBlendState.fDstCoeff = dstCoeff; | 1986 fHWBlendState.fDstCoeff = dstCoeff; |
1988 } | 1987 } |
1989 GrColor blendConst = this->getDrawState().getBlendConstant(); | 1988 GrColor blendConst = optState.getBlendConstant(); |
1990 if ((BlendCoeffReferencesConstant(srcCoeff) || | 1989 if ((BlendCoeffReferencesConstant(srcCoeff) || |
1991 BlendCoeffReferencesConstant(dstCoeff)) && | 1990 BlendCoeffReferencesConstant(dstCoeff)) && |
1992 (!fHWBlendState.fConstColorValid || | 1991 (!fHWBlendState.fConstColorValid || |
1993 fHWBlendState.fConstColor != blendConst)) { | 1992 fHWBlendState.fConstColor != blendConst)) { |
1994 GrGLfloat c[4]; | 1993 GrGLfloat c[4]; |
1995 GrColorToRGBAFloat(blendConst, c); | 1994 GrColorToRGBAFloat(blendConst, c); |
1996 GL_CALL(BlendColor(c[0], c[1], c[2], c[3])); | 1995 GL_CALL(BlendColor(c[0], c[1], c[2], c[3])); |
1997 fHWBlendState.fConstColor = blendConst; | 1996 fHWBlendState.fConstColor = blendConst; |
1998 fHWBlendState.fConstColorValid = true; | 1997 fHWBlendState.fConstColorValid = true; |
1999 } | 1998 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2102 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swi
zzle[3])); | 2101 GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_A, swi
zzle[3])); |
2103 } else { | 2102 } else { |
2104 GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGL
int)); | 2103 GR_STATIC_ASSERT(sizeof(newTexParams.fSwizzleRGBA[0]) == sizeof(GrGL
int)); |
2105 const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexPara
ms.fSwizzleRGBA); | 2104 const GrGLint* swizzle = reinterpret_cast<const GrGLint*>(newTexPara
ms.fSwizzleRGBA); |
2106 GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA,
swizzle)); | 2105 GL_CALL(TexParameteriv(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_SWIZZLE_RGBA,
swizzle)); |
2107 } | 2106 } |
2108 } | 2107 } |
2109 texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); | 2108 texture->setCachedTexParams(newTexParams, this->getResetTimestamp()); |
2110 } | 2109 } |
2111 | 2110 |
2112 void GrGpuGL::flushMiscFixedFunctionState() { | 2111 void GrGpuGL::flushMiscFixedFunctionState(const GrOptDrawState& optState) { |
2113 | 2112 if (optState.isDitherState()) { |
2114 const GrDrawState& drawState = this->getDrawState(); | |
2115 | |
2116 if (drawState.isDitherState()) { | |
2117 if (kYes_TriState != fHWDitherEnabled) { | 2113 if (kYes_TriState != fHWDitherEnabled) { |
2118 GL_CALL(Enable(GR_GL_DITHER)); | 2114 GL_CALL(Enable(GR_GL_DITHER)); |
2119 fHWDitherEnabled = kYes_TriState; | 2115 fHWDitherEnabled = kYes_TriState; |
2120 } | 2116 } |
2121 } else { | 2117 } else { |
2122 if (kNo_TriState != fHWDitherEnabled) { | 2118 if (kNo_TriState != fHWDitherEnabled) { |
2123 GL_CALL(Disable(GR_GL_DITHER)); | 2119 GL_CALL(Disable(GR_GL_DITHER)); |
2124 fHWDitherEnabled = kNo_TriState; | 2120 fHWDitherEnabled = kNo_TriState; |
2125 } | 2121 } |
2126 } | 2122 } |
2127 | 2123 |
2128 if (drawState.isColorWriteDisabled()) { | 2124 if (optState.isColorWriteDisabled()) { |
2129 if (kNo_TriState != fHWWriteToColor) { | 2125 if (kNo_TriState != fHWWriteToColor) { |
2130 GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE, | 2126 GL_CALL(ColorMask(GR_GL_FALSE, GR_GL_FALSE, |
2131 GR_GL_FALSE, GR_GL_FALSE)); | 2127 GR_GL_FALSE, GR_GL_FALSE)); |
2132 fHWWriteToColor = kNo_TriState; | 2128 fHWWriteToColor = kNo_TriState; |
2133 } | 2129 } |
2134 } else { | 2130 } else { |
2135 if (kYes_TriState != fHWWriteToColor) { | 2131 if (kYes_TriState != fHWWriteToColor) { |
2136 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); | 2132 GL_CALL(ColorMask(GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE, GR_GL_TRUE)); |
2137 fHWWriteToColor = kYes_TriState; | 2133 fHWWriteToColor = kYes_TriState; |
2138 } | 2134 } |
2139 } | 2135 } |
2140 | 2136 |
2141 if (fHWDrawFace != drawState.getDrawFace()) { | 2137 if (fHWDrawFace != optState.getDrawFace()) { |
2142 switch (this->getDrawState().getDrawFace()) { | 2138 switch (optState.getDrawFace()) { |
2143 case GrDrawState::kCCW_DrawFace: | 2139 case GrDrawState::kCCW_DrawFace: |
2144 GL_CALL(Enable(GR_GL_CULL_FACE)); | 2140 GL_CALL(Enable(GR_GL_CULL_FACE)); |
2145 GL_CALL(CullFace(GR_GL_BACK)); | 2141 GL_CALL(CullFace(GR_GL_BACK)); |
2146 break; | 2142 break; |
2147 case GrDrawState::kCW_DrawFace: | 2143 case GrDrawState::kCW_DrawFace: |
2148 GL_CALL(Enable(GR_GL_CULL_FACE)); | 2144 GL_CALL(Enable(GR_GL_CULL_FACE)); |
2149 GL_CALL(CullFace(GR_GL_FRONT)); | 2145 GL_CALL(CullFace(GR_GL_FRONT)); |
2150 break; | 2146 break; |
2151 case GrDrawState::kBoth_DrawFace: | 2147 case GrDrawState::kBoth_DrawFace: |
2152 GL_CALL(Disable(GR_GL_CULL_FACE)); | 2148 GL_CALL(Disable(GR_GL_CULL_FACE)); |
2153 break; | 2149 break; |
2154 default: | 2150 default: |
2155 SkFAIL("Unknown draw face."); | 2151 SkFAIL("Unknown draw face."); |
2156 } | 2152 } |
2157 fHWDrawFace = drawState.getDrawFace(); | 2153 fHWDrawFace = optState.getDrawFace(); |
2158 } | 2154 } |
2159 } | 2155 } |
2160 | 2156 |
2161 bool GrGpuGL::configToGLFormats(GrPixelConfig config, | 2157 bool GrGpuGL::configToGLFormats(GrPixelConfig config, |
2162 bool getSizedInternalFormat, | 2158 bool getSizedInternalFormat, |
2163 GrGLenum* internalFormat, | 2159 GrGLenum* internalFormat, |
2164 GrGLenum* externalFormat, | 2160 GrGLenum* externalFormat, |
2165 GrGLenum* externalType) { | 2161 GrGLenum* externalType) { |
2166 GrGLenum dontCare; | 2162 GrGLenum dontCare; |
2167 if (NULL == internalFormat) { | 2163 if (NULL == internalFormat) { |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2603 this->setVertexArrayID(gpu, 0); | 2599 this->setVertexArrayID(gpu, 0); |
2604 } | 2600 } |
2605 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2601 int attrCount = gpu->glCaps().maxVertexAttributes(); |
2606 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2602 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
2607 fDefaultVertexArrayAttribState.resize(attrCount); | 2603 fDefaultVertexArrayAttribState.resize(attrCount); |
2608 } | 2604 } |
2609 attribState = &fDefaultVertexArrayAttribState; | 2605 attribState = &fDefaultVertexArrayAttribState; |
2610 } | 2606 } |
2611 return attribState; | 2607 return attribState; |
2612 } | 2608 } |
OLD | NEW |