Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: src/gpu/gl/GrGpuGL.cpp

Issue 54403003: Fix few inconsistencies in handling fixed-function texture coordinate set generation (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2086 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 2097
2098 GrGLfloat glMatrix[4 * 4]; 2098 GrGLfloat glMatrix[4 * 4];
2099 fHWProjectionMatrixState.getGLMatrix<4>(glMatrix); 2099 fHWProjectionMatrixState.getGLMatrix<4>(glMatrix);
2100 GL_CALL(MatrixMode(GR_GL_PROJECTION)); 2100 GL_CALL(MatrixMode(GR_GL_PROJECTION));
2101 GL_CALL(LoadMatrixf(glMatrix)); 2101 GL_CALL(LoadMatrixf(glMatrix));
2102 } 2102 }
2103 2103
2104 void GrGpuGL::enableTexGen(int unitIdx, 2104 void GrGpuGL::enableTexGen(int unitIdx,
2105 TexGenComponents components, 2105 TexGenComponents components,
2106 const GrGLfloat* coefficients) { 2106 const GrGLfloat* coefficients) {
2107
2108 SkASSERT(this->glCaps().fixedFunctionSupport()); 2107 SkASSERT(this->glCaps().fixedFunctionSupport());
2109 SkASSERT(this->caps()->pathRenderingSupport());
2110 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo nents); 2108 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo nents);
2111 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= unitIdx); 2109 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= unitIdx);
2112 2110
2113 if (GR_GL_OBJECT_LINEAR == fHWTexGenSettings[unitIdx].fMode && 2111 if (GR_GL_OBJECT_LINEAR == fHWTexGenSettings[unitIdx].fMode &&
2114 components == fHWTexGenSettings[unitIdx].fNumComponents && 2112 components == fHWTexGenSettings[unitIdx].fNumComponents &&
2115 !memcmp(coefficients, fHWTexGenSettings[unitIdx].fCoefficients, 2113 !memcmp(coefficients, fHWTexGenSettings[unitIdx].fCoefficients,
2116 3 * components * sizeof(GrGLfloat))) { 2114 3 * components * sizeof(GrGLfloat))) {
2117 return; 2115 return;
2118 } 2116 }
2119 2117
(...skipping 15 matching lines...) Expand all
2135 fHWTexGenSettings[unitIdx].fNumComponents = components; 2133 fHWTexGenSettings[unitIdx].fNumComponents = components;
2136 2134
2137 for (int i = 0; i < components; i++) { 2135 for (int i = 0; i < components; i++) {
2138 GrGLfloat plane[] = {coefficients[0 + 3 * i], 2136 GrGLfloat plane[] = {coefficients[0 + 3 * i],
2139 coefficients[1 + 3 * i], 2137 coefficients[1 + 3 * i],
2140 0, 2138 0,
2141 coefficients[2 + 3 * i]}; 2139 coefficients[2 + 3 * i]};
2142 GL_CALL(TexGenfv(GR_GL_S + i, GR_GL_OBJECT_PLANE, plane)); 2140 GL_CALL(TexGenfv(GR_GL_S + i, GR_GL_OBJECT_PLANE, plane));
2143 } 2141 }
2144 2142
2145 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx, 2143 if (this->caps()->pathRenderingSupport()) {
2146 GR_GL_OBJECT_LINEAR, 2144 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + unitIdx,
2147 components, 2145 GR_GL_OBJECT_LINEAR,
2148 coefficients)); 2146 components,
2147 coefficients));
2148 }
2149 2149
2150 memcpy(fHWTexGenSettings[unitIdx].fCoefficients, coefficients, 2150 memcpy(fHWTexGenSettings[unitIdx].fCoefficients, coefficients,
2151 3 * components * sizeof(GrGLfloat)); 2151 3 * components * sizeof(GrGLfloat));
2152
2153 fHWActiveTexGenSets = SkTMax(fHWActiveTexGenSets, unitIdx);
2154 } 2152 }
2155 2153
2156 void GrGpuGL::enableTexGen(int unitIdx, TexGenComponents components, const SkMat rix& matrix) { 2154 void GrGpuGL::enableTexGen(int unitIdx, TexGenComponents components, const SkMat rix& matrix) {
2157
2158 GrGLfloat coefficients[3 * 3]; 2155 GrGLfloat coefficients[3 * 3];
2159 SkASSERT(this->glCaps().fixedFunctionSupport()); 2156 SkASSERT(this->glCaps().fixedFunctionSupport());
2160 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo nents); 2157 SkASSERT(components >= kS_TexGenComponents && components <= kSTR_TexGenCompo nents);
2161 2158
2162 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]); 2159 coefficients[0] = SkScalarToFloat(matrix[SkMatrix::kMScaleX]);
2163 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]); 2160 coefficients[1] = SkScalarToFloat(matrix[SkMatrix::kMSkewX]);
2164 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]); 2161 coefficients[2] = SkScalarToFloat(matrix[SkMatrix::kMTransX]);
2165 2162
2166 if (components >= kST_TexGenComponents) { 2163 if (components >= kST_TexGenComponents) {
2167 coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]); 2164 coefficients[3] = SkScalarToFloat(matrix[SkMatrix::kMSkewY]);
2168 coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]); 2165 coefficients[4] = SkScalarToFloat(matrix[SkMatrix::kMScaleY]);
2169 coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]); 2166 coefficients[5] = SkScalarToFloat(matrix[SkMatrix::kMTransY]);
2170 } 2167 }
2171 2168
2172 if (components >= kSTR_TexGenComponents) { 2169 if (components >= kSTR_TexGenComponents) {
2173 coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]); 2170 coefficients[6] = SkScalarToFloat(matrix[SkMatrix::kMPersp0]);
2174 coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]); 2171 coefficients[7] = SkScalarToFloat(matrix[SkMatrix::kMPersp1]);
2175 coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]); 2172 coefficients[8] = SkScalarToFloat(matrix[SkMatrix::kMPersp2]);
2176 } 2173 }
2177 2174
2178 enableTexGen(unitIdx, components, coefficients); 2175 enableTexGen(unitIdx, components, coefficients);
2179 } 2176 }
2180 2177
2181 void GrGpuGL::disableUnusedTexGen(int numUsedTexCoordSets) { 2178 void GrGpuGL::flushTexGenSettings(int numUsedTexCoordSets) {
2182
2183 SkASSERT(this->glCaps().fixedFunctionSupport()); 2179 SkASSERT(this->glCaps().fixedFunctionSupport());
2184 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= numUsedTexCoordSe ts); 2180 SkASSERT(this->glCaps().maxFixedFunctionTextureCoords() >= numUsedTexCoordSe ts);
2185 2181
2182 // Only write the inactive tex gens, since active tex gens were written
2183 // when they were enabled.
2184
2185 SkDEBUGCODE(
2186 for (int i = 0; i < numUsedTexCoordSets; i++) {
2187 SkASSERT(0 != fHWTexGenSettings[i].fNumComponents);
2188 }
2189 );
2190
2186 for (int i = numUsedTexCoordSets; i < fHWActiveTexGenSets; i++) { 2191 for (int i = numUsedTexCoordSets; i < fHWActiveTexGenSets; i++) {
2187 if (0 == fHWTexGenSettings[i].fNumComponents) { 2192 SkASSERT(0 != fHWTexGenSettings[i].fNumComponents);
2188 continue;
2189 }
2190 2193
2191 this->setTextureUnit(i); 2194 this->setTextureUnit(i);
2192 for (int j = 0; j < fHWTexGenSettings[i].fNumComponents; j++) { 2195 for (int j = 0; j < fHWTexGenSettings[i].fNumComponents; j++) {
2193 GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + j)); 2196 GL_CALL(Disable(GR_GL_TEXTURE_GEN_S + j));
2194 } 2197 }
2195 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL)); 2198
2199 if (this->caps()->pathRenderingSupport()) {
2200 GL_CALL(PathTexGen(GR_GL_TEXTURE0 + i, GR_GL_NONE, 0, NULL));
2201 }
2202
2196 fHWTexGenSettings[i].fNumComponents = 0; 2203 fHWTexGenSettings[i].fNumComponents = 0;
2197 } 2204 }
2198 2205
2199 fHWActiveTexGenSets = SkTMin(fHWActiveTexGenSets, numUsedTexCoordSets); 2206 fHWActiveTexGenSets = numUsedTexCoordSets;
2200 } 2207 }
2201 2208
2202 void GrGpuGL::flushMiscFixedFunctionState() { 2209 void GrGpuGL::flushMiscFixedFunctionState() {
2203 2210
2204 const GrDrawState& drawState = this->getDrawState(); 2211 const GrDrawState& drawState = this->getDrawState();
2205 2212
2206 if (drawState.isDitherState()) { 2213 if (drawState.isDitherState()) {
2207 if (kYes_TriState != fHWDitherEnabled) { 2214 if (kYes_TriState != fHWDitherEnabled) {
2208 GL_CALL(Enable(GR_GL_DITHER)); 2215 GL_CALL(Enable(GR_GL_DITHER));
2209 fHWDitherEnabled = kYes_TriState; 2216 fHWDitherEnabled = kYes_TriState;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 this->setVertexArrayID(gpu, 0); 2684 this->setVertexArrayID(gpu, 0);
2678 } 2685 }
2679 int attrCount = gpu->glCaps().maxVertexAttributes(); 2686 int attrCount = gpu->glCaps().maxVertexAttributes();
2680 if (fDefaultVertexArrayAttribState.count() != attrCount) { 2687 if (fDefaultVertexArrayAttribState.count() != attrCount) {
2681 fDefaultVertexArrayAttribState.resize(attrCount); 2688 fDefaultVertexArrayAttribState.resize(attrCount);
2682 } 2689 }
2683 attribState = &fDefaultVertexArrayAttribState; 2690 attribState = &fDefaultVertexArrayAttribState;
2684 } 2691 }
2685 return attribState; 2692 return attribState;
2686 } 2693 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGpuGL.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698