| 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 2082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 | 2093 |
| 2094 GrGLfloat glMatrix[4 * 4]; | 2094 GrGLfloat glMatrix[4 * 4]; |
| 2095 fHWProjectionMatrixState.getGLMatrix<4>(glMatrix); | 2095 fHWProjectionMatrixState.getGLMatrix<4>(glMatrix); |
| 2096 GL_CALL(MatrixMode(GR_GL_PROJECTION)); | 2096 GL_CALL(MatrixMode(GR_GL_PROJECTION)); |
| 2097 GL_CALL(LoadMatrixf(glMatrix)); | 2097 GL_CALL(LoadMatrixf(glMatrix)); |
| 2098 } | 2098 } |
| 2099 | 2099 |
| 2100 void GrGpuGL::enableTexGen(int unitIdx, | 2100 void GrGpuGL::enableTexGen(int unitIdx, |
| 2101 TexGenComponents components, | 2101 TexGenComponents components, |
| 2102 const GrGLfloat* coefficients) { | 2102 const GrGLfloat* coefficients) { |
| 2103 | |
| 2104 SkASSERT(this->glCaps().fixedFunctionSupport()); | 2103 SkASSERT(this->glCaps().fixedFunctionSupport()); |
| 2105 SkASSERT(this->caps()->pathRenderingSupport()); | |
| 2106 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo
nents); | 2104 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo
nents); |
| 2107 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= unitIdx); | 2105 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= unitIdx); |
| 2108 | 2106 |
| 2109 if (GR_GL_OBJECT_LINEAR == fHWTexGenSettings[unitIdx].fMode && | 2107 if (GR_GL_OBJECT_LINEAR == fHWTexGenSettings[unitIdx].fMode && |
| 2110 components == fHWTexGenSettings[unitIdx].fNumComponents && | 2108 components == fHWTexGenSettings[unitIdx].fNumComponents && |
| 2111 !memcmp(coefficients, fHWTexGenSettings[unitIdx].fCoefficients, | 2109 !memcmp(coefficients, fHWTexGenSettings[unitIdx].fCoefficients, |
| 2112 3 * components * sizeof(GrGLfloat))) { | 2110 3 * components * sizeof(GrGLfloat))) { |
| 2113 return; | 2111 return; |
| 2114 } | 2112 } |
| 2115 | 2113 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2131 fHWTexGenSettings[unitIdx].fNumComponents = components; | 2129 fHWTexGenSettings[unitIdx].fNumComponents = components; |
| 2132 | 2130 |
| 2133 for (int i = 0; i < components; i++) { | 2131 for (int i = 0; i < components; i++) { |
| 2134 GrGLfloat plane[] = {coefficients[0 + 3 * i], | 2132 GrGLfloat plane[] = {coefficients[0 + 3 * i], |
| 2135 coefficients[1 + 3 * i], | 2133 coefficients[1 + 3 * i], |
| 2136 0, | 2134 0, |
| 2137 coefficients[2 + 3 * i]}; | 2135 coefficients[2 + 3 * i]}; |
| 2138 GL_CALL(TexGenfv(GR_GL_S + i, GR_GL_OBJECT_PLANE, plane)); | 2136 GL_CALL(TexGenfv(GR_GL_S + i, GR_GL_OBJECT_PLANE, plane)); |
| 2139 } | 2137 } |
| 2140 | 2138 |
| 2141 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, | 2139 if (this->caps()->pathRenderingSupport()) { |
| 2142 GR_GL_OBJECT_LINEAR, | 2140 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, |
| 2143 components, | 2141 GR_GL_OBJECT_LINEAR, |
| 2144 coefficients)); | 2142 components, |
| 2143 coefficients)); |
| 2144 } |
| 2145 | 2145 |
| 2146 memcpy(fHWTexGenSettings[unitIdx].fCoefficients, coefficients, | 2146 memcpy(fHWTexGenSettings[unitIdx].fCoefficients, coefficients, |
| 2147 3 * components * sizeof(GrGLfloat)); | 2147 3 * components * sizeof(GrGLfloat)); |
| 2148 | |
| 2149 fHWActiveTexGenSets = SkTMax(fHWActiveTexGenSets, unitIdx); | |
| 2150 } | 2148 } |
| 2151 | 2149 |
| 2152 void GrGpuGL::enableTexGen(int unitIdx, TexGenComponents components, const SkMat
rix& matrix) { | 2150 void GrGpuGL::enableTexGen(int unitIdx, TexGenComponents components, const SkMat
rix& matrix) { |
| 2153 | |
| 2154 GrGLfloat coefficients[3 * 3]; | 2151 GrGLfloat coefficients[3 * 3]; |
| 2155 SkASSERT(this->glCaps().fixedFunctionSupport()); | 2152 SkASSERT(this->glCaps().fixedFunctionSupport()); |
| 2156 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo
nents); | 2153 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo
nents); |
| 2157 | 2154 |
| 2158 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); | 2155 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); |
| 2159 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); | 2156 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); |
| 2160 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); | 2157 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); |
| 2161 | 2158 |
| 2162 if (components >= kST_TexGenComponents) { | 2159 if (components >= kST_TexGenComponents) { |
| 2163 coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]); | 2160 coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]); |
| 2164 coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]); | 2161 coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]); |
| 2165 coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]); | 2162 coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]); |
| 2166 } | 2163 } |
| 2167 | 2164 |
| 2168 if (components >= kSTR_TexGenComponents) { | 2165 if (components >= kSTR_TexGenComponents) { |
| 2169 coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]); | 2166 coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]); |
| 2170 coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]); | 2167 coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]); |
| 2171 coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]); | 2168 coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]); |
| 2172 } | 2169 } |
| 2173 | 2170 |
| 2174 enableTexGen(unitIdx, components, coefficients); | 2171 enableTexGen(unitIdx, components, coefficients); |
| 2175 } | 2172 } |
| 2176 | 2173 |
| 2177 void GrGpuGL::disableUnusedTexGen(int numUsedTexCoordSets) { | 2174 void GrGpuGL::flushTexGenSettings(int numUsedTexCoordSets) { |
| 2178 | |
| 2179 SkASSERT(this->glCaps().fixedFunctionSupport()); | 2175 SkASSERT(this->glCaps().fixedFunctionSupport()); |
| 2180 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= numUsedTexCoordSe
ts); | 2176 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= numUsedTexCoordSe
ts); |
| 2181 | 2177 |
| 2178 // Only write the inactive tex gens, since active tex gens were written |
| 2179 // when they were enabled. |
| 2180 |
| 2181 SkDEBUGCODE( |
| 2182 for (int i = 0; i < numUsedTexCoordSets; i++) { |
| 2183 SkASSERT(0 != fHWTexGenSettings[i].fNumComponents); |
| 2184 } |
| 2185 ); |
| 2186 |
| 2182 for (int i = numUsedTexCoordSets; i < fHWActiveTexGenSets; i++) { | 2187 for (int i = numUsedTexCoordSets; i < fHWActiveTexGenSets; i++) { |
| 2183 if (0 == fHWTexGenSettings[i].fNumComponents) { | 2188 SkASSERT(0 != fHWTexGenSettings[i].fNumComponents); |
| 2184 continue; | |
| 2185 } | |
| 2186 | 2189 |
| 2187 this->setTextureUnit(i); | 2190 this->setTextureUnit(i); |
| 2188 for (int j = 0; j < fHWTexGenSettings[i].fNumComponents; j++) { | 2191 for (int j = 0; j < fHWTexGenSettings[i].fNumComponents; j++) { |
| 2189 GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + j)); | 2192 GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + j)); |
| 2190 } | 2193 } |
| 2191 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); | 2194 |
| 2195 if (this->caps()->pathRenderingSupport()) { |
| 2196 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); |
| 2197 } |
| 2198 |
| 2192 fHWTexGenSettings[i].fNumComponents = 0; | 2199 fHWTexGenSettings[i].fNumComponents = 0; |
| 2193 } | 2200 } |
| 2194 | 2201 |
| 2195 fHWActiveTexGenSets = SkTMin(fHWActiveTexGenSets, numUsedTexCoordSets); | 2202 fHWActiveTexGenSets = numUsedTexCoordSets; |
| 2196 } | 2203 } |
| 2197 | 2204 |
| 2198 void GrGpuGL::flushMiscFixedFunctionState() { | 2205 void GrGpuGL::flushMiscFixedFunctionState() { |
| 2199 | 2206 |
| 2200 const GrDrawState& drawState = this->getDrawState(); | 2207 const GrDrawState& drawState = this->getDrawState(); |
| 2201 | 2208 |
| 2202 if (drawState.isDitherState()) { | 2209 if (drawState.isDitherState()) { |
| 2203 if (kYes_TriState != fHWDitherEnabled) { | 2210 if (kYes_TriState != fHWDitherEnabled) { |
| 2204 GL_CALL(Enable(GR_GL_DITHER)); | 2211 GL_CALL(Enable(GR_GL_DITHER)); |
| 2205 fHWDitherEnabled = kYes_TriState; | 2212 fHWDitherEnabled = kYes_TriState; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2673 this->setVertexArrayID(gpu, 0); | 2680 this->setVertexArrayID(gpu, 0); |
| 2674 } | 2681 } |
| 2675 int attrCount = gpu->glCaps().maxVertexAttributes(); | 2682 int attrCount = gpu->glCaps().maxVertexAttributes(); |
| 2676 if (fDefaultVertexArrayAttribState.count() != attrCount) { | 2683 if (fDefaultVertexArrayAttribState.count() != attrCount) { |
| 2677 fDefaultVertexArrayAttribState.resize(attrCount); | 2684 fDefaultVertexArrayAttribState.resize(attrCount); |
| 2678 } | 2685 } |
| 2679 attribState = &fDefaultVertexArrayAttribState; | 2686 attribState = &fDefaultVertexArrayAttribState; |
| 2680 } | 2687 } |
| 2681 return attribState; | 2688 return attribState; |
| 2682 } | 2689 } |
| OLD | NEW |