blob: 4440bcdd8531413c0e3e1f6a91a1494d1afc97df [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) {
bsalomon@google.coma47a48d2011-04-26 20:22:11 +0000130 usingTextures[s] = this->isStageEnabled(s);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000131 if (usingTextures[s] && fCurrDrawState.fSamplerStates[s].isGradient()) {
132 unimpl("Fixed pipe doesn't support radial/sweep gradients");
133 return false;
134 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000135 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000136
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000137 if (GR_GL_SUPPORT_ES1) {
138 if (BlendCoefReferencesConstant(fCurrDrawState.fSrcBlend) ||
139 BlendCoefReferencesConstant(fCurrDrawState.fDstBlend)) {
140 unimpl("ES1 doesn't support blend constant");
141 return false;
142 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000143 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000144
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +0000145 if (!flushGLStateCommon(type)) {
146 return false;
147 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000148
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000149 if (fDirtyFlags.fRenderTargetChanged) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000150 flushProjectionMatrix();
reed@google.comac10a2d2010-12-22 21:39:39 +0000151 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000152
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000153 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.coma47a48d2011-04-26 20:22:11 +0000154 bool wasUsingTexture = StageWillBeUsed(s, fHWGeometryState.fVertexLayout, fHWDrawState);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000155 if (usingTextures[s] != wasUsingTexture) {
156 setTextureUnit(s);
157 if (usingTextures[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000158 GR_GL(Enable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000159 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000160 GR_GL(Disable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000161 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000162 }
163 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000164
reed@google.comac10a2d2010-12-22 21:39:39 +0000165 uint32_t vertColor = (fGeometrySrc.fVertexLayout & kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000166 uint32_t prevVertColor = (fHWGeometryState.fVertexLayout &
reed@google.comac10a2d2010-12-22 21:39:39 +0000167 kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000168
reed@google.comac10a2d2010-12-22 21:39:39 +0000169 if (vertColor != prevVertColor) {
170 if (vertColor) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000171 GR_GL(ShadeModel(GR_GL_SMOOTH));
reed@google.comac10a2d2010-12-22 21:39:39 +0000172 // invalidate the immediate mode color
173 fHWDrawState.fColor = GrColor_ILLEGAL;
174 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000175 GR_GL(ShadeModel(GR_GL_FLAT));
reed@google.comac10a2d2010-12-22 21:39:39 +0000176 }
177 }
178
bsalomon@google.com5782d712011-01-21 21:03:59 +0000179
reed@google.comac10a2d2010-12-22 21:39:39 +0000180 if (!vertColor && fHWDrawState.fColor != fCurrDrawState.fColor) {
181 GR_GL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor),
182 GrColorUnpackG(fCurrDrawState.fColor),
183 GrColorUnpackB(fCurrDrawState.fColor),
184 GrColorUnpackA(fCurrDrawState.fColor)));
185 fHWDrawState.fColor = fCurrDrawState.fColor;
186 }
187
188 // set texture environment, decide whether we are modulating by RGB or A.
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000189 for (int s = 0; s < kNumStages; ++s) {
190 if (usingTextures[s]) {
191 GrGLTexture* texture = (GrGLTexture*)fCurrDrawState.fTextures[s];
192 if (NULL != texture) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000193 TextureEnvRGBOperands nextRGBOperand0 =
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000194 (GrPixelConfigIsAlphaOnly(texture->config())) ?
bsalomon@google.com5782d712011-01-21 21:03:59 +0000195 kAlpha_TextureEnvRGBOperand :
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000196 kColor_TextureEnvRGBOperand;
197 if (fHWRGBOperand0[s] != nextRGBOperand0) {
198 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000199 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV,
200 GR_GL_OPERAND0_RGB,
bsalomon@google.com5782d712011-01-21 21:03:59 +0000201 (nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ?
twiz@google.com0f31ca72011-03-18 17:38:11 +0000202 GR_GL_SRC_ALPHA :
203 GR_GL_SRC_COLOR));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000204 fHWRGBOperand0[s] = nextRGBOperand0;
reed@google.comac10a2d2010-12-22 21:39:39 +0000205 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000206
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000207 if (((1 << s) & fDirtyFlags.fTextureChangedMask) ||
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000208 (fHWDrawState.fSamplerStates[s].getMatrix() !=
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000209 getSamplerMatrix(s))) {
210
211 GrMatrix texMat = getSamplerMatrix(s);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000212 AdjustTextureMatrix(texture,
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000213 GrSamplerState::kNormal_SampleMode,
214 &texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000215 GrGpuMatrix glm;
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000216 glm.set(texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000217 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000218 GR_GL(MatrixMode(GR_GL_TEXTURE));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000219 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000220 recordHWSamplerMatrix(s, getSamplerMatrix(s));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000221 }
222 } else {
223 GrAssert(!"Rendering with texture vert flag set but no bound texture");
224 return false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000225 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000226 }
227 }
228
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000229 if (fHWDrawState.fViewMatrix != fCurrDrawState.fViewMatrix) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000230 GrGpuMatrix glm;
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000231 glm.set(fCurrDrawState.fViewMatrix);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000232 GR_GL(MatrixMode(GR_GL_MODELVIEW));
reed@google.comac10a2d2010-12-22 21:39:39 +0000233 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.com5782d712011-01-21 21:03:59 +0000234 fHWDrawState.fViewMatrix =
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000235 fCurrDrawState.fViewMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +0000236 }
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000237 resetDirtyFlags();
reed@google.comac10a2d2010-12-22 21:39:39 +0000238 return true;
239}
240
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000241void GrGpuGLFixed::setupGeometry(int* startVertex,
242 int* startIndex,
243 int vertexCount,
244 int indexCount) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000245
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000246 int newColorOffset;
247 int newTexCoordOffsets[kNumStages];
bsalomon@google.com5782d712011-01-21 21:03:59 +0000248
twiz@google.com0f31ca72011-03-18 17:38:11 +0000249 GrGLsizei newStride = VertexSizeAndOffsetsByStage(fGeometrySrc.fVertexLayout,
250 newTexCoordOffsets,
251 &newColorOffset);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000252 int oldColorOffset;
253 int oldTexCoordOffsets[kNumStages];
twiz@google.com0f31ca72011-03-18 17:38:11 +0000254 GrGLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout,
255 oldTexCoordOffsets,
256 &oldColorOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000257
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000258 bool indexed = NULL != startIndex;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000259
260 int extraVertexOffset;
261 int extraIndexOffset;
262 setBuffers(indexed, &extraVertexOffset, &extraIndexOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000263
twiz@google.com0f31ca72011-03-18 17:38:11 +0000264 GrGLenum scalarType;
reed@google.comac10a2d2010-12-22 21:39:39 +0000265 if (fGeometrySrc.fVertexLayout & kTextFormat_VertexLayoutBit) {
266 scalarType = GrGLTextType;
267 } else {
268 scalarType = GrGLType;
269 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000270
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000271 size_t vertexOffset = (*startVertex + extraVertexOffset) * newStride;
272 *startVertex = 0;
273 if (indexed) {
274 *startIndex += extraIndexOffset;
275 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000276
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000277 // all the Pointers must be set if any of these are true
278 bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty ||
279 vertexOffset != fHWGeometryState.fVertexOffset ||
280 newStride != oldStride;
281
282 // position and tex coord offsets change if above conditions are true
283 // or the type changed based on text vs nontext type coords.
284 bool posAndTexChange = allOffsetsChange ||
285 ((GrGLTextType != GrGLType) &&
286 (kTextFormat_VertexLayoutBit &
287 (fHWGeometryState.fVertexLayout ^
288 fGeometrySrc.fVertexLayout)));
289
290 if (posAndTexChange) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000291 GR_GL(VertexPointer(2, scalarType, newStride, (GrGLvoid*)vertexOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000292 fHWGeometryState.fVertexOffset = vertexOffset;
reed@google.comac10a2d2010-12-22 21:39:39 +0000293 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000294
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000295 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000296 // need to enable array if tex coord offset is 0
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000297 // (using positions as coords)
298 if (newTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000299 GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[s]);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000300 if (oldTexCoordOffsets[s] < 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000301 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
302 GR_GL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000303 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
304 } else if (posAndTexChange ||
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000305 newTexCoordOffsets[s] != oldTexCoordOffsets[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000306 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000307 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000308 }
309 } else if (oldTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000310 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
311 GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000312 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000313 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000314
reed@google.comac10a2d2010-12-22 21:39:39 +0000315 if (newColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000316 GrGLvoid* colorOffset = (GrGLvoid*)(vertexOffset + newColorOffset);
reed@google.comac10a2d2010-12-22 21:39:39 +0000317 if (oldColorOffset <= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000318 GR_GL(EnableClientState(GR_GL_COLOR_ARRAY));
319 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000320 } else if (allOffsetsChange || newColorOffset != oldColorOffset) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000321 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
reed@google.comac10a2d2010-12-22 21:39:39 +0000322 }
323 } else if (oldColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000324 GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000325 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000326
reed@google.comac10a2d2010-12-22 21:39:39 +0000327 fHWGeometryState.fVertexLayout = fGeometrySrc.fVertexLayout;
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000328 fHWGeometryState.fArrayPtrsDirty = false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000329}