1 //
2 // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // Context_gles_1_0.cpp: Implements the GLES1-specific parts of Context.
8 
9 #include "libANGLE/Context.h"
10 
11 #include "common/mathutil.h"
12 #include "common/utilities.h"
13 
14 #include "libANGLE/GLES1Renderer.h"
15 #include "libANGLE/queryconversions.h"
16 #include "libANGLE/queryutils.h"
17 
18 namespace
19 {
20 
FixedMatrixToMat4(const GLfixed * m)21 angle::Mat4 FixedMatrixToMat4(const GLfixed *m)
22 {
23     angle::Mat4 matrixAsFloat;
24     GLfloat *floatData = matrixAsFloat.data();
25 
26     for (int i = 0; i < 16; i++)
27     {
28         floatData[i] = gl::ConvertFixedToFloat(m[i]);
29     }
30 
31     return matrixAsFloat;
32 }
33 
34 }  // namespace
35 
36 namespace gl
37 {
38 
alphaFunc(AlphaTestFunc func,GLfloat ref)39 void Context::alphaFunc(AlphaTestFunc func, GLfloat ref)
40 {
41     mState.gles1().setAlphaFunc(func, ref);
42 }
43 
alphaFuncx(AlphaTestFunc func,GLfixed ref)44 void Context::alphaFuncx(AlphaTestFunc func, GLfixed ref)
45 {
46     mState.gles1().setAlphaFunc(func, ConvertFixedToFloat(ref));
47 }
48 
clearColorx(GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)49 void Context::clearColorx(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
50 {
51     mState.setColorClearValue(ConvertFixedToFloat(red), ConvertFixedToFloat(green),
52                               ConvertFixedToFloat(blue), ConvertFixedToFloat(alpha));
53 }
54 
clearDepthx(GLfixed depth)55 void Context::clearDepthx(GLfixed depth)
56 {
57     mState.setDepthClearValue(clamp01(ConvertFixedToFloat(depth)));
58 }
59 
clientActiveTexture(GLenum texture)60 void Context::clientActiveTexture(GLenum texture)
61 {
62     mState.gles1().setClientTextureUnit(texture - GL_TEXTURE0);
63     mStateCache.onGLES1ClientStateChange(this);
64 }
65 
clipPlanef(GLenum p,const GLfloat * eqn)66 void Context::clipPlanef(GLenum p, const GLfloat *eqn)
67 {
68     mState.gles1().setClipPlane(p - GL_CLIP_PLANE0, eqn);
69 }
70 
clipPlanex(GLenum plane,const GLfixed * equation)71 void Context::clipPlanex(GLenum plane, const GLfixed *equation)
72 {
73     const GLfloat equationf[4] = {
74         ConvertFixedToFloat(equation[0]),
75         ConvertFixedToFloat(equation[1]),
76         ConvertFixedToFloat(equation[2]),
77         ConvertFixedToFloat(equation[3]),
78     };
79 
80     mState.gles1().setClipPlane(plane - GL_CLIP_PLANE0, equationf);
81 }
82 
color4f(GLfloat red,GLfloat green,GLfloat blue,GLfloat alpha)83 void Context::color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
84 {
85     mState.gles1().setCurrentColor({red, green, blue, alpha});
86 }
87 
color4ub(GLubyte red,GLubyte green,GLubyte blue,GLubyte alpha)88 void Context::color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
89 {
90     mState.gles1().setCurrentColor(
91         {normalizedToFloat<uint8_t>(red), normalizedToFloat<uint8_t>(green),
92          normalizedToFloat<uint8_t>(blue), normalizedToFloat<uint8_t>(alpha)});
93 }
94 
color4x(GLfixed red,GLfixed green,GLfixed blue,GLfixed alpha)95 void Context::color4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
96 {
97     mState.gles1().setCurrentColor({ConvertFixedToFloat(red), ConvertFixedToFloat(green),
98                                     ConvertFixedToFloat(blue), ConvertFixedToFloat(alpha)});
99 }
100 
colorPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)101 void Context::colorPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
102 {
103     // Note that we normalize data for UnsignedByte types. This is to match the behavior
104     // of current native GLES drivers.
105     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Color), size, type,
106                         type == VertexAttribType::UnsignedByte, stride, ptr);
107 }
108 
depthRangex(GLfixed n,GLfixed f)109 void Context::depthRangex(GLfixed n, GLfixed f)
110 {
111     mState.setDepthRange(clamp01(ConvertFixedToFloat(n)), clamp01(ConvertFixedToFloat(f)));
112 }
113 
disableClientState(ClientVertexArrayType clientState)114 void Context::disableClientState(ClientVertexArrayType clientState)
115 {
116     mState.gles1().setClientStateEnabled(clientState, false);
117     disableVertexAttribArray(vertexArrayIndex(clientState));
118     mStateCache.onGLES1ClientStateChange(this);
119 }
120 
enableClientState(ClientVertexArrayType clientState)121 void Context::enableClientState(ClientVertexArrayType clientState)
122 {
123     mState.gles1().setClientStateEnabled(clientState, true);
124     enableVertexAttribArray(vertexArrayIndex(clientState));
125     mStateCache.onGLES1ClientStateChange(this);
126 }
127 
fogf(GLenum pname,GLfloat param)128 void Context::fogf(GLenum pname, GLfloat param)
129 {
130     SetFogParameters(&mState.gles1(), pname, &param);
131 }
132 
fogfv(GLenum pname,const GLfloat * params)133 void Context::fogfv(GLenum pname, const GLfloat *params)
134 {
135     SetFogParameters(&mState.gles1(), pname, params);
136 }
137 
fogx(GLenum pname,GLfixed param)138 void Context::fogx(GLenum pname, GLfixed param)
139 {
140     if (GetFogParameterCount(pname) == 1)
141     {
142         GLfloat paramf = pname == GL_FOG_MODE ? ConvertToGLenum(param) : ConvertFixedToFloat(param);
143         fogf(pname, paramf);
144     }
145     else
146     {
147         UNREACHABLE();
148     }
149 }
150 
fogxv(GLenum pname,const GLfixed * params)151 void Context::fogxv(GLenum pname, const GLfixed *params)
152 {
153     int paramCount = GetFogParameterCount(pname);
154 
155     if (paramCount > 0)
156     {
157         GLfloat paramsf[4];
158         for (int i = 0; i < paramCount; i++)
159         {
160             paramsf[i] =
161                 pname == GL_FOG_MODE ? ConvertToGLenum(params[i]) : ConvertFixedToFloat(params[i]);
162         }
163         fogfv(pname, paramsf);
164     }
165     else
166     {
167         UNREACHABLE();
168     }
169 }
170 
frustumf(GLfloat l,GLfloat r,GLfloat b,GLfloat t,GLfloat n,GLfloat f)171 void Context::frustumf(GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f)
172 {
173     mState.gles1().multMatrix(angle::Mat4::Frustum(l, r, b, t, n, f));
174 }
175 
frustumx(GLfixed l,GLfixed r,GLfixed b,GLfixed t,GLfixed n,GLfixed f)176 void Context::frustumx(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
177 {
178     mState.gles1().multMatrix(angle::Mat4::Frustum(ConvertFixedToFloat(l), ConvertFixedToFloat(r),
179                                                    ConvertFixedToFloat(b), ConvertFixedToFloat(t),
180                                                    ConvertFixedToFloat(n), ConvertFixedToFloat(f)));
181 }
182 
getClipPlanef(GLenum plane,GLfloat * equation)183 void Context::getClipPlanef(GLenum plane, GLfloat *equation)
184 {
185     mState.gles1().getClipPlane(plane - GL_CLIP_PLANE0, equation);
186 }
187 
getClipPlanex(GLenum plane,GLfixed * equation)188 void Context::getClipPlanex(GLenum plane, GLfixed *equation)
189 {
190     GLfloat equationf[4] = {};
191 
192     mState.gles1().getClipPlane(plane - GL_CLIP_PLANE0, equationf);
193 
194     for (int i = 0; i < 4; i++)
195     {
196         equation[i] = ConvertFloatToFixed(equationf[i]);
197     }
198 }
199 
getFixedv(GLenum pname,GLfixed * params)200 void Context::getFixedv(GLenum pname, GLfixed *params)
201 {
202     GLenum nativeType;
203     unsigned int numParams = 0;
204 
205     getQueryParameterInfo(pname, &nativeType, &numParams);
206 
207     std::vector<GLfloat> paramsf(numParams, 0);
208     CastStateValues(this, nativeType, pname, numParams, paramsf.data());
209 
210     for (unsigned int i = 0; i < numParams; i++)
211     {
212         params[i] = ConvertFloatToFixed(paramsf[i]);
213     }
214 }
215 
getLightfv(GLenum light,LightParameter pname,GLfloat * params)216 void Context::getLightfv(GLenum light, LightParameter pname, GLfloat *params)
217 {
218     GetLightParameters(&mState.gles1(), light, pname, params);
219 }
220 
getLightxv(GLenum light,LightParameter pname,GLfixed * params)221 void Context::getLightxv(GLenum light, LightParameter pname, GLfixed *params)
222 {
223     GLfloat paramsf[4];
224     getLightfv(light, pname, paramsf);
225 
226     for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
227     {
228         params[i] = ConvertFloatToFixed(paramsf[i]);
229     }
230 }
231 
getMaterialfv(GLenum face,MaterialParameter pname,GLfloat * params)232 void Context::getMaterialfv(GLenum face, MaterialParameter pname, GLfloat *params)
233 {
234     GetMaterialParameters(&mState.gles1(), face, pname, params);
235 }
236 
getMaterialxv(GLenum face,MaterialParameter pname,GLfixed * params)237 void Context::getMaterialxv(GLenum face, MaterialParameter pname, GLfixed *params)
238 {
239     GLfloat paramsf[4];
240     getMaterialfv(face, pname, paramsf);
241 
242     for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
243     {
244         params[i] = ConvertFloatToFixed(paramsf[i]);
245     }
246 }
247 
getTexEnvfv(TextureEnvTarget target,TextureEnvParameter pname,GLfloat * params)248 void Context::getTexEnvfv(TextureEnvTarget target, TextureEnvParameter pname, GLfloat *params)
249 {
250     GetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, params);
251 }
252 
getTexEnviv(TextureEnvTarget target,TextureEnvParameter pname,GLint * params)253 void Context::getTexEnviv(TextureEnvTarget target, TextureEnvParameter pname, GLint *params)
254 {
255     GLfloat paramsf[4];
256     GetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
257     ConvertTextureEnvToInt(pname, paramsf, params);
258 }
259 
getTexEnvxv(TextureEnvTarget target,TextureEnvParameter pname,GLfixed * params)260 void Context::getTexEnvxv(TextureEnvTarget target, TextureEnvParameter pname, GLfixed *params)
261 {
262     GLfloat paramsf[4];
263     GetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
264     ConvertTextureEnvToFixed(pname, paramsf, params);
265 }
266 
getTexParameterxv(TextureType target,GLenum pname,GLfixed * params)267 void Context::getTexParameterxv(TextureType target, GLenum pname, GLfixed *params)
268 {
269     const Texture *const texture = getTextureByType(target);
270     QueryTexParameterxv(this, texture, pname, params);
271 }
272 
lightModelf(GLenum pname,GLfloat param)273 void Context::lightModelf(GLenum pname, GLfloat param)
274 {
275     SetLightModelParameters(&mState.gles1(), pname, &param);
276 }
277 
lightModelfv(GLenum pname,const GLfloat * params)278 void Context::lightModelfv(GLenum pname, const GLfloat *params)
279 {
280     SetLightModelParameters(&mState.gles1(), pname, params);
281 }
282 
lightModelx(GLenum pname,GLfixed param)283 void Context::lightModelx(GLenum pname, GLfixed param)
284 {
285     lightModelf(pname, ConvertFixedToFloat(param));
286 }
287 
lightModelxv(GLenum pname,const GLfixed * param)288 void Context::lightModelxv(GLenum pname, const GLfixed *param)
289 {
290     GLfloat paramsf[4];
291 
292     for (unsigned int i = 0; i < GetLightModelParameterCount(pname); i++)
293     {
294         paramsf[i] = ConvertFixedToFloat(param[i]);
295     }
296 
297     lightModelfv(pname, paramsf);
298 }
299 
lightf(GLenum light,LightParameter pname,GLfloat param)300 void Context::lightf(GLenum light, LightParameter pname, GLfloat param)
301 {
302     SetLightParameters(&mState.gles1(), light, pname, &param);
303 }
304 
lightfv(GLenum light,LightParameter pname,const GLfloat * params)305 void Context::lightfv(GLenum light, LightParameter pname, const GLfloat *params)
306 {
307     SetLightParameters(&mState.gles1(), light, pname, params);
308 }
309 
lightx(GLenum light,LightParameter pname,GLfixed param)310 void Context::lightx(GLenum light, LightParameter pname, GLfixed param)
311 {
312     lightf(light, pname, ConvertFixedToFloat(param));
313 }
314 
lightxv(GLenum light,LightParameter pname,const GLfixed * params)315 void Context::lightxv(GLenum light, LightParameter pname, const GLfixed *params)
316 {
317     GLfloat paramsf[4];
318 
319     for (unsigned int i = 0; i < GetLightParameterCount(pname); i++)
320     {
321         paramsf[i] = ConvertFixedToFloat(params[i]);
322     }
323 
324     lightfv(light, pname, paramsf);
325 }
326 
lineWidthx(GLfixed width)327 void Context::lineWidthx(GLfixed width)
328 {
329     mState.setLineWidth(ConvertFixedToFloat(width));
330 }
331 
loadIdentity()332 void Context::loadIdentity()
333 {
334     mState.gles1().loadMatrix(angle::Mat4());
335 }
336 
loadMatrixf(const GLfloat * m)337 void Context::loadMatrixf(const GLfloat *m)
338 {
339     mState.gles1().loadMatrix(angle::Mat4(m));
340 }
341 
loadMatrixx(const GLfixed * m)342 void Context::loadMatrixx(const GLfixed *m)
343 {
344     mState.gles1().loadMatrix(FixedMatrixToMat4(m));
345 }
346 
logicOp(LogicalOperation opcodePacked)347 void Context::logicOp(LogicalOperation opcodePacked)
348 {
349     mState.gles1().setLogicOp(opcodePacked);
350 }
351 
materialf(GLenum face,MaterialParameter pname,GLfloat param)352 void Context::materialf(GLenum face, MaterialParameter pname, GLfloat param)
353 {
354     SetMaterialParameters(&mState.gles1(), face, pname, &param);
355 }
356 
materialfv(GLenum face,MaterialParameter pname,const GLfloat * params)357 void Context::materialfv(GLenum face, MaterialParameter pname, const GLfloat *params)
358 {
359     SetMaterialParameters(&mState.gles1(), face, pname, params);
360 }
361 
materialx(GLenum face,MaterialParameter pname,GLfixed param)362 void Context::materialx(GLenum face, MaterialParameter pname, GLfixed param)
363 {
364     materialf(face, pname, ConvertFixedToFloat(param));
365 }
366 
materialxv(GLenum face,MaterialParameter pname,const GLfixed * param)367 void Context::materialxv(GLenum face, MaterialParameter pname, const GLfixed *param)
368 {
369     GLfloat paramsf[4];
370 
371     for (unsigned int i = 0; i < GetMaterialParameterCount(pname); i++)
372     {
373         paramsf[i] = ConvertFixedToFloat(param[i]);
374     }
375 
376     materialfv(face, pname, paramsf);
377 }
378 
matrixMode(MatrixType mode)379 void Context::matrixMode(MatrixType mode)
380 {
381     mState.gles1().setMatrixMode(mode);
382 }
383 
multMatrixf(const GLfloat * m)384 void Context::multMatrixf(const GLfloat *m)
385 {
386     mState.gles1().multMatrix(angle::Mat4(m));
387 }
388 
multMatrixx(const GLfixed * m)389 void Context::multMatrixx(const GLfixed *m)
390 {
391     mState.gles1().multMatrix(FixedMatrixToMat4(m));
392 }
393 
multiTexCoord4f(GLenum target,GLfloat s,GLfloat t,GLfloat r,GLfloat q)394 void Context::multiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
395 {
396     unsigned int unit = target - GL_TEXTURE0;
397     ASSERT(target >= GL_TEXTURE0 && unit < getCaps().maxMultitextureUnits);
398     mState.gles1().setCurrentTextureCoords(unit, {s, t, r, q});
399 }
400 
multiTexCoord4x(GLenum target,GLfixed s,GLfixed t,GLfixed r,GLfixed q)401 void Context::multiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
402 {
403     unsigned int unit = target - GL_TEXTURE0;
404     ASSERT(target >= GL_TEXTURE0 && unit < getCaps().maxMultitextureUnits);
405     mState.gles1().setCurrentTextureCoords(unit, {ConvertFixedToFloat(s), ConvertFixedToFloat(t),
406                                                   ConvertFixedToFloat(r), ConvertFixedToFloat(q)});
407 }
408 
normal3f(GLfloat nx,GLfloat ny,GLfloat nz)409 void Context::normal3f(GLfloat nx, GLfloat ny, GLfloat nz)
410 {
411     mState.gles1().setCurrentNormal({nx, ny, nz});
412 }
413 
normal3x(GLfixed nx,GLfixed ny,GLfixed nz)414 void Context::normal3x(GLfixed nx, GLfixed ny, GLfixed nz)
415 {
416     mState.gles1().setCurrentNormal(
417         {ConvertFixedToFloat(nx), ConvertFixedToFloat(ny), ConvertFixedToFloat(nz)});
418 }
419 
normalPointer(VertexAttribType type,GLsizei stride,const void * ptr)420 void Context::normalPointer(VertexAttribType type, GLsizei stride, const void *ptr)
421 {
422     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Normal), 3, type, GL_FALSE, stride,
423                         ptr);
424 }
425 
orthof(GLfloat left,GLfloat right,GLfloat bottom,GLfloat top,GLfloat zNear,GLfloat zFar)426 void Context::orthof(GLfloat left,
427                      GLfloat right,
428                      GLfloat bottom,
429                      GLfloat top,
430                      GLfloat zNear,
431                      GLfloat zFar)
432 {
433     mState.gles1().multMatrix(angle::Mat4::Ortho(left, right, bottom, top, zNear, zFar));
434 }
435 
orthox(GLfixed l,GLfixed r,GLfixed b,GLfixed t,GLfixed n,GLfixed f)436 void Context::orthox(GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f)
437 {
438     mState.gles1().multMatrix(angle::Mat4::Ortho(ConvertFixedToFloat(l), ConvertFixedToFloat(r),
439                                                  ConvertFixedToFloat(b), ConvertFixedToFloat(t),
440                                                  ConvertFixedToFloat(n), ConvertFixedToFloat(f)));
441 }
442 
pointParameterf(PointParameter pname,GLfloat param)443 void Context::pointParameterf(PointParameter pname, GLfloat param)
444 {
445     SetPointParameter(&mState.gles1(), pname, &param);
446 }
447 
pointParameterfv(PointParameter pname,const GLfloat * params)448 void Context::pointParameterfv(PointParameter pname, const GLfloat *params)
449 {
450     SetPointParameter(&mState.gles1(), pname, params);
451 }
452 
pointParameterx(PointParameter pname,GLfixed param)453 void Context::pointParameterx(PointParameter pname, GLfixed param)
454 {
455     GLfloat paramf = ConvertFixedToFloat(param);
456     SetPointParameter(&mState.gles1(), pname, &paramf);
457 }
458 
pointParameterxv(PointParameter pname,const GLfixed * params)459 void Context::pointParameterxv(PointParameter pname, const GLfixed *params)
460 {
461     GLfloat paramsf[4] = {};
462     for (unsigned int i = 0; i < GetPointParameterCount(pname); i++)
463     {
464         paramsf[i] = ConvertFixedToFloat(params[i]);
465     }
466     SetPointParameter(&mState.gles1(), pname, paramsf);
467 }
468 
pointSize(GLfloat size)469 void Context::pointSize(GLfloat size)
470 {
471     SetPointSize(&mState.gles1(), size);
472 }
473 
pointSizex(GLfixed size)474 void Context::pointSizex(GLfixed size)
475 {
476     SetPointSize(&mState.gles1(), ConvertFixedToFloat(size));
477 }
478 
polygonOffsetx(GLfixed factor,GLfixed units)479 void Context::polygonOffsetx(GLfixed factor, GLfixed units)
480 {
481     mState.setPolygonOffsetParams(ConvertFixedToFloat(factor), ConvertFixedToFloat(units));
482 }
483 
popMatrix()484 void Context::popMatrix()
485 {
486     mState.gles1().popMatrix();
487 }
488 
pushMatrix()489 void Context::pushMatrix()
490 {
491     mState.gles1().pushMatrix();
492 }
493 
rotatef(float angle,float x,float y,float z)494 void Context::rotatef(float angle, float x, float y, float z)
495 {
496     mState.gles1().multMatrix(angle::Mat4::Rotate(angle, angle::Vector3(x, y, z)));
497 }
498 
rotatex(GLfixed angle,GLfixed x,GLfixed y,GLfixed z)499 void Context::rotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
500 {
501     mState.gles1().multMatrix(angle::Mat4::Rotate(
502         ConvertFixedToFloat(angle),
503         angle::Vector3(ConvertFixedToFloat(x), ConvertFixedToFloat(y), ConvertFixedToFloat(z))));
504 }
505 
sampleCoveragex(GLclampx value,GLboolean invert)506 void Context::sampleCoveragex(GLclampx value, GLboolean invert)
507 {
508     GLclampf valuef = ConvertFixedToFloat(value);
509     mState.setSampleCoverageParams(clamp01(valuef), ConvertToBool(invert));
510 }
511 
scalef(float x,float y,float z)512 void Context::scalef(float x, float y, float z)
513 {
514     mState.gles1().multMatrix(angle::Mat4::Scale(angle::Vector3(x, y, z)));
515 }
516 
scalex(GLfixed x,GLfixed y,GLfixed z)517 void Context::scalex(GLfixed x, GLfixed y, GLfixed z)
518 {
519     mState.gles1().multMatrix(angle::Mat4::Scale(
520         angle::Vector3(ConvertFixedToFloat(x), ConvertFixedToFloat(y), ConvertFixedToFloat(z))));
521 }
522 
shadeModel(ShadingModel model)523 void Context::shadeModel(ShadingModel model)
524 {
525     mState.gles1().setShadeModel(model);
526 }
527 
texCoordPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)528 void Context::texCoordPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
529 {
530     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::TextureCoord), size, type, GL_FALSE,
531                         stride, ptr);
532 }
533 
texEnvf(TextureEnvTarget target,TextureEnvParameter pname,GLfloat param)534 void Context::texEnvf(TextureEnvTarget target, TextureEnvParameter pname, GLfloat param)
535 {
536     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, &param);
537 }
538 
texEnvfv(TextureEnvTarget target,TextureEnvParameter pname,const GLfloat * params)539 void Context::texEnvfv(TextureEnvTarget target, TextureEnvParameter pname, const GLfloat *params)
540 {
541     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, params);
542 }
543 
texEnvi(TextureEnvTarget target,TextureEnvParameter pname,GLint param)544 void Context::texEnvi(TextureEnvTarget target, TextureEnvParameter pname, GLint param)
545 {
546     GLfloat paramsf[4] = {};
547     ConvertTextureEnvFromInt(pname, &param, paramsf);
548     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
549 }
550 
texEnviv(TextureEnvTarget target,TextureEnvParameter pname,const GLint * params)551 void Context::texEnviv(TextureEnvTarget target, TextureEnvParameter pname, const GLint *params)
552 {
553     GLfloat paramsf[4] = {};
554     ConvertTextureEnvFromInt(pname, params, paramsf);
555     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
556 }
557 
texEnvx(TextureEnvTarget target,TextureEnvParameter pname,GLfixed param)558 void Context::texEnvx(TextureEnvTarget target, TextureEnvParameter pname, GLfixed param)
559 {
560     GLfloat paramsf[4] = {};
561     ConvertTextureEnvFromFixed(pname, &param, paramsf);
562     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
563 }
564 
texEnvxv(TextureEnvTarget target,TextureEnvParameter pname,const GLfixed * params)565 void Context::texEnvxv(TextureEnvTarget target, TextureEnvParameter pname, const GLfixed *params)
566 {
567     GLfloat paramsf[4] = {};
568     ConvertTextureEnvFromFixed(pname, params, paramsf);
569     SetTextureEnv(mState.getActiveSampler(), &mState.gles1(), target, pname, paramsf);
570 }
571 
texParameterx(TextureType target,GLenum pname,GLfixed param)572 void Context::texParameterx(TextureType target, GLenum pname, GLfixed param)
573 {
574     Texture *const texture = getTextureByType(target);
575     SetTexParameterx(this, texture, pname, param);
576 }
577 
texParameterxv(TextureType target,GLenum pname,const GLfixed * params)578 void Context::texParameterxv(TextureType target, GLenum pname, const GLfixed *params)
579 {
580     Texture *const texture = getTextureByType(target);
581     SetTexParameterxv(this, texture, pname, params);
582 }
583 
translatef(float x,float y,float z)584 void Context::translatef(float x, float y, float z)
585 {
586     mState.gles1().multMatrix(angle::Mat4::Translate(angle::Vector3(x, y, z)));
587 }
588 
translatex(GLfixed x,GLfixed y,GLfixed z)589 void Context::translatex(GLfixed x, GLfixed y, GLfixed z)
590 {
591     mState.gles1().multMatrix(angle::Mat4::Translate(
592         angle::Vector3(ConvertFixedToFloat(x), ConvertFixedToFloat(y), ConvertFixedToFloat(z))));
593 }
594 
vertexPointer(GLint size,VertexAttribType type,GLsizei stride,const void * ptr)595 void Context::vertexPointer(GLint size, VertexAttribType type, GLsizei stride, const void *ptr)
596 {
597     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::Vertex), size, type, GL_FALSE,
598                         stride, ptr);
599 }
600 
601 // GL_OES_draw_texture
drawTexf(float x,float y,float z,float width,float height)602 void Context::drawTexf(float x, float y, float z, float width, float height)
603 {
604     mGLES1Renderer->drawTexture(this, &mState, x, y, z, width, height);
605 }
606 
drawTexfv(const GLfloat * coords)607 void Context::drawTexfv(const GLfloat *coords)
608 {
609     mGLES1Renderer->drawTexture(this, &mState, coords[0], coords[1], coords[2], coords[3],
610                                 coords[4]);
611 }
612 
drawTexi(GLint x,GLint y,GLint z,GLint width,GLint height)613 void Context::drawTexi(GLint x, GLint y, GLint z, GLint width, GLint height)
614 {
615     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(x), static_cast<GLfloat>(y),
616                                 static_cast<GLfloat>(z), static_cast<GLfloat>(width),
617                                 static_cast<GLfloat>(height));
618 }
619 
drawTexiv(const GLint * coords)620 void Context::drawTexiv(const GLint *coords)
621 {
622     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(coords[0]),
623                                 static_cast<GLfloat>(coords[1]), static_cast<GLfloat>(coords[2]),
624                                 static_cast<GLfloat>(coords[3]), static_cast<GLfloat>(coords[4]));
625 }
626 
drawTexs(GLshort x,GLshort y,GLshort z,GLshort width,GLshort height)627 void Context::drawTexs(GLshort x, GLshort y, GLshort z, GLshort width, GLshort height)
628 {
629     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(x), static_cast<GLfloat>(y),
630                                 static_cast<GLfloat>(z), static_cast<GLfloat>(width),
631                                 static_cast<GLfloat>(height));
632 }
633 
drawTexsv(const GLshort * coords)634 void Context::drawTexsv(const GLshort *coords)
635 {
636     mGLES1Renderer->drawTexture(this, &mState, static_cast<GLfloat>(coords[0]),
637                                 static_cast<GLfloat>(coords[1]), static_cast<GLfloat>(coords[2]),
638                                 static_cast<GLfloat>(coords[3]), static_cast<GLfloat>(coords[4]));
639 }
640 
drawTexx(GLfixed x,GLfixed y,GLfixed z,GLfixed width,GLfixed height)641 void Context::drawTexx(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height)
642 {
643     mGLES1Renderer->drawTexture(this, &mState, ConvertFixedToFloat(x), ConvertFixedToFloat(y),
644                                 ConvertFixedToFloat(z), ConvertFixedToFloat(width),
645                                 ConvertFixedToFloat(height));
646 }
647 
drawTexxv(const GLfixed * coords)648 void Context::drawTexxv(const GLfixed *coords)
649 {
650     mGLES1Renderer->drawTexture(this, &mState, ConvertFixedToFloat(coords[0]),
651                                 ConvertFixedToFloat(coords[1]), ConvertFixedToFloat(coords[2]),
652                                 ConvertFixedToFloat(coords[3]), ConvertFixedToFloat(coords[4]));
653 }
654 
655 // GL_OES_matrix_palette
currentPaletteMatrix(GLuint matrixpaletteindex)656 void Context::currentPaletteMatrix(GLuint matrixpaletteindex)
657 {
658     UNIMPLEMENTED();
659 }
660 
loadPaletteFromModelViewMatrix()661 void Context::loadPaletteFromModelViewMatrix()
662 {
663     UNIMPLEMENTED();
664 }
665 
matrixIndexPointer(GLint size,GLenum type,GLsizei stride,const void * pointer)666 void Context::matrixIndexPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
667 {
668     UNIMPLEMENTED();
669 }
670 
weightPointer(GLint size,GLenum type,GLsizei stride,const void * pointer)671 void Context::weightPointer(GLint size, GLenum type, GLsizei stride, const void *pointer)
672 {
673     UNIMPLEMENTED();
674 }
675 
676 // GL_OES_point_size_array
pointSizePointer(VertexAttribType type,GLsizei stride,const void * ptr)677 void Context::pointSizePointer(VertexAttribType type, GLsizei stride, const void *ptr)
678 {
679     vertexAttribPointer(vertexArrayIndex(ClientVertexArrayType::PointSize), 1, type, GL_FALSE,
680                         stride, ptr);
681 }
682 
683 // GL_OES_query_matrix
queryMatrixx(GLfixed * mantissa,GLint * exponent)684 GLbitfield Context::queryMatrixx(GLfixed *mantissa, GLint *exponent)
685 {
686     UNIMPLEMENTED();
687     return 0;
688 }
689 
690 // GL_OES_texture_cube_map
getTexGenfv(GLenum coord,GLenum pname,GLfloat * params)691 void Context::getTexGenfv(GLenum coord, GLenum pname, GLfloat *params)
692 {
693     UNIMPLEMENTED();
694 }
695 
getTexGeniv(GLenum coord,GLenum pname,GLint * params)696 void Context::getTexGeniv(GLenum coord, GLenum pname, GLint *params)
697 {
698     UNIMPLEMENTED();
699 }
700 
getTexGenxv(GLenum coord,GLenum pname,GLfixed * params)701 void Context::getTexGenxv(GLenum coord, GLenum pname, GLfixed *params)
702 {
703     UNIMPLEMENTED();
704 }
705 
texGenf(GLenum coord,GLenum pname,GLfloat param)706 void Context::texGenf(GLenum coord, GLenum pname, GLfloat param)
707 {
708     UNIMPLEMENTED();
709 }
710 
texGenfv(GLenum coord,GLenum pname,const GLfloat * params)711 void Context::texGenfv(GLenum coord, GLenum pname, const GLfloat *params)
712 {
713     UNIMPLEMENTED();
714 }
715 
texGeni(GLenum coord,GLenum pname,GLint param)716 void Context::texGeni(GLenum coord, GLenum pname, GLint param)
717 {
718     UNIMPLEMENTED();
719 }
720 
texGeniv(GLenum coord,GLenum pname,const GLint * params)721 void Context::texGeniv(GLenum coord, GLenum pname, const GLint *params)
722 {
723     UNIMPLEMENTED();
724 }
725 
texGenx(GLenum coord,GLenum pname,GLfixed param)726 void Context::texGenx(GLenum coord, GLenum pname, GLfixed param)
727 {
728     UNIMPLEMENTED();
729 }
730 
texGenxv(GLenum coord,GLenum pname,const GLint * params)731 void Context::texGenxv(GLenum coord, GLenum pname, const GLint *params)
732 {
733     UNIMPLEMENTED();
734 }
735 
vertexArrayIndex(ClientVertexArrayType type) const736 int Context::vertexArrayIndex(ClientVertexArrayType type) const
737 {
738     return GLES1Renderer::VertexArrayIndex(type, mState.gles1());
739 }
740 
741 // static
TexCoordArrayIndex(unsigned int unit)742 int Context::TexCoordArrayIndex(unsigned int unit)
743 {
744     return GLES1Renderer::TexCoordArrayIndex(unit);
745 }
746 }  // namespace gl
747