blob: b955eebbc730d32f70f5c946d838c12f8cd725f8 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#include "GrGLConfig.h"
12
reed@google.comac10a2d2010-12-22 21:39:39 +000013#include "GrGpuGLFixed.h"
14#include "GrGpuVertex.h"
15
16#define SKIP_CACHE_CHECK true
17
18struct GrGpuMatrix {
twiz@google.com0f31ca72011-03-18 17:38:11 +000019 GrGLfloat fMat[16];
bsalomon@google.com5782d712011-01-21 21:03:59 +000020
reed@google.comac10a2d2010-12-22 21:39:39 +000021 void reset() {
22 Gr_bzero(fMat, sizeof(fMat));
23 fMat[0] = fMat[5] = fMat[10] = fMat[15] = GR_Scalar1;
24 }
bsalomon@google.com5782d712011-01-21 21:03:59 +000025
reed@google.comac10a2d2010-12-22 21:39:39 +000026 void set(const GrMatrix& m) {
27 Gr_bzero(fMat, sizeof(fMat));
bsalomon@google.comcc4dac32011-05-10 13:52:42 +000028 fMat[0] = GrScalarToFloat(m[GrMatrix::kMScaleX]);
29 fMat[4] = GrScalarToFloat(m[GrMatrix::kMSkewX]);
30 fMat[12] = GrScalarToFloat(m[GrMatrix::kMTransX]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000031
bsalomon@google.comcc4dac32011-05-10 13:52:42 +000032 fMat[1] = GrScalarToFloat(m[GrMatrix::kMSkewY]);
33 fMat[5] = GrScalarToFloat(m[GrMatrix::kMScaleY]);
34 fMat[13] = GrScalarToFloat(m[GrMatrix::kMTransY]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000035
bsalomon@google.comcc4dac32011-05-10 13:52:42 +000036 fMat[3] = GrScalarToFloat(m[GrMatrix::kMPersp0]);
37 fMat[7] = GrScalarToFloat(m[GrMatrix::kMPersp1]);
38 fMat[15] = GrScalarToFloat(m[GrMatrix::kMPersp2]);
bsalomon@google.com5782d712011-01-21 21:03:59 +000039
bsalomon@google.comc6cf7232011-02-17 16:43:10 +000040 fMat[10] = 1.f; // z-scale
reed@google.comac10a2d2010-12-22 21:39:39 +000041 }
42};
43
44// these must match the order in the corresponding enum in GrGpu.h
twiz@google.com0f31ca72011-03-18 17:38:11 +000045static const GrGLenum gMatrixMode2Enum[] = {
46 GR_GL_MODELVIEW, GR_GL_TEXTURE
reed@google.comac10a2d2010-12-22 21:39:39 +000047};
48
49///////////////////////////////////////////////////////////////////////////////
50
51GrGpuGLFixed::GrGpuGLFixed() {
bsalomon@google.com6aef1fb2011-05-05 12:33:22 +000052 f4X4DownsampleFilterSupport = false;
bsalomon@google.com271cffc2011-05-20 14:13:56 +000053 fDualSourceBlendingSupport = false;
reed@google.comac10a2d2010-12-22 21:39:39 +000054}
55
56GrGpuGLFixed::~GrGpuGLFixed() {
57}
58
59void GrGpuGLFixed::resetContext() {
60 INHERITED::resetContext();
reed@google.comac10a2d2010-12-22 21:39:39 +000061
twiz@google.com0f31ca72011-03-18 17:38:11 +000062 GR_GL(Disable(GR_GL_TEXTURE_2D));
reed@google.comac10a2d2010-12-22 21:39:39 +000063
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000064 for (int s = 0; s < kNumStages; ++s) {
65 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +000066 GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
67 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_TEXTURE_ENV_MODE, GR_GL_COMBINE));
68 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_RGB, GR_GL_MODULATE));
69 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_RGB, GR_GL_TEXTURE0+s));
70 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_RGB, GR_GL_PREVIOUS));
71 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_RGB, GR_GL_SRC_COLOR));
reed@google.comac10a2d2010-12-22 21:39:39 +000072
twiz@google.com0f31ca72011-03-18 17:38:11 +000073 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_COMBINE_ALPHA, GR_GL_MODULATE));
74 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC0_ALPHA, GR_GL_TEXTURE0+s));
75 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND0_ALPHA, GR_GL_SRC_ALPHA));
76 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_SRC1_ALPHA, GR_GL_PREVIOUS));
77 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV, GR_GL_OPERAND1_ALPHA, GR_GL_SRC_ALPHA));
bsalomon@google.com5782d712011-01-21 21:03:59 +000078
79 // color oprand0 changes between GL_SRC_COLR and GL_SRC_ALPHA depending
80 // upon whether we have a (premultiplied) RGBA texture or just an ALPHA
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000081 // texture, e.g.:
82 //glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
bsalomon@google.com5782d712011-01-21 21:03:59 +000083 fHWRGBOperand0[s] = (TextureEnvRGBOperands) -1;
bsalomon@google.com8531c1c2011-01-13 19:52:45 +000084 }
reed@google.comac10a2d2010-12-22 21:39:39 +000085
86 fHWGeometryState.fVertexLayout = 0;
bsalomon@google.com1c13c962011-02-14 16:51:21 +000087 fHWGeometryState.fVertexOffset = ~0;
twiz@google.com0f31ca72011-03-18 17:38:11 +000088 GR_GL(EnableClientState(GR_GL_VERTEX_ARRAY));
89 GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
90 GR_GL(ShadeModel(GR_GL_FLAT));
91 GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
bsalomon@google.com5782d712011-01-21 21:03:59 +000092
93 GR_GL(PointSize(1.f));
94
reed@google.comac10a2d2010-12-22 21:39:39 +000095 GrGLClearErr();
96 fTextVerts = false;
97
reed@google.comac10a2d2010-12-22 21:39:39 +000098 fBaseVertex = 0xffffffff;
99}
100
101
102void GrGpuGLFixed::flushProjectionMatrix() {
103 float mat[16];
104 Gr_bzero(mat, sizeof(mat));
bsalomon@google.com5782d712011-01-21 21:03:59 +0000105
reed@google.comac10a2d2010-12-22 21:39:39 +0000106 GrAssert(NULL != fCurrDrawState.fRenderTarget);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000107
reed@google.comac10a2d2010-12-22 21:39:39 +0000108 mat[0] = 2.f / fCurrDrawState.fRenderTarget->width();
109 mat[5] = -2.f / fCurrDrawState.fRenderTarget->height();
110 mat[10] = -1.f;
111 mat[15] = 1;
bsalomon@google.com5782d712011-01-21 21:03:59 +0000112
reed@google.comac10a2d2010-12-22 21:39:39 +0000113 mat[12] = -1.f;
114 mat[13] = 1.f;
bsalomon@google.com5782d712011-01-21 21:03:59 +0000115
twiz@google.com0f31ca72011-03-18 17:38:11 +0000116 GR_GL(MatrixMode(GR_GL_PROJECTION));
reed@google.comac10a2d2010-12-22 21:39:39 +0000117 GR_GL(LoadMatrixf(mat));
118}
119
bsalomon@google.comffca4002011-02-22 20:34:01 +0000120bool GrGpuGLFixed::flushGraphicsState(GrPrimitiveType type) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000121
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000122 bool usingTextures[kNumStages];
bsalomon@google.com5782d712011-01-21 21:03:59 +0000123
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000124 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.coma47a48d2011-04-26 20:22:11 +0000125 usingTextures[s] = this->isStageEnabled(s);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000126 if (usingTextures[s] && fCurrDrawState.fSamplerStates[s].isGradient()) {
127 unimpl("Fixed pipe doesn't support radial/sweep gradients");
128 return false;
129 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000130 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000131
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000132 if (GR_GL_SUPPORT_ES1) {
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000133 if (BlendCoeffReferencesConstant(fCurrDrawState.fSrcBlend) ||
134 BlendCoeffReferencesConstant(fCurrDrawState.fDstBlend)) {
twiz@google.comb65e0cb2011-03-18 20:41:44 +0000135 unimpl("ES1 doesn't support blend constant");
136 return false;
137 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000138 }
bsalomon@google.com080773c2011-03-15 19:09:25 +0000139
bsalomon@google.com2e7b43d2011-01-18 20:57:22 +0000140 if (!flushGLStateCommon(type)) {
141 return false;
142 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000143
bsalomon@google.com271cffc2011-05-20 14:13:56 +0000144 this->flushBlend(type, fCurrDrawState.fSrcBlend, fCurrDrawState.fDstBlend);
145
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000146 if (fDirtyFlags.fRenderTargetChanged) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000147 flushProjectionMatrix();
reed@google.comac10a2d2010-12-22 21:39:39 +0000148 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000149
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000150 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.coma47a48d2011-04-26 20:22:11 +0000151 bool wasUsingTexture = StageWillBeUsed(s, fHWGeometryState.fVertexLayout, fHWDrawState);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000152 if (usingTextures[s] != wasUsingTexture) {
153 setTextureUnit(s);
154 if (usingTextures[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000155 GR_GL(Enable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000156 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000157 GR_GL(Disable(GR_GL_TEXTURE_2D));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000158 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000159 }
160 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000161
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000162 uint32_t vertColor = (this->getGeomSrc().fVertexLayout & kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000163 uint32_t prevVertColor = (fHWGeometryState.fVertexLayout &
reed@google.comac10a2d2010-12-22 21:39:39 +0000164 kColor_VertexLayoutBit);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000165
reed@google.comac10a2d2010-12-22 21:39:39 +0000166 if (vertColor != prevVertColor) {
167 if (vertColor) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000168 GR_GL(ShadeModel(GR_GL_SMOOTH));
reed@google.comac10a2d2010-12-22 21:39:39 +0000169 // invalidate the immediate mode color
170 fHWDrawState.fColor = GrColor_ILLEGAL;
171 } else {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000172 GR_GL(ShadeModel(GR_GL_FLAT));
reed@google.comac10a2d2010-12-22 21:39:39 +0000173 }
174 }
175
bsalomon@google.com5782d712011-01-21 21:03:59 +0000176
reed@google.comac10a2d2010-12-22 21:39:39 +0000177 if (!vertColor && fHWDrawState.fColor != fCurrDrawState.fColor) {
178 GR_GL(Color4ub(GrColorUnpackR(fCurrDrawState.fColor),
179 GrColorUnpackG(fCurrDrawState.fColor),
180 GrColorUnpackB(fCurrDrawState.fColor),
181 GrColorUnpackA(fCurrDrawState.fColor)));
182 fHWDrawState.fColor = fCurrDrawState.fColor;
183 }
184
185 // set texture environment, decide whether we are modulating by RGB or A.
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000186 for (int s = 0; s < kNumStages; ++s) {
187 if (usingTextures[s]) {
188 GrGLTexture* texture = (GrGLTexture*)fCurrDrawState.fTextures[s];
189 if (NULL != texture) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000190 TextureEnvRGBOperands nextRGBOperand0 =
bsalomon@google.com669fdc42011-04-05 17:08:27 +0000191 (GrPixelConfigIsAlphaOnly(texture->config())) ?
bsalomon@google.com5782d712011-01-21 21:03:59 +0000192 kAlpha_TextureEnvRGBOperand :
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000193 kColor_TextureEnvRGBOperand;
194 if (fHWRGBOperand0[s] != nextRGBOperand0) {
195 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000196 GR_GL(TexEnvi(GR_GL_TEXTURE_ENV,
197 GR_GL_OPERAND0_RGB,
bsalomon@google.com5782d712011-01-21 21:03:59 +0000198 (nextRGBOperand0==kAlpha_TextureEnvRGBOperand) ?
twiz@google.com0f31ca72011-03-18 17:38:11 +0000199 GR_GL_SRC_ALPHA :
200 GR_GL_SRC_COLOR));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000201 fHWRGBOperand0[s] = nextRGBOperand0;
reed@google.comac10a2d2010-12-22 21:39:39 +0000202 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000203
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000204 if (((1 << s) & fDirtyFlags.fTextureChangedMask) ||
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000205 (fHWDrawState.fSamplerStates[s].getMatrix() !=
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000206 getSamplerMatrix(s))) {
207
208 GrMatrix texMat = getSamplerMatrix(s);
bsalomon@google.coma7f84e12011-03-10 14:13:19 +0000209 AdjustTextureMatrix(texture,
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000210 GrSamplerState::kNormal_SampleMode,
211 &texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000212 GrGpuMatrix glm;
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000213 glm.set(texMat);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000214 setTextureUnit(s);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000215 GR_GL(MatrixMode(GR_GL_TEXTURE));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000216 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000217 recordHWSamplerMatrix(s, getSamplerMatrix(s));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000218 }
219 } else {
220 GrAssert(!"Rendering with texture vert flag set but no bound texture");
221 return false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000222 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000223 }
224 }
225
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000226 if (fHWDrawState.fViewMatrix != fCurrDrawState.fViewMatrix) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000227 GrGpuMatrix glm;
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000228 glm.set(fCurrDrawState.fViewMatrix);
twiz@google.com0f31ca72011-03-18 17:38:11 +0000229 GR_GL(MatrixMode(GR_GL_MODELVIEW));
reed@google.comac10a2d2010-12-22 21:39:39 +0000230 GR_GL(LoadMatrixf(glm.fMat));
bsalomon@google.com5782d712011-01-21 21:03:59 +0000231 fHWDrawState.fViewMatrix =
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000232 fCurrDrawState.fViewMatrix;
reed@google.comac10a2d2010-12-22 21:39:39 +0000233 }
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000234 resetDirtyFlags();
reed@google.comac10a2d2010-12-22 21:39:39 +0000235 return true;
236}
237
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000238void GrGpuGLFixed::setupGeometry(int* startVertex,
239 int* startIndex,
240 int vertexCount,
241 int indexCount) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000242
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000243 int newColorOffset;
244 int newTexCoordOffsets[kNumStages];
bsalomon@google.com5782d712011-01-21 21:03:59 +0000245
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000246 GrGLsizei newStride = VertexSizeAndOffsetsByStage(this->getGeomSrc().fVertexLayout,
twiz@google.com0f31ca72011-03-18 17:38:11 +0000247 newTexCoordOffsets,
248 &newColorOffset);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000249 int oldColorOffset;
250 int oldTexCoordOffsets[kNumStages];
twiz@google.com0f31ca72011-03-18 17:38:11 +0000251 GrGLsizei oldStride = VertexSizeAndOffsetsByStage(fHWGeometryState.fVertexLayout,
252 oldTexCoordOffsets,
253 &oldColorOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000254
bsalomon@google.comc6cf7232011-02-17 16:43:10 +0000255 bool indexed = NULL != startIndex;
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000256
257 int extraVertexOffset;
258 int extraIndexOffset;
259 setBuffers(indexed, &extraVertexOffset, &extraIndexOffset);
bsalomon@google.com5782d712011-01-21 21:03:59 +0000260
twiz@google.com0f31ca72011-03-18 17:38:11 +0000261 GrGLenum scalarType;
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000262 if (this->getGeomSrc().fVertexLayout & kTextFormat_VertexLayoutBit) {
reed@google.comac10a2d2010-12-22 21:39:39 +0000263 scalarType = GrGLTextType;
264 } else {
265 scalarType = GrGLType;
266 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000267
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000268 size_t vertexOffset = (*startVertex + extraVertexOffset) * newStride;
269 *startVertex = 0;
270 if (indexed) {
271 *startIndex += extraIndexOffset;
272 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000273
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000274 // all the Pointers must be set if any of these are true
275 bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty ||
276 vertexOffset != fHWGeometryState.fVertexOffset ||
277 newStride != oldStride;
278
279 // position and tex coord offsets change if above conditions are true
280 // or the type changed based on text vs nontext type coords.
281 bool posAndTexChange = allOffsetsChange ||
282 ((GrGLTextType != GrGLType) &&
283 (kTextFormat_VertexLayoutBit &
284 (fHWGeometryState.fVertexLayout ^
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000285 this->getGeomSrc().fVertexLayout)));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000286
287 if (posAndTexChange) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000288 GR_GL(VertexPointer(2, scalarType, newStride, (GrGLvoid*)vertexOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000289 fHWGeometryState.fVertexOffset = vertexOffset;
reed@google.comac10a2d2010-12-22 21:39:39 +0000290 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000291
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000292 for (int s = 0; s < kNumStages; ++s) {
bsalomon@google.com5782d712011-01-21 21:03:59 +0000293 // need to enable array if tex coord offset is 0
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000294 // (using positions as coords)
295 if (newTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000296 GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[s]);
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000297 if (oldTexCoordOffsets[s] < 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000298 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
299 GR_GL(EnableClientState(GR_GL_TEXTURE_COORD_ARRAY));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000300 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
301 } else if (posAndTexChange ||
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000302 newTexCoordOffsets[s] != oldTexCoordOffsets[s]) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000303 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000304 GR_GL(TexCoordPointer(2, scalarType, newStride, texCoordOffset));
bsalomon@google.com8531c1c2011-01-13 19:52:45 +0000305 }
306 } else if (oldTexCoordOffsets[s] >= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000307 GR_GL(ClientActiveTexture(GR_GL_TEXTURE0+s));
308 GR_GL(DisableClientState(GR_GL_TEXTURE_COORD_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000309 }
reed@google.comac10a2d2010-12-22 21:39:39 +0000310 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000311
reed@google.comac10a2d2010-12-22 21:39:39 +0000312 if (newColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000313 GrGLvoid* colorOffset = (GrGLvoid*)(vertexOffset + newColorOffset);
reed@google.comac10a2d2010-12-22 21:39:39 +0000314 if (oldColorOffset <= 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000315 GR_GL(EnableClientState(GR_GL_COLOR_ARRAY));
316 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
bsalomon@google.com1c13c962011-02-14 16:51:21 +0000317 } else if (allOffsetsChange || newColorOffset != oldColorOffset) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000318 GR_GL(ColorPointer(4, GR_GL_UNSIGNED_BYTE, newStride, colorOffset));
reed@google.comac10a2d2010-12-22 21:39:39 +0000319 }
320 } else if (oldColorOffset > 0) {
twiz@google.com0f31ca72011-03-18 17:38:11 +0000321 GR_GL(DisableClientState(GR_GL_COLOR_ARRAY));
reed@google.comac10a2d2010-12-22 21:39:39 +0000322 }
bsalomon@google.com5782d712011-01-21 21:03:59 +0000323
bsalomon@google.com25fb21f2011-06-21 18:17:25 +0000324 fHWGeometryState.fVertexLayout = this->getGeomSrc().fVertexLayout;
bsalomon@google.com7acdb8e2011-02-11 14:07:02 +0000325 fHWGeometryState.fArrayPtrsDirty = false;
reed@google.comac10a2d2010-12-22 21:39:39 +0000326}