blob: 446949f1c293aca4f559087da34ab8b6dc6479a4 [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.comc6cf7232011-02-17 16:43:10 +000035 fMat[0] = GrScalarToFloat(m[GrMatrix::kScaleX]);
36 fMat[4] = GrScalarToFloat(m[GrMatrix::kSkewX]);
37 fMat[12] = GrScalarToFloat(m[GrMatrix::kTransX]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000038
bsalomon@google.comc6cf7232011-02-17 16:43:10 +000039 fMat[1] = GrScalarToFloat(m[GrMatrix::kSkewY]);
40 fMat[5] = GrScalarToFloat(m[GrMatrix::kScaleY]);
41 fMat[13] = GrScalarToFloat(m[GrMatrix::kTransY]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000042
bsalomon@google.comc6cf7232011-02-17 16:43:10 +000043 fMat[3] = GrScalarToFloat(m[GrMatrix::kPersp0]);
44 fMat[7] = GrScalarToFloat(m[GrMatrix::kPersp1]);
45 fMat[15] = GrScalarToFloat(m[GrMatrix::kPersp2]);
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() {
reed@google.comac10a2d2010-12-22 21:39:39 +000059}
60
61GrGpuGLFixed::~GrGpuGLFixed() {
62}
63
64void GrGpuGLFixed::resetContext() {
65 INHERITED::resetContext();
reed@google.comac10a2d2010-12-22 21:39:39 +000066
twiz@google.com0f31ca72011-03-18 17:38:11 +000067 GR_GL(Disable(GR_GL_TEXTURE_2D));
reed@google.comac10a2d2010-12-22 21:39:39 +000068
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000069 for (int s = 0; s < kNumStages; ++s) {
70 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +000071 GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
72 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_TEXTURE_ENV_MODE, GR_GL_COMBINE));
73 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_RGB, GR_GL_MODULATE));
74 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_RGB, GR_GL_TEXTURE0+s));
75 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_RGB, GR_GL_PREVIOUS));
76 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_RGB, GR_GL_SRC_COLOR));
reed@google.comac10a2d2010-12-22 21:39:39 +000077
twiz@google.com0f31ca72011-03-18 17:38:11 +000078 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_ALPHA, GR_GL_MODULATE));
79 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_ALPHA, GR_GL_TEXTURE0+s));
80 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND0_ALPHA, GR_GL_SRC_ALPHA));
81 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_ALPHA, GR_GL_PREVIOUS));
82 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_ALPHA, GR_GL_SRC_ALPHA));
bsalomon@google.com5782d712011-01-21 21:03:59 +000083
84 // color oprand0 changes between GL_SRC_COLR and GL_SRC_ALPHA depending
85 // upon whether we have a (premultiplied) RGBA texture or just an ALPHA
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000086 // texture, e.g.:
87 //glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
bsalomon@google.com5782d712011-01-21 21:03:59 +000088 fHWRGBOperand0[s] = (TextureEnvRGBOperands) -1;
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000089 }
reed@google.comac10a2d2010-12-22 21:39:39 +000090
91 fHWGeometryState.fVertexLayout = 0;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000092 fHWGeometryState.fVertexOffset = ~0;
twiz@google.com0f31ca72011-03-18 17:38:11 +000093 GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
94 GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
95 GR_GL(ShadeModel(GR_GL_FLAT));
96 GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
bsalomon@google.com5782d712011-01-21 21:03:59 +000097
98 GR_GL(PointSize(1.f));
99
reed@google.comac10a2d2010-12-22 21:39:39 +0000100 GrGLClearErr();
101 fTextVerts = false;
102
reed@google.comac10a2d2010-12-22 21:39:39 +0000103 fBaseVertex = 0xffffffff;
104}
105
106
107void GrGpuGLFixed::flushProjectionMatrix() {
108 float mat[16];
109 Gr_bzero(mat, sizeof(mat));
bsalomon@google.com5782d712011-01-21 21:03:59 +0000110
reed@google.comac10a2d2010-12-22 21:39:39 +0000111 GrAssert(NULL != fCurrDrawState.fRenderTarget);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000112
reed@google.comac10a2d2010-12-22 21:39:39 +0000113 mat[0] = 2.f / fCurrDrawState.fRenderTarget->width();
114 mat[5] = -2.f / fCurrDrawState.fRenderTarget->height();
115 mat[10] = -1.f;
116 mat[15] = 1;
bsalomon@google.com5782d712011-01-21 21:03:59 +0000117
reed@google.comac10a2d2010-12-22 21:39:39 +0000118 mat[12] = -1.f;
119 mat[13] = 1.f;
bsalomon@google.com5782d712011-01-21 21:03:59 +0000120
twiz@google.com0f31ca72011-03-18 17:38:11 +0000121 GR_GL(MatrixMode(GR_GL_PROJECTION));
reed@google.comac10a2d2010-12-22 21:39:39 +0000122 GR_GL(LoadMatrixf(mat));
123}
124
bsalomon@google.comffca4002011-02-22 20:34:01 +0000125bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000126
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000127 bool usingTextures[kNumStages];
bsalomon@google.com5782d712011-01-21 21:03:59 +0000128
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000129 for (int s = 0; s < kNumStages; ++s) {
130 usingTextures[s] = VertexUsesStage(s, fGeometrySrc.fVertexLayout);
reed@google.comac10a2d2010-12-22 21:39:39 +0000131
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000132 if (usingTextures[s] && fCurrDrawState.fSamplerStates[s].isGradient()) {
133 unimpl("Fixed pipe doesn't support radial/sweep gradients");
134 return false;
135 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000136 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000137
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000138 if (GR_GL_SUPPORT_ES1) {
139 if (BlendCoefReferencesConstant(fCurrDrawState.fSrcBlend) ||
140 BlendCoefReferencesConstant(fCurrDrawState.fDstBlend)) {
141 unimpl("ES1 doesn't support blend constant");
142 return false;
143 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000144 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000145
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +0000146 if (!flushGLStateCommon(type)) {
147 return false;
148 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000149
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000150 if (fDirtyFlags.fRenderTargetChanged) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000151 flushProjectionMatrix();
reed@google.comac10a2d2010-12-22 21:39:39 +0000152 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000153
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000154 for (int s = 0; s < kNumStages; ++s) {
155 bool wasUsingTexture = VertexUsesStage(s, fHWGeometryState.fVertexLayout);
156 if (usingTextures[s] != wasUsingTexture) {
157 setTextureUnit(s);
158 if (usingTextures[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000159 GR_GL(Enable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000160 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000161 GR_GL(Disable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000162 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000163 }
164 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000165
reed@google.comac10a2d2010-12-22 21:39:39 +0000166 uint32_t vertColor = (fGeometrySrc.fVertexLayout & kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000167 uint32_t prevVertColor = (fHWGeometryState.fVertexLayout &
reed@google.comac10a2d2010-12-22 21:39:39 +0000168 kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000169
reed@google.comac10a2d2010-12-22 21:39:39 +0000170 if (vertColor != prevVertColor) {
171 if (vertColor) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000172 GR_GL(ShadeModel(GR_GL_SMOOTH));
reed@google.comac10a2d2010-12-22 21:39:39 +0000173 // invalidate the immediate mode color
174 fHWDrawState.fColor = GrColor_ILLEGAL;
175 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000176 GR_GL(ShadeModel(GR_GL_FLAT));
reed@google.comac10a2d2010-12-22 21:39:39 +0000177 }
178 }
179
bsalomon@google.com5782d712011-01-21 21:03:59 +0000180
reed@google.comac10a2d2010-12-22 21:39:39 +0000181 if (!vertColor && fHWDrawState.fColor != fCurrDrawState.fColor) {
182 GR_GL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor),
183 GrColorUnpackG(fCurrDrawState.fColor),
184 GrColorUnpackB(fCurrDrawState.fColor),
185 GrColorUnpackA(fCurrDrawState.fColor)));
186 fHWDrawState.fColor = fCurrDrawState.fColor;
187 }
188
189 // set texture environment, decide whether we are modulating by RGB or A.
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000190 for (int s = 0; s < kNumStages; ++s) {
191 if (usingTextures[s]) {
192 GrGLTexture* texture = (GrGLTexture*)fCurrDrawState.fTextures[s];
193 if (NULL != texture) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000194 TextureEnvRGBOperands nextRGBOperand0 =
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000195 (GrPixelConfigIsAlphaOnly(texture->config())) ?
bsalomon@google.com5782d712011-01-21 21:03:59 +0000196 kAlpha_TextureEnvRGBOperand :
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000197 kColor_TextureEnvRGBOperand;
198 if (fHWRGBOperand0[s] != nextRGBOperand0) {
199 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000200 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV,
201 GR_GL_OPERAND0_RGB,
bsalomon@google.com5782d712011-01-21 21:03:59 +0000202 (nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ?
twiz@google.com0f31ca72011-03-18 17:38:11 +0000203 GR_GL_SRC_ALPHA :
204 GR_GL_SRC_COLOR));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000205 fHWRGBOperand0[s] = nextRGBOperand0;
reed@google.comac10a2d2010-12-22 21:39:39 +0000206 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000207
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000208 if (((1 << s) & fDirtyFlags.fTextureChangedMask) ||
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000209 (fHWDrawState.fSamplerStates[s].getMatrix() !=
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000210 getSamplerMatrix(s))) {
211
212 GrMatrix texMat = getSamplerMatrix(s);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000213 AdjustTextureMatrix(texture,
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000214 GrSamplerState::kNormal_SampleMode,
215 &texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000216 GrGpuMatrix glm;
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000217 glm.set(texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000218 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000219 GR_GL(MatrixMode(GR_GL_TEXTURE));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000220 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000221 recordHWSamplerMatrix(s, getSamplerMatrix(s));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000222 }
223 } else {
224 GrAssert(!"Rendering with texture vert flag set but no bound texture");
225 return false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000226 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000227 }
228 }
229
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000230 if (fHWDrawState.fViewMatrix != fCurrDrawState.fViewMatrix) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000231 GrGpuMatrix glm;
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000232 glm.set(fCurrDrawState.fViewMatrix);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000233 GR_GL(MatrixMode(GR_GL_MODELVIEW));
reed@google.comac10a2d2010-12-22 21:39:39 +0000234 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.com5782d712011-01-21 21:03:59 +0000235 fHWDrawState.fViewMatrix =
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000236 fCurrDrawState.fViewMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +0000237 }
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000238 resetDirtyFlags();
reed@google.comac10a2d2010-12-22 21:39:39 +0000239 return true;
240}
241
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000242void GrGpuGLFixed::setupGeometry(int* startVertex,
243 int* startIndex,
244 int vertexCount,
245 int indexCount) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000246
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000247 int newColorOffset;
248 int newTexCoordOffsets[kNumStages];
bsalomon@google.com5782d712011-01-21 21:03:59 +0000249
twiz@google.com0f31ca72011-03-18 17:38:11 +0000250 GrGLsizei newStride = VertexSizeAndOffsetsByStage(fGeometrySrc.fVertexLayout,
251 newTexCoordOffsets,
252 &newColorOffset);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000253 int oldColorOffset;
254 int oldTexCoordOffsets[kNumStages];
twiz@google.com0f31ca72011-03-18 17:38:11 +0000255 GrGLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout,
256 oldTexCoordOffsets,
257 &oldColorOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000258
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000259 bool indexed = NULL != startIndex;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000260
261 int extraVertexOffset;
262 int extraIndexOffset;
263 setBuffers(indexed, &extraVertexOffset, &extraIndexOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000264
twiz@google.com0f31ca72011-03-18 17:38:11 +0000265 GrGLenum scalarType;
reed@google.comac10a2d2010-12-22 21:39:39 +0000266 if (fGeometrySrc.fVertexLayout & kTextFormat_VertexLayoutBit) {
267 scalarType = GrGLTextType;
268 } else {
269 scalarType = GrGLType;
270 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000271
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000272 size_t vertexOffset = (*startVertex + extraVertexOffset) * newStride;
273 *startVertex = 0;
274 if (indexed) {
275 *startIndex += extraIndexOffset;
276 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000277
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000278 // all the Pointers must be set if any of these are true
279 bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty ||
280 vertexOffset != fHWGeometryState.fVertexOffset ||
281 newStride != oldStride;
282
283 // position and tex coord offsets change if above conditions are true
284 // or the type changed based on text vs nontext type coords.
285 bool posAndTexChange = allOffsetsChange ||
286 ((GrGLTextType != GrGLType) &&
287 (kTextFormat_VertexLayoutBit &
288 (fHWGeometryState.fVertexLayout ^
289 fGeometrySrc.fVertexLayout)));
290
291 if (posAndTexChange) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000292 GR_GL(VertexPointer(2, scalarType, newStride, (GrGLvoid*)vertexOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000293 fHWGeometryState.fVertexOffset = vertexOffset;
reed@google.comac10a2d2010-12-22 21:39:39 +0000294 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000295
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000296 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000297 // need to enable array if tex coord offset is 0
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000298 // (using positions as coords)
299 if (newTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000300 GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[s]);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000301 if (oldTexCoordOffsets[s] < 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000302 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
303 GR_GL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000304 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
305 } else if (posAndTexChange ||
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000306 newTexCoordOffsets[s] != oldTexCoordOffsets[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000307 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000308 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000309 }
310 } else if (oldTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000311 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
312 GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000313 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000314 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000315
reed@google.comac10a2d2010-12-22 21:39:39 +0000316 if (newColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000317 GrGLvoid* colorOffset = (GrGLvoid*)(vertexOffset + newColorOffset);
reed@google.comac10a2d2010-12-22 21:39:39 +0000318 if (oldColorOffset <= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000319 GR_GL(EnableClientState(GR_GL_COLOR_ARRAY));
320 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000321 } else if (allOffsetsChange || newColorOffset != oldColorOffset) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000322 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
reed@google.comac10a2d2010-12-22 21:39:39 +0000323 }
324 } else if (oldColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000325 GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000326 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000327
reed@google.comac10a2d2010-12-22 21:39:39 +0000328 fHWGeometryState.fVertexLayout = fGeometrySrc.fVertexLayout;
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000329 fHWGeometryState.fArrayPtrsDirty = false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000330}