xref: /aosp_15_r20/external/angle/src/libANGLE/GLES1State.cpp (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2018 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker 
7*8975f5c5SAndroid Build Coastguard Worker // GLES1State.cpp: Implements the GLES1State class, tracking state
8*8975f5c5SAndroid Build Coastguard Worker // for GLES1 contexts.
9*8975f5c5SAndroid Build Coastguard Worker 
10*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/GLES1State.h"
11*8975f5c5SAndroid Build Coastguard Worker 
12*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/Context.h"
13*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/GLES1Renderer.h"
14*8975f5c5SAndroid Build Coastguard Worker 
15*8975f5c5SAndroid Build Coastguard Worker namespace gl
16*8975f5c5SAndroid Build Coastguard Worker {
17*8975f5c5SAndroid Build Coastguard Worker 
18*8975f5c5SAndroid Build Coastguard Worker TextureCoordF::TextureCoordF() = default;
19*8975f5c5SAndroid Build Coastguard Worker 
TextureCoordF(float _s,float _t,float _r,float _q)20*8975f5c5SAndroid Build Coastguard Worker TextureCoordF::TextureCoordF(float _s, float _t, float _r, float _q) : s(_s), t(_t), r(_r), q(_q) {}
21*8975f5c5SAndroid Build Coastguard Worker 
operator ==(const TextureCoordF & other) const22*8975f5c5SAndroid Build Coastguard Worker bool TextureCoordF::operator==(const TextureCoordF &other) const
23*8975f5c5SAndroid Build Coastguard Worker {
24*8975f5c5SAndroid Build Coastguard Worker     return s == other.s && t == other.t && r == other.r && q == other.q;
25*8975f5c5SAndroid Build Coastguard Worker }
26*8975f5c5SAndroid Build Coastguard Worker 
27*8975f5c5SAndroid Build Coastguard Worker MaterialParameters::MaterialParameters() = default;
28*8975f5c5SAndroid Build Coastguard Worker 
29*8975f5c5SAndroid Build Coastguard Worker LightModelParameters::LightModelParameters() = default;
30*8975f5c5SAndroid Build Coastguard Worker 
31*8975f5c5SAndroid Build Coastguard Worker LightParameters::LightParameters() = default;
32*8975f5c5SAndroid Build Coastguard Worker 
33*8975f5c5SAndroid Build Coastguard Worker LightParameters::LightParameters(const LightParameters &other) = default;
34*8975f5c5SAndroid Build Coastguard Worker 
35*8975f5c5SAndroid Build Coastguard Worker FogParameters::FogParameters() = default;
36*8975f5c5SAndroid Build Coastguard Worker 
37*8975f5c5SAndroid Build Coastguard Worker AlphaTestParameters::AlphaTestParameters() = default;
38*8975f5c5SAndroid Build Coastguard Worker 
operator !=(const AlphaTestParameters & other) const39*8975f5c5SAndroid Build Coastguard Worker bool AlphaTestParameters::operator!=(const AlphaTestParameters &other) const
40*8975f5c5SAndroid Build Coastguard Worker {
41*8975f5c5SAndroid Build Coastguard Worker     return func != other.func || ref != other.ref;
42*8975f5c5SAndroid Build Coastguard Worker }
43*8975f5c5SAndroid Build Coastguard Worker 
44*8975f5c5SAndroid Build Coastguard Worker TextureEnvironmentParameters::TextureEnvironmentParameters() = default;
45*8975f5c5SAndroid Build Coastguard Worker 
46*8975f5c5SAndroid Build Coastguard Worker TextureEnvironmentParameters::TextureEnvironmentParameters(
47*8975f5c5SAndroid Build Coastguard Worker     const TextureEnvironmentParameters &other) = default;
48*8975f5c5SAndroid Build Coastguard Worker 
49*8975f5c5SAndroid Build Coastguard Worker PointParameters::PointParameters() = default;
50*8975f5c5SAndroid Build Coastguard Worker 
51*8975f5c5SAndroid Build Coastguard Worker PointParameters::PointParameters(const PointParameters &other) = default;
52*8975f5c5SAndroid Build Coastguard Worker 
53*8975f5c5SAndroid Build Coastguard Worker ClipPlaneParameters::ClipPlaneParameters() = default;
54*8975f5c5SAndroid Build Coastguard Worker 
ClipPlaneParameters(bool enabled,const angle::Vector4 & equation)55*8975f5c5SAndroid Build Coastguard Worker ClipPlaneParameters::ClipPlaneParameters(bool enabled, const angle::Vector4 &equation)
56*8975f5c5SAndroid Build Coastguard Worker     : enabled(enabled), equation(equation)
57*8975f5c5SAndroid Build Coastguard Worker {}
58*8975f5c5SAndroid Build Coastguard Worker 
59*8975f5c5SAndroid Build Coastguard Worker ClipPlaneParameters::ClipPlaneParameters(const ClipPlaneParameters &other) = default;
60*8975f5c5SAndroid Build Coastguard Worker 
61*8975f5c5SAndroid Build Coastguard Worker ClipPlaneParameters &ClipPlaneParameters::operator=(const ClipPlaneParameters &other) = default;
62*8975f5c5SAndroid Build Coastguard Worker 
GLES1State()63*8975f5c5SAndroid Build Coastguard Worker GLES1State::GLES1State()
64*8975f5c5SAndroid Build Coastguard Worker     : mGLState(nullptr),
65*8975f5c5SAndroid Build Coastguard Worker       mVertexArrayEnabled(false),
66*8975f5c5SAndroid Build Coastguard Worker       mNormalArrayEnabled(false),
67*8975f5c5SAndroid Build Coastguard Worker       mColorArrayEnabled(false),
68*8975f5c5SAndroid Build Coastguard Worker       mPointSizeArrayEnabled(false),
69*8975f5c5SAndroid Build Coastguard Worker       mLineSmoothEnabled(false),
70*8975f5c5SAndroid Build Coastguard Worker       mPointSmoothEnabled(false),
71*8975f5c5SAndroid Build Coastguard Worker       mPointSpriteEnabled(false),
72*8975f5c5SAndroid Build Coastguard Worker       mAlphaTestEnabled(false),
73*8975f5c5SAndroid Build Coastguard Worker       mLogicOpEnabled(false),
74*8975f5c5SAndroid Build Coastguard Worker       mLightingEnabled(false),
75*8975f5c5SAndroid Build Coastguard Worker       mFogEnabled(false),
76*8975f5c5SAndroid Build Coastguard Worker       mRescaleNormalEnabled(false),
77*8975f5c5SAndroid Build Coastguard Worker       mNormalizeEnabled(false),
78*8975f5c5SAndroid Build Coastguard Worker       mColorMaterialEnabled(false),
79*8975f5c5SAndroid Build Coastguard Worker       mReflectionMapEnabled(false),
80*8975f5c5SAndroid Build Coastguard Worker       mCurrentColor({0.0f, 0.0f, 0.0f, 0.0f}),
81*8975f5c5SAndroid Build Coastguard Worker       mCurrentNormal({0.0f, 0.0f, 0.0f}),
82*8975f5c5SAndroid Build Coastguard Worker       mClientActiveTexture(0),
83*8975f5c5SAndroid Build Coastguard Worker       mMatrixMode(MatrixType::Modelview),
84*8975f5c5SAndroid Build Coastguard Worker       mShadeModel(ShadingModel::Smooth),
85*8975f5c5SAndroid Build Coastguard Worker       mLogicOp(LogicalOperation::Copy),
86*8975f5c5SAndroid Build Coastguard Worker       mLineSmoothHint(HintSetting::DontCare),
87*8975f5c5SAndroid Build Coastguard Worker       mPointSmoothHint(HintSetting::DontCare),
88*8975f5c5SAndroid Build Coastguard Worker       mPerspectiveCorrectionHint(HintSetting::DontCare),
89*8975f5c5SAndroid Build Coastguard Worker       mFogHint(HintSetting::DontCare)
90*8975f5c5SAndroid Build Coastguard Worker {}
91*8975f5c5SAndroid Build Coastguard Worker 
92*8975f5c5SAndroid Build Coastguard Worker GLES1State::~GLES1State() = default;
93*8975f5c5SAndroid Build Coastguard Worker 
94*8975f5c5SAndroid Build Coastguard Worker // Taken from the GLES 1.x spec which specifies all initial state values.
initialize(const Context * context,const PrivateState * state)95*8975f5c5SAndroid Build Coastguard Worker void GLES1State::initialize(const Context *context, const PrivateState *state)
96*8975f5c5SAndroid Build Coastguard Worker {
97*8975f5c5SAndroid Build Coastguard Worker     mGLState = state;
98*8975f5c5SAndroid Build Coastguard Worker 
99*8975f5c5SAndroid Build Coastguard Worker     const Caps &caps = context->getCaps();
100*8975f5c5SAndroid Build Coastguard Worker 
101*8975f5c5SAndroid Build Coastguard Worker     mTexUnitEnables.resize(caps.maxMultitextureUnits);
102*8975f5c5SAndroid Build Coastguard Worker     for (auto &enables : mTexUnitEnables)
103*8975f5c5SAndroid Build Coastguard Worker     {
104*8975f5c5SAndroid Build Coastguard Worker         enables.reset();
105*8975f5c5SAndroid Build Coastguard Worker     }
106*8975f5c5SAndroid Build Coastguard Worker 
107*8975f5c5SAndroid Build Coastguard Worker     mVertexArrayEnabled    = false;
108*8975f5c5SAndroid Build Coastguard Worker     mNormalArrayEnabled    = false;
109*8975f5c5SAndroid Build Coastguard Worker     mColorArrayEnabled     = false;
110*8975f5c5SAndroid Build Coastguard Worker     mPointSizeArrayEnabled = false;
111*8975f5c5SAndroid Build Coastguard Worker     mTexCoordArrayEnabled.resize(caps.maxMultitextureUnits, false);
112*8975f5c5SAndroid Build Coastguard Worker 
113*8975f5c5SAndroid Build Coastguard Worker     mLineSmoothEnabled    = false;
114*8975f5c5SAndroid Build Coastguard Worker     mPointSmoothEnabled   = false;
115*8975f5c5SAndroid Build Coastguard Worker     mPointSpriteEnabled   = false;
116*8975f5c5SAndroid Build Coastguard Worker     mLogicOpEnabled       = false;
117*8975f5c5SAndroid Build Coastguard Worker     mAlphaTestEnabled     = false;
118*8975f5c5SAndroid Build Coastguard Worker     mLightingEnabled      = false;
119*8975f5c5SAndroid Build Coastguard Worker     mFogEnabled           = false;
120*8975f5c5SAndroid Build Coastguard Worker     mRescaleNormalEnabled = false;
121*8975f5c5SAndroid Build Coastguard Worker     mNormalizeEnabled     = false;
122*8975f5c5SAndroid Build Coastguard Worker     mColorMaterialEnabled = false;
123*8975f5c5SAndroid Build Coastguard Worker     mReflectionMapEnabled = false;
124*8975f5c5SAndroid Build Coastguard Worker 
125*8975f5c5SAndroid Build Coastguard Worker     mMatrixMode = MatrixType::Modelview;
126*8975f5c5SAndroid Build Coastguard Worker 
127*8975f5c5SAndroid Build Coastguard Worker     mCurrentColor  = {1.0f, 1.0f, 1.0f, 1.0f};
128*8975f5c5SAndroid Build Coastguard Worker     mCurrentNormal = {0.0f, 0.0f, 1.0f};
129*8975f5c5SAndroid Build Coastguard Worker     mCurrentTextureCoords.resize(caps.maxMultitextureUnits);
130*8975f5c5SAndroid Build Coastguard Worker     mClientActiveTexture = 0;
131*8975f5c5SAndroid Build Coastguard Worker 
132*8975f5c5SAndroid Build Coastguard Worker     mTextureEnvironments.resize(caps.maxMultitextureUnits);
133*8975f5c5SAndroid Build Coastguard Worker 
134*8975f5c5SAndroid Build Coastguard Worker     mModelviewMatrices.push_back(angle::Mat4());
135*8975f5c5SAndroid Build Coastguard Worker     mProjectionMatrices.push_back(angle::Mat4());
136*8975f5c5SAndroid Build Coastguard Worker     mTextureMatrices.resize(caps.maxMultitextureUnits);
137*8975f5c5SAndroid Build Coastguard Worker     for (auto &stack : mTextureMatrices)
138*8975f5c5SAndroid Build Coastguard Worker     {
139*8975f5c5SAndroid Build Coastguard Worker         stack.push_back(angle::Mat4());
140*8975f5c5SAndroid Build Coastguard Worker     }
141*8975f5c5SAndroid Build Coastguard Worker 
142*8975f5c5SAndroid Build Coastguard Worker     mMaterial.ambient  = {0.2f, 0.2f, 0.2f, 1.0f};
143*8975f5c5SAndroid Build Coastguard Worker     mMaterial.diffuse  = {0.8f, 0.8f, 0.8f, 1.0f};
144*8975f5c5SAndroid Build Coastguard Worker     mMaterial.specular = {0.0f, 0.0f, 0.0f, 1.0f};
145*8975f5c5SAndroid Build Coastguard Worker     mMaterial.emissive = {0.0f, 0.0f, 0.0f, 1.0f};
146*8975f5c5SAndroid Build Coastguard Worker 
147*8975f5c5SAndroid Build Coastguard Worker     mMaterial.specularExponent = 0.0f;
148*8975f5c5SAndroid Build Coastguard Worker 
149*8975f5c5SAndroid Build Coastguard Worker     mLightModel.color    = {0.2f, 0.2f, 0.2f, 1.0f};
150*8975f5c5SAndroid Build Coastguard Worker     mLightModel.twoSided = false;
151*8975f5c5SAndroid Build Coastguard Worker 
152*8975f5c5SAndroid Build Coastguard Worker     mLights.resize(caps.maxLights);
153*8975f5c5SAndroid Build Coastguard Worker 
154*8975f5c5SAndroid Build Coastguard Worker     // GL_LIGHT0 is special and has default state that avoids all-black renderings.
155*8975f5c5SAndroid Build Coastguard Worker     mLights[0].diffuse  = {1.0f, 1.0f, 1.0f, 1.0f};
156*8975f5c5SAndroid Build Coastguard Worker     mLights[0].specular = {1.0f, 1.0f, 1.0f, 1.0f};
157*8975f5c5SAndroid Build Coastguard Worker 
158*8975f5c5SAndroid Build Coastguard Worker     mFog.mode    = FogMode::Exp;
159*8975f5c5SAndroid Build Coastguard Worker     mFog.density = 1.0f;
160*8975f5c5SAndroid Build Coastguard Worker     mFog.start   = 0.0f;
161*8975f5c5SAndroid Build Coastguard Worker     mFog.end     = 1.0f;
162*8975f5c5SAndroid Build Coastguard Worker 
163*8975f5c5SAndroid Build Coastguard Worker     mFog.color = {0.0f, 0.0f, 0.0f, 0.0f};
164*8975f5c5SAndroid Build Coastguard Worker 
165*8975f5c5SAndroid Build Coastguard Worker     mShadeModel = ShadingModel::Smooth;
166*8975f5c5SAndroid Build Coastguard Worker 
167*8975f5c5SAndroid Build Coastguard Worker     mAlphaTestParameters.func = AlphaTestFunc::AlwaysPass;
168*8975f5c5SAndroid Build Coastguard Worker     mAlphaTestParameters.ref  = 0.0f;
169*8975f5c5SAndroid Build Coastguard Worker 
170*8975f5c5SAndroid Build Coastguard Worker     mLogicOp = LogicalOperation::Copy;
171*8975f5c5SAndroid Build Coastguard Worker 
172*8975f5c5SAndroid Build Coastguard Worker     mClipPlanes.resize(caps.maxClipPlanes,
173*8975f5c5SAndroid Build Coastguard Worker                        ClipPlaneParameters(false, angle::Vector4(0.0f, 0.0f, 0.0f, 0.0f)));
174*8975f5c5SAndroid Build Coastguard Worker 
175*8975f5c5SAndroid Build Coastguard Worker     mLineSmoothHint            = HintSetting::DontCare;
176*8975f5c5SAndroid Build Coastguard Worker     mPointSmoothHint           = HintSetting::DontCare;
177*8975f5c5SAndroid Build Coastguard Worker     mPerspectiveCorrectionHint = HintSetting::DontCare;
178*8975f5c5SAndroid Build Coastguard Worker     mFogHint                   = HintSetting::DontCare;
179*8975f5c5SAndroid Build Coastguard Worker 
180*8975f5c5SAndroid Build Coastguard Worker     // The user-specified point size, GL_POINT_SIZE_MAX,
181*8975f5c5SAndroid Build Coastguard Worker     // is initially equal to the implementation maximum.
182*8975f5c5SAndroid Build Coastguard Worker     mPointParameters.pointSizeMax = caps.maxAliasedPointSize;
183*8975f5c5SAndroid Build Coastguard Worker 
184*8975f5c5SAndroid Build Coastguard Worker     mDirtyBits.set();
185*8975f5c5SAndroid Build Coastguard Worker }
186*8975f5c5SAndroid Build Coastguard Worker 
setAlphaTestParameters(AlphaTestFunc func,GLfloat ref)187*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setAlphaTestParameters(AlphaTestFunc func, GLfloat ref)
188*8975f5c5SAndroid Build Coastguard Worker {
189*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_ALPHA_TEST);
190*8975f5c5SAndroid Build Coastguard Worker     mAlphaTestParameters.func = func;
191*8975f5c5SAndroid Build Coastguard Worker     mAlphaTestParameters.ref  = ref;
192*8975f5c5SAndroid Build Coastguard Worker }
193*8975f5c5SAndroid Build Coastguard Worker 
setClientTextureUnit(unsigned int unit)194*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setClientTextureUnit(unsigned int unit)
195*8975f5c5SAndroid Build Coastguard Worker {
196*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_CLIENT_ACTIVE_TEXTURE);
197*8975f5c5SAndroid Build Coastguard Worker     mClientActiveTexture = unit;
198*8975f5c5SAndroid Build Coastguard Worker }
199*8975f5c5SAndroid Build Coastguard Worker 
getClientTextureUnit() const200*8975f5c5SAndroid Build Coastguard Worker unsigned int GLES1State::getClientTextureUnit() const
201*8975f5c5SAndroid Build Coastguard Worker {
202*8975f5c5SAndroid Build Coastguard Worker     return mClientActiveTexture;
203*8975f5c5SAndroid Build Coastguard Worker }
204*8975f5c5SAndroid Build Coastguard Worker 
setCurrentColor(const ColorF & color)205*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setCurrentColor(const ColorF &color)
206*8975f5c5SAndroid Build Coastguard Worker {
207*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_CURRENT_VECTOR);
208*8975f5c5SAndroid Build Coastguard Worker     mCurrentColor = color;
209*8975f5c5SAndroid Build Coastguard Worker 
210*8975f5c5SAndroid Build Coastguard Worker     // > When enabled, both the ambient (acm) and diffuse (dcm) properties of both the front and
211*8975f5c5SAndroid Build Coastguard Worker     // > back material are immediately set to the value of the current color, and will track changes
212*8975f5c5SAndroid Build Coastguard Worker     // > to the current color resulting from either the Color commands or drawing vertex arrays with
213*8975f5c5SAndroid Build Coastguard Worker     // > the color array enabled.
214*8975f5c5SAndroid Build Coastguard Worker     // > The replacements made to material properties are permanent; the replaced values remain
215*8975f5c5SAndroid Build Coastguard Worker     // > until changed by either sending a new color or by setting a new material value when
216*8975f5c5SAndroid Build Coastguard Worker     // > COLOR_MATERIAL is not currently enabled, to override that particular value.
217*8975f5c5SAndroid Build Coastguard Worker     if (isColorMaterialEnabled())
218*8975f5c5SAndroid Build Coastguard Worker     {
219*8975f5c5SAndroid Build Coastguard Worker         mMaterial.ambient = color;
220*8975f5c5SAndroid Build Coastguard Worker         mMaterial.diffuse = color;
221*8975f5c5SAndroid Build Coastguard Worker     }
222*8975f5c5SAndroid Build Coastguard Worker }
223*8975f5c5SAndroid Build Coastguard Worker 
getCurrentColor() const224*8975f5c5SAndroid Build Coastguard Worker const ColorF &GLES1State::getCurrentColor() const
225*8975f5c5SAndroid Build Coastguard Worker {
226*8975f5c5SAndroid Build Coastguard Worker     return mCurrentColor;
227*8975f5c5SAndroid Build Coastguard Worker }
228*8975f5c5SAndroid Build Coastguard Worker 
setCurrentNormal(const angle::Vector3 & normal)229*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setCurrentNormal(const angle::Vector3 &normal)
230*8975f5c5SAndroid Build Coastguard Worker {
231*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_CURRENT_VECTOR);
232*8975f5c5SAndroid Build Coastguard Worker     mCurrentNormal = normal;
233*8975f5c5SAndroid Build Coastguard Worker }
234*8975f5c5SAndroid Build Coastguard Worker 
getCurrentNormal() const235*8975f5c5SAndroid Build Coastguard Worker const angle::Vector3 &GLES1State::getCurrentNormal() const
236*8975f5c5SAndroid Build Coastguard Worker {
237*8975f5c5SAndroid Build Coastguard Worker     return mCurrentNormal;
238*8975f5c5SAndroid Build Coastguard Worker }
239*8975f5c5SAndroid Build Coastguard Worker 
shouldHandleDirtyProgram()240*8975f5c5SAndroid Build Coastguard Worker bool GLES1State::shouldHandleDirtyProgram()
241*8975f5c5SAndroid Build Coastguard Worker {
242*8975f5c5SAndroid Build Coastguard Worker     bool ret = isDirty(DIRTY_GLES1_PROGRAM);
243*8975f5c5SAndroid Build Coastguard Worker     clearDirtyBits(DIRTY_GLES1_PROGRAM);
244*8975f5c5SAndroid Build Coastguard Worker     return ret;
245*8975f5c5SAndroid Build Coastguard Worker }
246*8975f5c5SAndroid Build Coastguard Worker 
setCurrentTextureCoords(unsigned int unit,const TextureCoordF & coords)247*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setCurrentTextureCoords(unsigned int unit, const TextureCoordF &coords)
248*8975f5c5SAndroid Build Coastguard Worker {
249*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_CURRENT_VECTOR);
250*8975f5c5SAndroid Build Coastguard Worker     mCurrentTextureCoords[unit] = coords;
251*8975f5c5SAndroid Build Coastguard Worker }
252*8975f5c5SAndroid Build Coastguard Worker 
getCurrentTextureCoords(unsigned int unit) const253*8975f5c5SAndroid Build Coastguard Worker const TextureCoordF &GLES1State::getCurrentTextureCoords(unsigned int unit) const
254*8975f5c5SAndroid Build Coastguard Worker {
255*8975f5c5SAndroid Build Coastguard Worker     return mCurrentTextureCoords[unit];
256*8975f5c5SAndroid Build Coastguard Worker }
257*8975f5c5SAndroid Build Coastguard Worker 
setMatrixMode(MatrixType mode)258*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setMatrixMode(MatrixType mode)
259*8975f5c5SAndroid Build Coastguard Worker {
260*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_MATRICES);
261*8975f5c5SAndroid Build Coastguard Worker     mMatrixMode = mode;
262*8975f5c5SAndroid Build Coastguard Worker }
263*8975f5c5SAndroid Build Coastguard Worker 
getMatrixMode() const264*8975f5c5SAndroid Build Coastguard Worker MatrixType GLES1State::getMatrixMode() const
265*8975f5c5SAndroid Build Coastguard Worker {
266*8975f5c5SAndroid Build Coastguard Worker     return mMatrixMode;
267*8975f5c5SAndroid Build Coastguard Worker }
268*8975f5c5SAndroid Build Coastguard Worker 
getCurrentMatrixStackDepth(GLenum queryType) const269*8975f5c5SAndroid Build Coastguard Worker GLint GLES1State::getCurrentMatrixStackDepth(GLenum queryType) const
270*8975f5c5SAndroid Build Coastguard Worker {
271*8975f5c5SAndroid Build Coastguard Worker     switch (queryType)
272*8975f5c5SAndroid Build Coastguard Worker     {
273*8975f5c5SAndroid Build Coastguard Worker         case GL_MODELVIEW_STACK_DEPTH:
274*8975f5c5SAndroid Build Coastguard Worker             return clampCast<GLint>(mModelviewMatrices.size());
275*8975f5c5SAndroid Build Coastguard Worker         case GL_PROJECTION_STACK_DEPTH:
276*8975f5c5SAndroid Build Coastguard Worker             return clampCast<GLint>(mProjectionMatrices.size());
277*8975f5c5SAndroid Build Coastguard Worker         case GL_TEXTURE_STACK_DEPTH:
278*8975f5c5SAndroid Build Coastguard Worker             return clampCast<GLint>(mTextureMatrices[mGLState->getActiveSampler()].size());
279*8975f5c5SAndroid Build Coastguard Worker         default:
280*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
281*8975f5c5SAndroid Build Coastguard Worker             return 0;
282*8975f5c5SAndroid Build Coastguard Worker     }
283*8975f5c5SAndroid Build Coastguard Worker }
284*8975f5c5SAndroid Build Coastguard Worker 
pushMatrix()285*8975f5c5SAndroid Build Coastguard Worker void GLES1State::pushMatrix()
286*8975f5c5SAndroid Build Coastguard Worker {
287*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_MATRICES);
288*8975f5c5SAndroid Build Coastguard Worker     auto &stack = currentMatrixStack();
289*8975f5c5SAndroid Build Coastguard Worker     stack.push_back(stack.back());
290*8975f5c5SAndroid Build Coastguard Worker }
291*8975f5c5SAndroid Build Coastguard Worker 
popMatrix()292*8975f5c5SAndroid Build Coastguard Worker void GLES1State::popMatrix()
293*8975f5c5SAndroid Build Coastguard Worker {
294*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_MATRICES);
295*8975f5c5SAndroid Build Coastguard Worker     auto &stack = currentMatrixStack();
296*8975f5c5SAndroid Build Coastguard Worker     stack.pop_back();
297*8975f5c5SAndroid Build Coastguard Worker }
298*8975f5c5SAndroid Build Coastguard Worker 
currentMatrixStack()299*8975f5c5SAndroid Build Coastguard Worker GLES1State::MatrixStack &GLES1State::currentMatrixStack()
300*8975f5c5SAndroid Build Coastguard Worker {
301*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_MATRICES);
302*8975f5c5SAndroid Build Coastguard Worker     switch (mMatrixMode)
303*8975f5c5SAndroid Build Coastguard Worker     {
304*8975f5c5SAndroid Build Coastguard Worker         case MatrixType::Modelview:
305*8975f5c5SAndroid Build Coastguard Worker             return mModelviewMatrices;
306*8975f5c5SAndroid Build Coastguard Worker         case MatrixType::Projection:
307*8975f5c5SAndroid Build Coastguard Worker             return mProjectionMatrices;
308*8975f5c5SAndroid Build Coastguard Worker         case MatrixType::Texture:
309*8975f5c5SAndroid Build Coastguard Worker             return mTextureMatrices[mGLState->getActiveSampler()];
310*8975f5c5SAndroid Build Coastguard Worker         default:
311*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
312*8975f5c5SAndroid Build Coastguard Worker             return mModelviewMatrices;
313*8975f5c5SAndroid Build Coastguard Worker     }
314*8975f5c5SAndroid Build Coastguard Worker }
315*8975f5c5SAndroid Build Coastguard Worker 
getModelviewMatrix() const316*8975f5c5SAndroid Build Coastguard Worker const angle::Mat4 &GLES1State::getModelviewMatrix() const
317*8975f5c5SAndroid Build Coastguard Worker {
318*8975f5c5SAndroid Build Coastguard Worker     return mModelviewMatrices.back();
319*8975f5c5SAndroid Build Coastguard Worker }
320*8975f5c5SAndroid Build Coastguard Worker 
getMatrixStack(MatrixType mode) const321*8975f5c5SAndroid Build Coastguard Worker const GLES1State::MatrixStack &GLES1State::getMatrixStack(MatrixType mode) const
322*8975f5c5SAndroid Build Coastguard Worker {
323*8975f5c5SAndroid Build Coastguard Worker     switch (mode)
324*8975f5c5SAndroid Build Coastguard Worker     {
325*8975f5c5SAndroid Build Coastguard Worker         case MatrixType::Modelview:
326*8975f5c5SAndroid Build Coastguard Worker             return mModelviewMatrices;
327*8975f5c5SAndroid Build Coastguard Worker         case MatrixType::Projection:
328*8975f5c5SAndroid Build Coastguard Worker             return mProjectionMatrices;
329*8975f5c5SAndroid Build Coastguard Worker         case MatrixType::Texture:
330*8975f5c5SAndroid Build Coastguard Worker             return mTextureMatrices[mGLState->getActiveSampler()];
331*8975f5c5SAndroid Build Coastguard Worker         default:
332*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
333*8975f5c5SAndroid Build Coastguard Worker             return mModelviewMatrices;
334*8975f5c5SAndroid Build Coastguard Worker     }
335*8975f5c5SAndroid Build Coastguard Worker }
336*8975f5c5SAndroid Build Coastguard Worker 
currentMatrixStack() const337*8975f5c5SAndroid Build Coastguard Worker const GLES1State::MatrixStack &GLES1State::currentMatrixStack() const
338*8975f5c5SAndroid Build Coastguard Worker {
339*8975f5c5SAndroid Build Coastguard Worker     return getMatrixStack(mMatrixMode);
340*8975f5c5SAndroid Build Coastguard Worker }
341*8975f5c5SAndroid Build Coastguard Worker 
loadMatrix(const angle::Mat4 & m)342*8975f5c5SAndroid Build Coastguard Worker void GLES1State::loadMatrix(const angle::Mat4 &m)
343*8975f5c5SAndroid Build Coastguard Worker {
344*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_MATRICES);
345*8975f5c5SAndroid Build Coastguard Worker     currentMatrixStack().back() = m;
346*8975f5c5SAndroid Build Coastguard Worker }
347*8975f5c5SAndroid Build Coastguard Worker 
multMatrix(const angle::Mat4 & m)348*8975f5c5SAndroid Build Coastguard Worker void GLES1State::multMatrix(const angle::Mat4 &m)
349*8975f5c5SAndroid Build Coastguard Worker {
350*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_MATRICES);
351*8975f5c5SAndroid Build Coastguard Worker     angle::Mat4 currentMatrix   = currentMatrixStack().back();
352*8975f5c5SAndroid Build Coastguard Worker     currentMatrixStack().back() = currentMatrix.product(m);
353*8975f5c5SAndroid Build Coastguard Worker }
354*8975f5c5SAndroid Build Coastguard Worker 
setTextureEnabled(GLint activeSampler,TextureType type,bool enabled)355*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setTextureEnabled(GLint activeSampler, TextureType type, bool enabled)
356*8975f5c5SAndroid Build Coastguard Worker {
357*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_TEXTURE_UNIT_ENABLE);
358*8975f5c5SAndroid Build Coastguard Worker     mTexUnitEnables[activeSampler].set(type, enabled);
359*8975f5c5SAndroid Build Coastguard Worker }
360*8975f5c5SAndroid Build Coastguard Worker 
setLogicOpEnabled(bool enabled)361*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setLogicOpEnabled(bool enabled)
362*8975f5c5SAndroid Build Coastguard Worker {
363*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_LOGIC_OP);
364*8975f5c5SAndroid Build Coastguard Worker     mLogicOpEnabled = enabled;
365*8975f5c5SAndroid Build Coastguard Worker }
366*8975f5c5SAndroid Build Coastguard Worker 
setLogicOp(LogicalOperation opcodePacked)367*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setLogicOp(LogicalOperation opcodePacked)
368*8975f5c5SAndroid Build Coastguard Worker {
369*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_LOGIC_OP);
370*8975f5c5SAndroid Build Coastguard Worker     mLogicOp = opcodePacked;
371*8975f5c5SAndroid Build Coastguard Worker }
372*8975f5c5SAndroid Build Coastguard Worker 
setClientStateEnabled(ClientVertexArrayType clientState,bool enable)373*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setClientStateEnabled(ClientVertexArrayType clientState, bool enable)
374*8975f5c5SAndroid Build Coastguard Worker {
375*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_CLIENT_STATE_ENABLE);
376*8975f5c5SAndroid Build Coastguard Worker     switch (clientState)
377*8975f5c5SAndroid Build Coastguard Worker     {
378*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::Vertex:
379*8975f5c5SAndroid Build Coastguard Worker             mVertexArrayEnabled = enable;
380*8975f5c5SAndroid Build Coastguard Worker             break;
381*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::Normal:
382*8975f5c5SAndroid Build Coastguard Worker             mNormalArrayEnabled = enable;
383*8975f5c5SAndroid Build Coastguard Worker             break;
384*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::Color:
385*8975f5c5SAndroid Build Coastguard Worker             mColorArrayEnabled = enable;
386*8975f5c5SAndroid Build Coastguard Worker             break;
387*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::PointSize:
388*8975f5c5SAndroid Build Coastguard Worker             mPointSizeArrayEnabled = enable;
389*8975f5c5SAndroid Build Coastguard Worker             break;
390*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::TextureCoord:
391*8975f5c5SAndroid Build Coastguard Worker             mTexCoordArrayEnabled[mClientActiveTexture] = enable;
392*8975f5c5SAndroid Build Coastguard Worker             break;
393*8975f5c5SAndroid Build Coastguard Worker         default:
394*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
395*8975f5c5SAndroid Build Coastguard Worker             break;
396*8975f5c5SAndroid Build Coastguard Worker     }
397*8975f5c5SAndroid Build Coastguard Worker }
398*8975f5c5SAndroid Build Coastguard Worker 
setTexCoordArrayEnabled(unsigned int unit,bool enable)399*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setTexCoordArrayEnabled(unsigned int unit, bool enable)
400*8975f5c5SAndroid Build Coastguard Worker {
401*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_CLIENT_STATE_ENABLE);
402*8975f5c5SAndroid Build Coastguard Worker     mTexCoordArrayEnabled[unit] = enable;
403*8975f5c5SAndroid Build Coastguard Worker }
404*8975f5c5SAndroid Build Coastguard Worker 
isClientStateEnabled(ClientVertexArrayType clientState) const405*8975f5c5SAndroid Build Coastguard Worker bool GLES1State::isClientStateEnabled(ClientVertexArrayType clientState) const
406*8975f5c5SAndroid Build Coastguard Worker {
407*8975f5c5SAndroid Build Coastguard Worker     switch (clientState)
408*8975f5c5SAndroid Build Coastguard Worker     {
409*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::Vertex:
410*8975f5c5SAndroid Build Coastguard Worker             return mVertexArrayEnabled;
411*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::Normal:
412*8975f5c5SAndroid Build Coastguard Worker             return mNormalArrayEnabled;
413*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::Color:
414*8975f5c5SAndroid Build Coastguard Worker             return mColorArrayEnabled;
415*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::PointSize:
416*8975f5c5SAndroid Build Coastguard Worker             return mPointSizeArrayEnabled;
417*8975f5c5SAndroid Build Coastguard Worker         case ClientVertexArrayType::TextureCoord:
418*8975f5c5SAndroid Build Coastguard Worker             return mTexCoordArrayEnabled[mClientActiveTexture];
419*8975f5c5SAndroid Build Coastguard Worker         default:
420*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
421*8975f5c5SAndroid Build Coastguard Worker             return false;
422*8975f5c5SAndroid Build Coastguard Worker     }
423*8975f5c5SAndroid Build Coastguard Worker }
424*8975f5c5SAndroid Build Coastguard Worker 
isTexCoordArrayEnabled(unsigned int unit) const425*8975f5c5SAndroid Build Coastguard Worker bool GLES1State::isTexCoordArrayEnabled(unsigned int unit) const
426*8975f5c5SAndroid Build Coastguard Worker {
427*8975f5c5SAndroid Build Coastguard Worker     ASSERT(unit < mTexCoordArrayEnabled.size());
428*8975f5c5SAndroid Build Coastguard Worker     return mTexCoordArrayEnabled[unit];
429*8975f5c5SAndroid Build Coastguard Worker }
430*8975f5c5SAndroid Build Coastguard Worker 
isTextureTargetEnabled(unsigned int unit,const TextureType type) const431*8975f5c5SAndroid Build Coastguard Worker bool GLES1State::isTextureTargetEnabled(unsigned int unit, const TextureType type) const
432*8975f5c5SAndroid Build Coastguard Worker {
433*8975f5c5SAndroid Build Coastguard Worker     if (mTexUnitEnables.empty())
434*8975f5c5SAndroid Build Coastguard Worker     {
435*8975f5c5SAndroid Build Coastguard Worker         return false;
436*8975f5c5SAndroid Build Coastguard Worker     }
437*8975f5c5SAndroid Build Coastguard Worker     return mTexUnitEnables[unit].test(type);
438*8975f5c5SAndroid Build Coastguard Worker }
439*8975f5c5SAndroid Build Coastguard Worker 
lightModelParameters()440*8975f5c5SAndroid Build Coastguard Worker LightModelParameters &GLES1State::lightModelParameters()
441*8975f5c5SAndroid Build Coastguard Worker {
442*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_LIGHTS);
443*8975f5c5SAndroid Build Coastguard Worker     return mLightModel;
444*8975f5c5SAndroid Build Coastguard Worker }
445*8975f5c5SAndroid Build Coastguard Worker 
lightModelParameters() const446*8975f5c5SAndroid Build Coastguard Worker const LightModelParameters &GLES1State::lightModelParameters() const
447*8975f5c5SAndroid Build Coastguard Worker {
448*8975f5c5SAndroid Build Coastguard Worker     return mLightModel;
449*8975f5c5SAndroid Build Coastguard Worker }
450*8975f5c5SAndroid Build Coastguard Worker 
lightParameters(unsigned int light)451*8975f5c5SAndroid Build Coastguard Worker LightParameters &GLES1State::lightParameters(unsigned int light)
452*8975f5c5SAndroid Build Coastguard Worker {
453*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_LIGHTS);
454*8975f5c5SAndroid Build Coastguard Worker     return mLights[light];
455*8975f5c5SAndroid Build Coastguard Worker }
456*8975f5c5SAndroid Build Coastguard Worker 
lightParameters(unsigned int light) const457*8975f5c5SAndroid Build Coastguard Worker const LightParameters &GLES1State::lightParameters(unsigned int light) const
458*8975f5c5SAndroid Build Coastguard Worker {
459*8975f5c5SAndroid Build Coastguard Worker     return mLights[light];
460*8975f5c5SAndroid Build Coastguard Worker }
461*8975f5c5SAndroid Build Coastguard Worker 
materialParameters()462*8975f5c5SAndroid Build Coastguard Worker MaterialParameters &GLES1State::materialParameters()
463*8975f5c5SAndroid Build Coastguard Worker {
464*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_MATERIAL);
465*8975f5c5SAndroid Build Coastguard Worker     return mMaterial;
466*8975f5c5SAndroid Build Coastguard Worker }
467*8975f5c5SAndroid Build Coastguard Worker 
materialParameters() const468*8975f5c5SAndroid Build Coastguard Worker const MaterialParameters &GLES1State::materialParameters() const
469*8975f5c5SAndroid Build Coastguard Worker {
470*8975f5c5SAndroid Build Coastguard Worker     return mMaterial;
471*8975f5c5SAndroid Build Coastguard Worker }
472*8975f5c5SAndroid Build Coastguard Worker 
isColorMaterialEnabled() const473*8975f5c5SAndroid Build Coastguard Worker bool GLES1State::isColorMaterialEnabled() const
474*8975f5c5SAndroid Build Coastguard Worker {
475*8975f5c5SAndroid Build Coastguard Worker     return mColorMaterialEnabled;
476*8975f5c5SAndroid Build Coastguard Worker }
477*8975f5c5SAndroid Build Coastguard Worker 
setShadeModel(ShadingModel model)478*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setShadeModel(ShadingModel model)
479*8975f5c5SAndroid Build Coastguard Worker {
480*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_SHADE_MODEL);
481*8975f5c5SAndroid Build Coastguard Worker     mShadeModel = model;
482*8975f5c5SAndroid Build Coastguard Worker }
483*8975f5c5SAndroid Build Coastguard Worker 
setClipPlane(unsigned int plane,const GLfloat * equation)484*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setClipPlane(unsigned int plane, const GLfloat *equation)
485*8975f5c5SAndroid Build Coastguard Worker {
486*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_CLIP_PLANES);
487*8975f5c5SAndroid Build Coastguard Worker     assert(plane < mClipPlanes.size());
488*8975f5c5SAndroid Build Coastguard Worker     mClipPlanes[plane].equation[0] = equation[0];
489*8975f5c5SAndroid Build Coastguard Worker     mClipPlanes[plane].equation[1] = equation[1];
490*8975f5c5SAndroid Build Coastguard Worker     mClipPlanes[plane].equation[2] = equation[2];
491*8975f5c5SAndroid Build Coastguard Worker     mClipPlanes[plane].equation[3] = equation[3];
492*8975f5c5SAndroid Build Coastguard Worker }
493*8975f5c5SAndroid Build Coastguard Worker 
getClipPlane(unsigned int plane,GLfloat * equation) const494*8975f5c5SAndroid Build Coastguard Worker void GLES1State::getClipPlane(unsigned int plane, GLfloat *equation) const
495*8975f5c5SAndroid Build Coastguard Worker {
496*8975f5c5SAndroid Build Coastguard Worker     assert(plane < mClipPlanes.size());
497*8975f5c5SAndroid Build Coastguard Worker     equation[0] = mClipPlanes[plane].equation[0];
498*8975f5c5SAndroid Build Coastguard Worker     equation[1] = mClipPlanes[plane].equation[1];
499*8975f5c5SAndroid Build Coastguard Worker     equation[2] = mClipPlanes[plane].equation[2];
500*8975f5c5SAndroid Build Coastguard Worker     equation[3] = mClipPlanes[plane].equation[3];
501*8975f5c5SAndroid Build Coastguard Worker }
502*8975f5c5SAndroid Build Coastguard Worker 
fogParameters()503*8975f5c5SAndroid Build Coastguard Worker FogParameters &GLES1State::fogParameters()
504*8975f5c5SAndroid Build Coastguard Worker {
505*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_FOG);
506*8975f5c5SAndroid Build Coastguard Worker     return mFog;
507*8975f5c5SAndroid Build Coastguard Worker }
508*8975f5c5SAndroid Build Coastguard Worker 
fogParameters() const509*8975f5c5SAndroid Build Coastguard Worker const FogParameters &GLES1State::fogParameters() const
510*8975f5c5SAndroid Build Coastguard Worker {
511*8975f5c5SAndroid Build Coastguard Worker     return mFog;
512*8975f5c5SAndroid Build Coastguard Worker }
513*8975f5c5SAndroid Build Coastguard Worker 
textureEnvironment(unsigned int unit)514*8975f5c5SAndroid Build Coastguard Worker TextureEnvironmentParameters &GLES1State::textureEnvironment(unsigned int unit)
515*8975f5c5SAndroid Build Coastguard Worker {
516*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_TEXTURE_ENVIRONMENT);
517*8975f5c5SAndroid Build Coastguard Worker     assert(unit < mTextureEnvironments.size());
518*8975f5c5SAndroid Build Coastguard Worker     return mTextureEnvironments[unit];
519*8975f5c5SAndroid Build Coastguard Worker }
520*8975f5c5SAndroid Build Coastguard Worker 
textureEnvironment(unsigned int unit) const521*8975f5c5SAndroid Build Coastguard Worker const TextureEnvironmentParameters &GLES1State::textureEnvironment(unsigned int unit) const
522*8975f5c5SAndroid Build Coastguard Worker {
523*8975f5c5SAndroid Build Coastguard Worker     assert(unit < mTextureEnvironments.size());
524*8975f5c5SAndroid Build Coastguard Worker     return mTextureEnvironments[unit];
525*8975f5c5SAndroid Build Coastguard Worker }
526*8975f5c5SAndroid Build Coastguard Worker 
operator ==(const TextureEnvironmentParameters & a,const TextureEnvironmentParameters & b)527*8975f5c5SAndroid Build Coastguard Worker bool operator==(const TextureEnvironmentParameters &a, const TextureEnvironmentParameters &b)
528*8975f5c5SAndroid Build Coastguard Worker {
529*8975f5c5SAndroid Build Coastguard Worker     return a.tie() == b.tie();
530*8975f5c5SAndroid Build Coastguard Worker }
531*8975f5c5SAndroid Build Coastguard Worker 
operator !=(const TextureEnvironmentParameters & a,const TextureEnvironmentParameters & b)532*8975f5c5SAndroid Build Coastguard Worker bool operator!=(const TextureEnvironmentParameters &a, const TextureEnvironmentParameters &b)
533*8975f5c5SAndroid Build Coastguard Worker {
534*8975f5c5SAndroid Build Coastguard Worker     return !(a == b);
535*8975f5c5SAndroid Build Coastguard Worker }
536*8975f5c5SAndroid Build Coastguard Worker 
pointParameters()537*8975f5c5SAndroid Build Coastguard Worker PointParameters &GLES1State::pointParameters()
538*8975f5c5SAndroid Build Coastguard Worker {
539*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_POINT_PARAMETERS);
540*8975f5c5SAndroid Build Coastguard Worker     return mPointParameters;
541*8975f5c5SAndroid Build Coastguard Worker }
542*8975f5c5SAndroid Build Coastguard Worker 
pointParameters() const543*8975f5c5SAndroid Build Coastguard Worker const PointParameters &GLES1State::pointParameters() const
544*8975f5c5SAndroid Build Coastguard Worker {
545*8975f5c5SAndroid Build Coastguard Worker     return mPointParameters;
546*8975f5c5SAndroid Build Coastguard Worker }
547*8975f5c5SAndroid Build Coastguard Worker 
getAlphaTestParameters() const548*8975f5c5SAndroid Build Coastguard Worker const AlphaTestParameters &GLES1State::getAlphaTestParameters() const
549*8975f5c5SAndroid Build Coastguard Worker {
550*8975f5c5SAndroid Build Coastguard Worker     return mAlphaTestParameters;
551*8975f5c5SAndroid Build Coastguard Worker }
552*8975f5c5SAndroid Build Coastguard Worker 
getVertexArraysAttributeMask() const553*8975f5c5SAndroid Build Coastguard Worker AttributesMask GLES1State::getVertexArraysAttributeMask() const
554*8975f5c5SAndroid Build Coastguard Worker {
555*8975f5c5SAndroid Build Coastguard Worker     AttributesMask attribsMask;
556*8975f5c5SAndroid Build Coastguard Worker 
557*8975f5c5SAndroid Build Coastguard Worker     ClientVertexArrayType nonTexcoordArrays[] = {
558*8975f5c5SAndroid Build Coastguard Worker         ClientVertexArrayType::Vertex,
559*8975f5c5SAndroid Build Coastguard Worker         ClientVertexArrayType::Normal,
560*8975f5c5SAndroid Build Coastguard Worker         ClientVertexArrayType::Color,
561*8975f5c5SAndroid Build Coastguard Worker         ClientVertexArrayType::PointSize,
562*8975f5c5SAndroid Build Coastguard Worker     };
563*8975f5c5SAndroid Build Coastguard Worker 
564*8975f5c5SAndroid Build Coastguard Worker     for (const ClientVertexArrayType attrib : nonTexcoordArrays)
565*8975f5c5SAndroid Build Coastguard Worker     {
566*8975f5c5SAndroid Build Coastguard Worker         attribsMask.set(GLES1Renderer::VertexArrayIndex(attrib, *this),
567*8975f5c5SAndroid Build Coastguard Worker                         isClientStateEnabled(attrib));
568*8975f5c5SAndroid Build Coastguard Worker     }
569*8975f5c5SAndroid Build Coastguard Worker 
570*8975f5c5SAndroid Build Coastguard Worker     for (unsigned int i = 0; i < kTexUnitCount; i++)
571*8975f5c5SAndroid Build Coastguard Worker     {
572*8975f5c5SAndroid Build Coastguard Worker         attribsMask.set(GLES1Renderer::TexCoordArrayIndex(i), isTexCoordArrayEnabled(i));
573*8975f5c5SAndroid Build Coastguard Worker     }
574*8975f5c5SAndroid Build Coastguard Worker 
575*8975f5c5SAndroid Build Coastguard Worker     return attribsMask;
576*8975f5c5SAndroid Build Coastguard Worker }
577*8975f5c5SAndroid Build Coastguard Worker 
getActiveAttributesMask() const578*8975f5c5SAndroid Build Coastguard Worker AttributesMask GLES1State::getActiveAttributesMask() const
579*8975f5c5SAndroid Build Coastguard Worker {
580*8975f5c5SAndroid Build Coastguard Worker     // The program always has 8 attributes enabled.
581*8975f5c5SAndroid Build Coastguard Worker     return AttributesMask(0xFF);
582*8975f5c5SAndroid Build Coastguard Worker }
583*8975f5c5SAndroid Build Coastguard Worker 
setHint(GLenum target,GLenum mode)584*8975f5c5SAndroid Build Coastguard Worker void GLES1State::setHint(GLenum target, GLenum mode)
585*8975f5c5SAndroid Build Coastguard Worker {
586*8975f5c5SAndroid Build Coastguard Worker     setDirty(DIRTY_GLES1_HINT_SETTING);
587*8975f5c5SAndroid Build Coastguard Worker     HintSetting setting = FromGLenum<HintSetting>(mode);
588*8975f5c5SAndroid Build Coastguard Worker     switch (target)
589*8975f5c5SAndroid Build Coastguard Worker     {
590*8975f5c5SAndroid Build Coastguard Worker         case GL_PERSPECTIVE_CORRECTION_HINT:
591*8975f5c5SAndroid Build Coastguard Worker             mPerspectiveCorrectionHint = setting;
592*8975f5c5SAndroid Build Coastguard Worker             break;
593*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SMOOTH_HINT:
594*8975f5c5SAndroid Build Coastguard Worker             mPointSmoothHint = setting;
595*8975f5c5SAndroid Build Coastguard Worker             break;
596*8975f5c5SAndroid Build Coastguard Worker         case GL_LINE_SMOOTH_HINT:
597*8975f5c5SAndroid Build Coastguard Worker             mLineSmoothHint = setting;
598*8975f5c5SAndroid Build Coastguard Worker             break;
599*8975f5c5SAndroid Build Coastguard Worker         case GL_FOG_HINT:
600*8975f5c5SAndroid Build Coastguard Worker             mFogHint = setting;
601*8975f5c5SAndroid Build Coastguard Worker             break;
602*8975f5c5SAndroid Build Coastguard Worker         default:
603*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
604*8975f5c5SAndroid Build Coastguard Worker     }
605*8975f5c5SAndroid Build Coastguard Worker }
606*8975f5c5SAndroid Build Coastguard Worker 
getHint(GLenum target) const607*8975f5c5SAndroid Build Coastguard Worker GLenum GLES1State::getHint(GLenum target) const
608*8975f5c5SAndroid Build Coastguard Worker {
609*8975f5c5SAndroid Build Coastguard Worker     switch (target)
610*8975f5c5SAndroid Build Coastguard Worker     {
611*8975f5c5SAndroid Build Coastguard Worker         case GL_PERSPECTIVE_CORRECTION_HINT:
612*8975f5c5SAndroid Build Coastguard Worker             return ToGLenum(mPerspectiveCorrectionHint);
613*8975f5c5SAndroid Build Coastguard Worker         case GL_POINT_SMOOTH_HINT:
614*8975f5c5SAndroid Build Coastguard Worker             return ToGLenum(mPointSmoothHint);
615*8975f5c5SAndroid Build Coastguard Worker         case GL_LINE_SMOOTH_HINT:
616*8975f5c5SAndroid Build Coastguard Worker             return ToGLenum(mLineSmoothHint);
617*8975f5c5SAndroid Build Coastguard Worker         case GL_FOG_HINT:
618*8975f5c5SAndroid Build Coastguard Worker             return ToGLenum(mFogHint);
619*8975f5c5SAndroid Build Coastguard Worker         default:
620*8975f5c5SAndroid Build Coastguard Worker             UNREACHABLE();
621*8975f5c5SAndroid Build Coastguard Worker             return 0;
622*8975f5c5SAndroid Build Coastguard Worker     }
623*8975f5c5SAndroid Build Coastguard Worker }
624*8975f5c5SAndroid Build Coastguard Worker 
625*8975f5c5SAndroid Build Coastguard Worker }  // namespace gl
626