blob: baa220b0b535094ff9783944d018e1b68e64ffd9 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#include "GrGLConfig.h"
19
reed@google.comac10a2d2010-12-22 21:39:39 +000020#include "GrGpuGLFixed.h"
21#include "GrGpuVertex.h"
22
23#define SKIP_CACHE_CHECK true
24
25struct GrGpuMatrix {
twiz@google.com0f31ca72011-03-18 17:38:11 +000026 GrGLfloat fMat[16];
bsalomon@google.com5782d712011-01-21 21:03:59 +000027
reed@google.comac10a2d2010-12-22 21:39:39 +000028 void reset() {
29 Gr_bzero(fMat, sizeof(fMat));
30 fMat[0] = fMat[5] = fMat[10] = fMat[15] = GR_Scalar1;
31 }
bsalomon@google.com5782d712011-01-21 21:03:59 +000032
reed@google.comac10a2d2010-12-22 21:39:39 +000033 void set(const GrMatrix& m) {
34 Gr_bzero(fMat, sizeof(fMat));
bsalomon@google.comcc4dac32011-05-10 13:52:42 +000035 fMat[0] = GrScalarToFloat(m[GrMatrix::kMScaleX]);
36 fMat[4] = GrScalarToFloat(m[GrMatrix::kMSkewX]);
37 fMat[12] = GrScalarToFloat(m[GrMatrix::kMTransX]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000038
bsalomon@google.comcc4dac32011-05-10 13:52:42 +000039 fMat[1] = GrScalarToFloat(m[GrMatrix::kMSkewY]);
40 fMat[5] = GrScalarToFloat(m[GrMatrix::kMScaleY]);
41 fMat[13] = GrScalarToFloat(m[GrMatrix::kMTransY]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000042
bsalomon@google.comcc4dac32011-05-10 13:52:42 +000043 fMat[3] = GrScalarToFloat(m[GrMatrix::kMPersp0]);
44 fMat[7] = GrScalarToFloat(m[GrMatrix::kMPersp1]);
45 fMat[15] = GrScalarToFloat(m[GrMatrix::kMPersp2]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000046
bsalomon@google.comc6cf7232011-02-17 16:43:10 +000047 fMat[10] = 1.f; // z-scale
reed@google.comac10a2d2010-12-22 21:39:39 +000048 }
49};
50
51// these must match the order in the corresponding enum in GrGpu.h
twiz@google.com0f31ca72011-03-18 17:38:11 +000052static const GrGLenum gMatrixMode2Enum[] = {
53 GR_GL_MODELVIEW, GR_GL_TEXTURE
reed@google.comac10a2d2010-12-22 21:39:39 +000054};
55
56///////////////////////////////////////////////////////////////////////////////
57
58GrGpuGLFixed::GrGpuGLFixed() {
bsalomon@google.com6aef1fb2011-05-05 12:33:22 +000059 f4X4DownsampleFilterSupport = false;
bsalomon@google.com271cffc2011-05-20 14:13:56 +000060 fDualSourceBlendingSupport = false;
reed@google.comac10a2d2010-12-22 21:39:39 +000061}
62
63GrGpuGLFixed::~GrGpuGLFixed() {
64}
65
66void GrGpuGLFixed::resetContext() {
67 INHERITED::resetContext();
reed@google.comac10a2d2010-12-22 21:39:39 +000068
twiz@google.com0f31ca72011-03-18 17:38:11 +000069 GR_GL(Disable(GR_GL_TEXTURE_2D));
reed@google.comac10a2d2010-12-22 21:39:39 +000070
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000071 for (int s = 0; s < kNumStages; ++s) {
72 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +000073 GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
74 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_TEXTURE_ENV_MODE, GR_GL_COMBINE));
75 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_RGB, GR_GL_MODULATE));
76 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_RGB, GR_GL_TEXTURE0+s));
77 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_RGB, GR_GL_PREVIOUS));
78 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_RGB, GR_GL_SRC_COLOR));
reed@google.comac10a2d2010-12-22 21:39:39 +000079
twiz@google.com0f31ca72011-03-18 17:38:11 +000080 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_ALPHA, GR_GL_MODULATE));
81 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_ALPHA, GR_GL_TEXTURE0+s));
82 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND0_ALPHA, GR_GL_SRC_ALPHA));
83 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_ALPHA, GR_GL_PREVIOUS));
84 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_ALPHA, GR_GL_SRC_ALPHA));
bsalomon@google.com5782d712011-01-21 21:03:59 +000085
86 // color oprand0 changes between GL_SRC_COLR and GL_SRC_ALPHA depending
87 // upon whether we have a (premultiplied) RGBA texture or just an ALPHA
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000088 // texture, e.g.:
89 //glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
bsalomon@google.com5782d712011-01-21 21:03:59 +000090 fHWRGBOperand0[s] = (TextureEnvRGBOperands) -1;
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000091 }
reed@google.comac10a2d2010-12-22 21:39:39 +000092
93 fHWGeometryState.fVertexLayout = 0;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000094 fHWGeometryState.fVertexOffset = ~0;
twiz@google.com0f31ca72011-03-18 17:38:11 +000095 GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
96 GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
97 GR_GL(ShadeModel(GR_GL_FLAT));
98 GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
bsalomon@google.com5782d712011-01-21 21:03:59 +000099
100 GR_GL(PointSize(1.f));
101
reed@google.comac10a2d2010-12-22 21:39:39 +0000102 GrGLClearErr();
103 fTextVerts = false;
104
reed@google.comac10a2d2010-12-22 21:39:39 +0000105 fBaseVertex = 0xffffffff;
106}
107
108
109void GrGpuGLFixed::flushProjectionMatrix() {
110 float mat[16];
111 Gr_bzero(mat, sizeof(mat));
bsalomon@google.com5782d712011-01-21 21:03:59 +0000112
reed@google.comac10a2d2010-12-22 21:39:39 +0000113 GrAssert(NULL != fCurrDrawState.fRenderTarget);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000114
reed@google.comac10a2d2010-12-22 21:39:39 +0000115 mat[0] = 2.f / fCurrDrawState.fRenderTarget->width();
116 mat[5] = -2.f / fCurrDrawState.fRenderTarget->height();
117 mat[10] = -1.f;
118 mat[15] = 1;
bsalomon@google.com5782d712011-01-21 21:03:59 +0000119
reed@google.comac10a2d2010-12-22 21:39:39 +0000120 mat[12] = -1.f;
121 mat[13] = 1.f;
bsalomon@google.com5782d712011-01-21 21:03:59 +0000122
twiz@google.com0f31ca72011-03-18 17:38:11 +0000123 GR_GL(MatrixMode(GR_GL_PROJECTION));
reed@google.comac10a2d2010-12-22 21:39:39 +0000124 GR_GL(LoadMatrixf(mat));
125}
126
bsalomon@google.comffca4002011-02-22 20:34:01 +0000127bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000128
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000129 bool usingTextures[kNumStages];
bsalomon@google.com5782d712011-01-21 21:03:59 +0000130
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000131 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.coma47a48d2011-04-26 20:22:11 +0000132 usingTextures[s] = this->isStageEnabled(s);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000133 if (usingTextures[s] && fCurrDrawState.fSamplerStates[s].isGradient()) {
134 unimpl("Fixed pipe doesn't support radial/sweep gradients");
135 return false;
136 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000137 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000138
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000139 if (GR_GL_SUPPORT_ES1) {
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000140 if (BlendCoeffReferencesConstant(fCurrDrawState.fSrcBlend) ||
141 BlendCoeffReferencesConstant(fCurrDrawState.fDstBlend)) {
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000142 unimpl("ES1 doesn't support blend constant");
143 return false;
144 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000145 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000146
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +0000147 if (!flushGLStateCommon(type)) {
148 return false;
149 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000150
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000151 this->flushBlend(type, fCurrDrawState.fSrcBlend, fCurrDrawState.fDstBlend);
152
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000153 if (fDirtyFlags.fRenderTargetChanged) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000154 flushProjectionMatrix();
reed@google.comac10a2d2010-12-22 21:39:39 +0000155 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000156
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000157 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.coma47a48d2011-04-26 20:22:11 +0000158 bool wasUsingTexture = StageWillBeUsed(s, fHWGeometryState.fVertexLayout, fHWDrawState);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000159 if (usingTextures[s] != wasUsingTexture) {
160 setTextureUnit(s);
161 if (usingTextures[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000162 GR_GL(Enable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000163 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000164 GR_GL(Disable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000165 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000166 }
167 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000168
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000169 uint32_t vertColor = (this->getGeomSrc().fVertexLayout & kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000170 uint32_t prevVertColor = (fHWGeometryState.fVertexLayout &
reed@google.comac10a2d2010-12-22 21:39:39 +0000171 kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000172
reed@google.comac10a2d2010-12-22 21:39:39 +0000173 if (vertColor != prevVertColor) {
174 if (vertColor) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000175 GR_GL(ShadeModel(GR_GL_SMOOTH));
reed@google.comac10a2d2010-12-22 21:39:39 +0000176 // invalidate the immediate mode color
177 fHWDrawState.fColor = GrColor_ILLEGAL;
178 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000179 GR_GL(ShadeModel(GR_GL_FLAT));
reed@google.comac10a2d2010-12-22 21:39:39 +0000180 }
181 }
182
bsalomon@google.com5782d712011-01-21 21:03:59 +0000183
reed@google.comac10a2d2010-12-22 21:39:39 +0000184 if (!vertColor && fHWDrawState.fColor != fCurrDrawState.fColor) {
185 GR_GL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor),
186 GrColorUnpackG(fCurrDrawState.fColor),
187 GrColorUnpackB(fCurrDrawState.fColor),
188 GrColorUnpackA(fCurrDrawState.fColor)));
189 fHWDrawState.fColor = fCurrDrawState.fColor;
190 }
191
192 // set texture environment, decide whether we are modulating by RGB or A.
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000193 for (int s = 0; s < kNumStages; ++s) {
194 if (usingTextures[s]) {
195 GrGLTexture* texture = (GrGLTexture*)fCurrDrawState.fTextures[s];
196 if (NULL != texture) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000197 TextureEnvRGBOperands nextRGBOperand0 =
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000198 (GrPixelConfigIsAlphaOnly(texture->config())) ?
bsalomon@google.com5782d712011-01-21 21:03:59 +0000199 kAlpha_TextureEnvRGBOperand :
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000200 kColor_TextureEnvRGBOperand;
201 if (fHWRGBOperand0[s] != nextRGBOperand0) {
202 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000203 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV,
204 GR_GL_OPERAND0_RGB,
bsalomon@google.com5782d712011-01-21 21:03:59 +0000205 (nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ?
twiz@google.com0f31ca72011-03-18 17:38:11 +0000206 GR_GL_SRC_ALPHA :
207 GR_GL_SRC_COLOR));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000208 fHWRGBOperand0[s] = nextRGBOperand0;
reed@google.comac10a2d2010-12-22 21:39:39 +0000209 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000210
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000211 if (((1 << s) & fDirtyFlags.fTextureChangedMask) ||
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000212 (fHWDrawState.fSamplerStates[s].getMatrix() !=
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000213 getSamplerMatrix(s))) {
214
215 GrMatrix texMat = getSamplerMatrix(s);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000216 AdjustTextureMatrix(texture,
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000217 GrSamplerState::kNormal_SampleMode,
218 &texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000219 GrGpuMatrix glm;
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000220 glm.set(texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000221 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000222 GR_GL(MatrixMode(GR_GL_TEXTURE));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000223 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000224 recordHWSamplerMatrix(s, getSamplerMatrix(s));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000225 }
226 } else {
227 GrAssert(!"Rendering with texture vert flag set but no bound texture");
228 return false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000229 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000230 }
231 }
232
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000233 if (fHWDrawState.fViewMatrix != fCurrDrawState.fViewMatrix) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000234 GrGpuMatrix glm;
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000235 glm.set(fCurrDrawState.fViewMatrix);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000236 GR_GL(MatrixMode(GR_GL_MODELVIEW));
reed@google.comac10a2d2010-12-22 21:39:39 +0000237 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.com5782d712011-01-21 21:03:59 +0000238 fHWDrawState.fViewMatrix =
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000239 fCurrDrawState.fViewMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +0000240 }
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000241 resetDirtyFlags();
reed@google.comac10a2d2010-12-22 21:39:39 +0000242 return true;
243}
244
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000245void GrGpuGLFixed::setupGeometry(int* startVertex,
246 int* startIndex,
247 int vertexCount,
248 int indexCount) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000249
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000250 int newColorOffset;
251 int newTexCoordOffsets[kNumStages];
bsalomon@google.com5782d712011-01-21 21:03:59 +0000252
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000253 GrGLsizei newStride = VertexSizeAndOffsetsByStage(this->getGeomSrc().fVertexLayout,
twiz@google.com0f31ca72011-03-18 17:38:11 +0000254 newTexCoordOffsets,
255 &newColorOffset);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000256 int oldColorOffset;
257 int oldTexCoordOffsets[kNumStages];
twiz@google.com0f31ca72011-03-18 17:38:11 +0000258 GrGLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout,
259 oldTexCoordOffsets,
260 &oldColorOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000261
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000262 bool indexed = NULL != startIndex;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000263
264 int extraVertexOffset;
265 int extraIndexOffset;
266 setBuffers(indexed, &extraVertexOffset, &extraIndexOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000267
twiz@google.com0f31ca72011-03-18 17:38:11 +0000268 GrGLenum scalarType;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000269 if (this->getGeomSrc().fVertexLayout & kTextFormat_VertexLayoutBit) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000270 scalarType = GrGLTextType;
271 } else {
272 scalarType = GrGLType;
273 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000274
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000275 size_t vertexOffset = (*startVertex + extraVertexOffset) * newStride;
276 *startVertex = 0;
277 if (indexed) {
278 *startIndex += extraIndexOffset;
279 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000280
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000281 // all the Pointers must be set if any of these are true
282 bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty ||
283 vertexOffset != fHWGeometryState.fVertexOffset ||
284 newStride != oldStride;
285
286 // position and tex coord offsets change if above conditions are true
287 // or the type changed based on text vs nontext type coords.
288 bool posAndTexChange = allOffsetsChange ||
289 ((GrGLTextType != GrGLType) &&
290 (kTextFormat_VertexLayoutBit &
291 (fHWGeometryState.fVertexLayout ^
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000292 this->getGeomSrc().fVertexLayout)));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000293
294 if (posAndTexChange) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000295 GR_GL(VertexPointer(2, scalarType, newStride, (GrGLvoid*)vertexOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000296 fHWGeometryState.fVertexOffset = vertexOffset;
reed@google.comac10a2d2010-12-22 21:39:39 +0000297 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000298
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000299 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000300 // need to enable array if tex coord offset is 0
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000301 // (using positions as coords)
302 if (newTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000303 GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[s]);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000304 if (oldTexCoordOffsets[s] < 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000305 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
306 GR_GL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000307 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
308 } else if (posAndTexChange ||
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000309 newTexCoordOffsets[s] != oldTexCoordOffsets[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000310 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000311 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000312 }
313 } else if (oldTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000314 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
315 GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000316 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000317 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000318
reed@google.comac10a2d2010-12-22 21:39:39 +0000319 if (newColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000320 GrGLvoid* colorOffset = (GrGLvoid*)(vertexOffset + newColorOffset);
reed@google.comac10a2d2010-12-22 21:39:39 +0000321 if (oldColorOffset <= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000322 GR_GL(EnableClientState(GR_GL_COLOR_ARRAY));
323 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000324 } else if (allOffsetsChange || newColorOffset != oldColorOffset) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000325 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
reed@google.comac10a2d2010-12-22 21:39:39 +0000326 }
327 } else if (oldColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000328 GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000329 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000330
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000331 fHWGeometryState.fVertexLayout = this->getGeomSrc().fVertexLayout;
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000332 fHWGeometryState.fArrayPtrsDirty = false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000333}