blob: 9637117bc11addcc7b877ba2350938cf65d26fe1 [file] [log] [blame]
John Reck3b202512014-06-23 13:13:08 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Chris Craik96a5c4c2015-01-27 15:46:35 -080016#include "renderstate/RenderState.h"
John Reck3b202512014-06-23 13:13:08 -070017
John Reck443a7142014-09-04 17:40:05 -070018#include "renderthread/CanvasContext.h"
John Reck0e89e2b2014-10-31 14:49:06 -070019#include "renderthread/EglManager.h"
Chris Craik117bdbc2015-02-05 10:12:38 -080020#include "utils/GLUtils.h"
John Reck443a7142014-09-04 17:40:05 -070021
Chris Craik9db58c02015-08-19 15:19:18 -070022#include <algorithm>
23
John Reck3b202512014-06-23 13:13:08 -070024namespace android {
25namespace uirenderer {
26
John Reck0e89e2b2014-10-31 14:49:06 -070027RenderState::RenderState(renderthread::RenderThread& thread)
28 : mRenderThread(thread)
John Reck3b202512014-06-23 13:13:08 -070029 , mViewportWidth(0)
30 , mViewportHeight(0)
31 , mFramebuffer(0) {
John Reck0e89e2b2014-10-31 14:49:06 -070032 mThreadId = pthread_self();
John Reck3b202512014-06-23 13:13:08 -070033}
34
35RenderState::~RenderState() {
Chris Craik44eb2c02015-01-29 09:45:09 -080036 LOG_ALWAYS_FATAL_IF(mBlend || mMeshState || mScissor || mStencil,
Chris Craik96a5c4c2015-01-27 15:46:35 -080037 "State object lifecycle not managed correctly");
John Reck3b202512014-06-23 13:13:08 -070038}
39
40void RenderState::onGLContextCreated() {
Chris Craik44eb2c02015-01-29 09:45:09 -080041 LOG_ALWAYS_FATAL_IF(mBlend || mMeshState || mScissor || mStencil,
Chris Craik96a5c4c2015-01-27 15:46:35 -080042 "State object lifecycle not managed correctly");
Chris Craik44eb2c02015-01-29 09:45:09 -080043 mBlend = new Blend();
Chris Craik96a5c4c2015-01-27 15:46:35 -080044 mMeshState = new MeshState();
45 mScissor = new Scissor();
46 mStencil = new Stencil();
Chris Craik65fe5ee2015-01-26 18:06:29 -080047
Chris Craik96a5c4c2015-01-27 15:46:35 -080048 // This is delayed because the first access of Caches makes GL calls
Chris Craikff5c8e82015-01-30 09:46:18 -080049 if (!mCaches) {
50 mCaches = &Caches::createInstance(*this);
51 }
Chris Craik96a5c4c2015-01-27 15:46:35 -080052 mCaches->init();
53 mCaches->textureCache.setAssetAtlas(&mAssetAtlas);
John Reck3b202512014-06-23 13:13:08 -070054}
55
John Reck49bc4ac2015-01-29 12:53:38 -080056static void layerLostGlContext(Layer* layer) {
57 layer->onGlContextLost();
58}
59
Chris Craik1d477422014-08-26 17:30:15 -070060void RenderState::onGLContextDestroyed() {
Chris Craik21029ef2014-09-12 09:29:10 -070061/*
Chris Craikbfd1cd62014-09-10 13:04:31 -070062 size_t size = mActiveLayers.size();
63 if (CC_UNLIKELY(size != 0)) {
64 ALOGE("Crashing, have %d contexts and %d layers at context destruction. isempty %d",
65 mRegisteredContexts.size(), size, mActiveLayers.empty());
John Reck17035b02014-09-03 07:39:53 -070066 mCaches->dumpMemoryUsage();
John Reck443a7142014-09-04 17:40:05 -070067 for (std::set<renderthread::CanvasContext*>::iterator cit = mRegisteredContexts.begin();
68 cit != mRegisteredContexts.end(); cit++) {
69 renderthread::CanvasContext* context = *cit;
Chris Craikbfd1cd62014-09-10 13:04:31 -070070 ALOGE("Context: %p (root = %p)", context, context->mRootRenderNode.get());
71 ALOGE(" Prefeteched layers: %zu", context->mPrefetechedLayers.size());
John Reck443a7142014-09-04 17:40:05 -070072 for (std::set<RenderNode*>::iterator pit = context->mPrefetechedLayers.begin();
73 pit != context->mPrefetechedLayers.end(); pit++) {
74 (*pit)->debugDumpLayers(" ");
75 }
76 context->mRootRenderNode->debugDumpLayers(" ");
77 }
Chris Craik599e2542014-09-05 15:17:11 -070078
Chris Craikbfd1cd62014-09-10 13:04:31 -070079
80 if (mActiveLayers.begin() == mActiveLayers.end()) {
81 ALOGE("set has become empty. wat.");
82 }
Chris Craik599e2542014-09-05 15:17:11 -070083 for (std::set<const Layer*>::iterator lit = mActiveLayers.begin();
84 lit != mActiveLayers.end(); lit++) {
85 const Layer* layer = *(lit);
Chris Craikbfd1cd62014-09-10 13:04:31 -070086 ALOGE("Layer %p, state %d, texlayer %d, fbo %d, buildlayered %d",
87 layer, layer->state, layer->isTextureLayer(), layer->getFbo(), layer->wasBuildLayered);
Chris Craik599e2542014-09-05 15:17:11 -070088 }
Chris Craikbfd1cd62014-09-10 13:04:31 -070089 LOG_ALWAYS_FATAL("%d layers have survived gl context destruction", size);
John Reck17035b02014-09-03 07:39:53 -070090 }
Chris Craik21029ef2014-09-12 09:29:10 -070091*/
John Reck49bc4ac2015-01-29 12:53:38 -080092
Chris Craik96a5c4c2015-01-27 15:46:35 -080093 // TODO: reset all cached state in state objects
John Reck49bc4ac2015-01-29 12:53:38 -080094 std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerLostGlContext);
John Reckebd52612014-12-10 16:47:36 -080095 mAssetAtlas.terminate();
Chris Craik96a5c4c2015-01-27 15:46:35 -080096
Chris Craik44eb2c02015-01-29 09:45:09 -080097 mCaches->terminate();
98
99 delete mBlend;
100 mBlend = nullptr;
Chris Craik96a5c4c2015-01-27 15:46:35 -0800101 delete mMeshState;
102 mMeshState = nullptr;
103 delete mScissor;
104 mScissor = nullptr;
105 delete mStencil;
106 mStencil = nullptr;
Chris Craik1d477422014-08-26 17:30:15 -0700107}
108
John Reck3b202512014-06-23 13:13:08 -0700109void RenderState::setViewport(GLsizei width, GLsizei height) {
110 mViewportWidth = width;
111 mViewportHeight = height;
112 glViewport(0, 0, mViewportWidth, mViewportHeight);
113}
114
115
116void RenderState::getViewport(GLsizei* outWidth, GLsizei* outHeight) {
117 *outWidth = mViewportWidth;
118 *outHeight = mViewportHeight;
119}
120
121void RenderState::bindFramebuffer(GLuint fbo) {
122 if (mFramebuffer != fbo) {
123 mFramebuffer = fbo;
124 glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
125 }
126}
127
Chris Craik818c9fb2015-10-23 14:33:42 -0700128GLuint RenderState::genFramebuffer() {
129 GLuint ret;
130 glGenFramebuffers(1, &ret);
131 return ret;
132}
133
134void RenderState::deleteFramebuffer(GLuint fbo) {
135 if (mFramebuffer == fbo) {
136 // GL defines that deleting the currently bound FBO rebinds FBO 0.
137 // Reflect this in our cached value.
138 mFramebuffer = 0;
139 }
140 glDeleteFramebuffers(1, &fbo);
141}
142
John Reck3b202512014-06-23 13:13:08 -0700143void RenderState::invokeFunctor(Functor* functor, DrawGlInfo::Mode mode, DrawGlInfo* info) {
John Reck95cd24b2015-08-04 11:17:39 -0700144 if (mode == DrawGlInfo::kModeProcessNoContext) {
145 // If there's no context we don't need to interrupt as there's
146 // no gl state to save/restore
147 (*functor)(mode, info);
148 } else {
149 interruptForFunctorInvoke();
150 (*functor)(mode, info);
151 resumeFromFunctorInvoke();
152 }
John Reck3b202512014-06-23 13:13:08 -0700153}
154
155void RenderState::interruptForFunctorInvoke() {
Chris Craik6c15ffa2015-02-02 13:50:55 -0800156 mCaches->setProgram(nullptr);
Chris Craik44eb2c02015-01-29 09:45:09 -0800157 mCaches->textureState().resetActiveTexture();
Chris Craik96a5c4c2015-01-27 15:46:35 -0800158 meshState().unbindMeshBuffer();
159 meshState().unbindIndicesBuffer();
160 meshState().resetVertexPointers();
161 meshState().disableTexCoordsVertexArray();
John Reck3b202512014-06-23 13:13:08 -0700162 debugOverdraw(false, false);
163}
164
165void RenderState::resumeFromFunctorInvoke() {
166 glViewport(0, 0, mViewportWidth, mViewportHeight);
167 glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
168 debugOverdraw(false, false);
169
170 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
171
Chris Craik65fe5ee2015-01-26 18:06:29 -0800172 scissor().invalidate();
Chris Craik44eb2c02015-01-29 09:45:09 -0800173 blend().invalidate();
John Reck3b202512014-06-23 13:13:08 -0700174
Chris Craik44eb2c02015-01-29 09:45:09 -0800175 mCaches->textureState().activateTexture(0);
176 mCaches->textureState().resetBoundTextures();
John Reck3b202512014-06-23 13:13:08 -0700177}
178
179void RenderState::debugOverdraw(bool enable, bool clear) {
Chris Craik2507c342015-05-04 14:36:49 -0700180 if (Properties::debugOverdraw && mFramebuffer == 0) {
John Reck3b202512014-06-23 13:13:08 -0700181 if (clear) {
Chris Craik65fe5ee2015-01-26 18:06:29 -0800182 scissor().setEnabled(false);
Chris Craik96a5c4c2015-01-27 15:46:35 -0800183 stencil().clear();
John Reck3b202512014-06-23 13:13:08 -0700184 }
185 if (enable) {
Chris Craik96a5c4c2015-01-27 15:46:35 -0800186 stencil().enableDebugWrite();
John Reck3b202512014-06-23 13:13:08 -0700187 } else {
Chris Craik96a5c4c2015-01-27 15:46:35 -0800188 stencil().disable();
John Reck3b202512014-06-23 13:13:08 -0700189 }
190 }
191}
192
John Reck0e89e2b2014-10-31 14:49:06 -0700193void RenderState::requireGLContext() {
194 assertOnGLThread();
John Reckd7db4d72015-05-20 07:18:55 -0700195 LOG_ALWAYS_FATAL_IF(!mRenderThread.eglManager().hasEglContext(),
196 "No GL context!");
John Reck0e89e2b2014-10-31 14:49:06 -0700197}
198
199void RenderState::assertOnGLThread() {
200 pthread_t curr = pthread_self();
201 LOG_ALWAYS_FATAL_IF(!pthread_equal(mThreadId, curr), "Wrong thread!");
202}
203
John Reck0e89e2b2014-10-31 14:49:06 -0700204class DecStrongTask : public renderthread::RenderTask {
205public:
206 DecStrongTask(VirtualLightRefBase* object) : mObject(object) {}
207
Chris Craikd41c4d82015-01-05 15:51:13 -0800208 virtual void run() override {
209 mObject->decStrong(nullptr);
210 mObject = nullptr;
John Reck0e89e2b2014-10-31 14:49:06 -0700211 delete this;
212 }
213
214private:
215 VirtualLightRefBase* mObject;
216};
217
218void RenderState::postDecStrong(VirtualLightRefBase* object) {
219 mRenderThread.queue(new DecStrongTask(object));
220}
221
Chris Craik6c15ffa2015-02-02 13:50:55 -0800222///////////////////////////////////////////////////////////////////////////////
223// Render
224///////////////////////////////////////////////////////////////////////////////
225
Chris Craik12efe642015-09-28 15:52:12 -0700226void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix) {
Chris Craik6c15ffa2015-02-02 13:50:55 -0800227 const Glop::Mesh& mesh = glop.mesh;
Chris Craikef250742015-02-25 17:16:16 -0800228 const Glop::Mesh::Vertices& vertices = mesh.vertices;
229 const Glop::Mesh::Indices& indices = mesh.indices;
Chris Craik0519c8102015-02-11 13:17:06 -0800230 const Glop::Fill& fill = glop.fill;
Chris Craik6c15ffa2015-02-02 13:50:55 -0800231
Chris Craik0519c8102015-02-11 13:17:06 -0800232 // ---------------------------------------------
233 // ---------- Program + uniform setup ----------
234 // ---------------------------------------------
235 mCaches->setProgram(fill.program);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800236
Chris Craik0519c8102015-02-11 13:17:06 -0800237 if (fill.colorEnabled) {
238 fill.program->setColor(fill.color);
239 }
Chris Craik6c15ffa2015-02-02 13:50:55 -0800240
Chris Craik12efe642015-09-28 15:52:12 -0700241 fill.program->set(orthoMatrix,
Chris Craik6c15ffa2015-02-02 13:50:55 -0800242 glop.transform.modelView,
Chris Craik53e51e42015-06-01 10:35:35 -0700243 glop.transform.meshTransform(),
244 glop.transform.transformFlags & TransformFlags::OffsetByFudgeFactor);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800245
Chris Craik0519c8102015-02-11 13:17:06 -0800246 // Color filter uniforms
Chris Craikb9ce116d2015-08-20 15:14:06 -0700247 if (fill.filterMode == ProgramDescription::ColorFilterMode::Blend) {
Chris Craikef250742015-02-25 17:16:16 -0800248 const FloatColor& color = fill.filter.color;
Chris Craik117bdbc2015-02-05 10:12:38 -0800249 glUniform4f(mCaches->program().getUniform("colorBlend"),
250 color.r, color.g, color.b, color.a);
Chris Craikb9ce116d2015-08-20 15:14:06 -0700251 } else if (fill.filterMode == ProgramDescription::ColorFilterMode::Matrix) {
Chris Craik117bdbc2015-02-05 10:12:38 -0800252 glUniformMatrix4fv(mCaches->program().getUniform("colorMatrix"), 1, GL_FALSE,
Chris Craikef250742015-02-25 17:16:16 -0800253 fill.filter.matrix.matrix);
Chris Craik117bdbc2015-02-05 10:12:38 -0800254 glUniform4fv(mCaches->program().getUniform("colorMatrixVector"), 1,
Chris Craikef250742015-02-25 17:16:16 -0800255 fill.filter.matrix.vector);
Chris Craik117bdbc2015-02-05 10:12:38 -0800256 }
257
Chris Craik0519c8102015-02-11 13:17:06 -0800258 // Round rect clipping uniforms
259 if (glop.roundRectClipState) {
260 // TODO: avoid query, and cache values (or RRCS ptr) in program
261 const RoundRectClipState* state = glop.roundRectClipState;
262 const Rect& innerRect = state->innerRect;
263 glUniform4f(fill.program->getUniform("roundRectInnerRectLTRB"),
264 innerRect.left, innerRect.top,
265 innerRect.right, innerRect.bottom);
266 glUniformMatrix4fv(fill.program->getUniform("roundRectInvTransform"),
267 1, GL_FALSE, &state->matrix.data[0]);
268
269 // add half pixel to round out integer rect space to cover pixel centers
270 float roundedOutRadius = state->radius + 0.5f;
271 glUniform1f(fill.program->getUniform("roundRectRadius"),
272 roundedOutRadius);
273 }
Chris Craikef250742015-02-25 17:16:16 -0800274
Chris Craik117bdbc2015-02-05 10:12:38 -0800275 // --------------------------------
Chris Craik6c15ffa2015-02-02 13:50:55 -0800276 // ---------- Mesh setup ----------
Chris Craik117bdbc2015-02-05 10:12:38 -0800277 // --------------------------------
278 // vertices
Chris Craikef250742015-02-25 17:16:16 -0800279 const bool force = meshState().bindMeshBufferInternal(vertices.bufferObject)
280 || (vertices.position != nullptr);
281 meshState().bindPositionVertexPointer(force, vertices.position, vertices.stride);
Chris Craik117bdbc2015-02-05 10:12:38 -0800282
283 // indices
Chris Craikef250742015-02-25 17:16:16 -0800284 meshState().bindIndicesBufferInternal(indices.bufferObject);
Chris Craik117bdbc2015-02-05 10:12:38 -0800285
Chris Craik53e51e42015-06-01 10:35:35 -0700286 if (vertices.attribFlags & VertexAttribFlags::TextureCoord) {
Chris Craik26bf3422015-02-26 16:28:17 -0800287 const Glop::Fill::TextureData& texture = fill.texture;
288 // texture always takes slot 0, shader samplers increment from there
Chris Craik0519c8102015-02-11 13:17:06 -0800289 mCaches->textureState().activateTexture(0);
290
Chris Craik26bf3422015-02-26 16:28:17 -0800291 if (texture.clamp != GL_INVALID_ENUM) {
Chris Craik5f1356c2015-05-27 11:06:21 -0700292 texture.texture->setWrap(texture.clamp, true, false, texture.target);
Chris Craik30036092015-02-12 10:41:39 -0800293 }
Chris Craik26bf3422015-02-26 16:28:17 -0800294 if (texture.filter != GL_INVALID_ENUM) {
Chris Craik5f1356c2015-05-27 11:06:21 -0700295 texture.texture->setFilter(texture.filter, true, false, texture.target);
Chris Craik30036092015-02-12 10:41:39 -0800296 }
Chris Craik0519c8102015-02-11 13:17:06 -0800297
Chris Craik26bf3422015-02-26 16:28:17 -0800298 mCaches->textureState().bindTexture(texture.target, texture.texture->id);
Chris Craik0519c8102015-02-11 13:17:06 -0800299 meshState().enableTexCoordsVertexArray();
Chris Craikef250742015-02-25 17:16:16 -0800300 meshState().bindTexCoordsVertexPointer(force, vertices.texCoord, vertices.stride);
Chris Craik26bf3422015-02-26 16:28:17 -0800301
302 if (texture.textureTransform) {
303 glUniformMatrix4fv(fill.program->getUniform("mainTextureTransform"), 1,
304 GL_FALSE, &texture.textureTransform->data[0]);
305 }
Chris Craik6c15ffa2015-02-02 13:50:55 -0800306 } else {
307 meshState().disableTexCoordsVertexArray();
308 }
Chris Craikef250742015-02-25 17:16:16 -0800309 int colorLocation = -1;
Chris Craik53e51e42015-06-01 10:35:35 -0700310 if (vertices.attribFlags & VertexAttribFlags::Color) {
Chris Craikef250742015-02-25 17:16:16 -0800311 colorLocation = fill.program->getAttrib("colors");
312 glEnableVertexAttribArray(colorLocation);
313 glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, vertices.stride, vertices.color);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800314 }
Chris Craikef250742015-02-25 17:16:16 -0800315 int alphaLocation = -1;
Chris Craik53e51e42015-06-01 10:35:35 -0700316 if (vertices.attribFlags & VertexAttribFlags::Alpha) {
Chris Craikef250742015-02-25 17:16:16 -0800317 // NOTE: alpha vertex position is computed assuming no VBO
318 const void* alphaCoords = ((const GLbyte*) vertices.position) + kVertexAlphaOffset;
319 alphaLocation = fill.program->getAttrib("vtxAlpha");
320 glEnableVertexAttribArray(alphaLocation);
321 glVertexAttribPointer(alphaLocation, 1, GL_FLOAT, GL_FALSE, vertices.stride, alphaCoords);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800322 }
Chris Craik922d3a72015-02-13 17:47:21 -0800323 // Shader uniforms
Chris Craikef250742015-02-25 17:16:16 -0800324 SkiaShader::apply(*mCaches, fill.skiaShaderData);
Chris Craik922d3a72015-02-13 17:47:21 -0800325
Chris Craik117bdbc2015-02-05 10:12:38 -0800326 // ------------------------------------
Chris Craik6c15ffa2015-02-02 13:50:55 -0800327 // ---------- GL state setup ----------
Chris Craik117bdbc2015-02-05 10:12:38 -0800328 // ------------------------------------
Chris Craik03188872015-02-02 18:39:33 -0800329 blend().setFactors(glop.blend.src, glop.blend.dst);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800330
Chris Craik117bdbc2015-02-05 10:12:38 -0800331 // ------------------------------------
Chris Craik2ab95d72015-02-06 15:25:51 -0800332 // ---------- Actual drawing ----------
Chris Craik117bdbc2015-02-05 10:12:38 -0800333 // ------------------------------------
Chris Craikef250742015-02-25 17:16:16 -0800334 if (indices.bufferObject == meshState().getQuadListIBO()) {
Chris Craik2ab95d72015-02-06 15:25:51 -0800335 // Since the indexed quad list is of limited length, we loop over
336 // the glDrawXXX method while updating the vertex pointer
Chris Craik0519c8102015-02-11 13:17:06 -0800337 GLsizei elementsCount = mesh.elementCount;
Chris Craikef250742015-02-25 17:16:16 -0800338 const GLbyte* vertexData = static_cast<const GLbyte*>(vertices.position);
Chris Craik2ab95d72015-02-06 15:25:51 -0800339 while (elementsCount > 0) {
Chris Craik9db58c02015-08-19 15:19:18 -0700340 GLsizei drawCount = std::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6);
Chris Craik2ab95d72015-02-06 15:25:51 -0800341
Chris Craikf27133d2015-02-19 09:51:53 -0800342 // rebind pointers without forcing, since initial bind handled above
Chris Craikef250742015-02-25 17:16:16 -0800343 meshState().bindPositionVertexPointer(false, vertexData, vertices.stride);
Chris Craik53e51e42015-06-01 10:35:35 -0700344 if (vertices.attribFlags & VertexAttribFlags::TextureCoord) {
Chris Craikf27133d2015-02-19 09:51:53 -0800345 meshState().bindTexCoordsVertexPointer(false,
Chris Craikef250742015-02-25 17:16:16 -0800346 vertexData + kMeshTextureOffset, vertices.stride);
Chris Craikf27133d2015-02-19 09:51:53 -0800347 }
348
Chris Craik2ab95d72015-02-06 15:25:51 -0800349 glDrawElements(mesh.primitiveMode, drawCount, GL_UNSIGNED_SHORT, nullptr);
350 elementsCount -= drawCount;
Chris Craikef250742015-02-25 17:16:16 -0800351 vertexData += (drawCount / 6) * 4 * vertices.stride;
Chris Craik2ab95d72015-02-06 15:25:51 -0800352 }
Chris Craikef250742015-02-25 17:16:16 -0800353 } else if (indices.bufferObject || indices.indices) {
354 glDrawElements(mesh.primitiveMode, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800355 } else {
Chris Craik0519c8102015-02-11 13:17:06 -0800356 glDrawArrays(mesh.primitiveMode, 0, mesh.elementCount);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800357 }
Chris Craik117bdbc2015-02-05 10:12:38 -0800358
Chris Craik2ab95d72015-02-06 15:25:51 -0800359 // -----------------------------------
360 // ---------- Mesh teardown ----------
361 // -----------------------------------
Chris Craik53e51e42015-06-01 10:35:35 -0700362 if (vertices.attribFlags & VertexAttribFlags::Alpha) {
Chris Craikef250742015-02-25 17:16:16 -0800363 glDisableVertexAttribArray(alphaLocation);
364 }
Chris Craik53e51e42015-06-01 10:35:35 -0700365 if (vertices.attribFlags & VertexAttribFlags::Color) {
Chris Craikef250742015-02-25 17:16:16 -0800366 glDisableVertexAttribArray(colorLocation);
Chris Craik117bdbc2015-02-05 10:12:38 -0800367 }
368}
369
370void RenderState::dump() {
371 blend().dump();
372 meshState().dump();
373 scissor().dump();
374 stencil().dump();
Chris Craik6c15ffa2015-02-02 13:50:55 -0800375}
376
John Reck3b202512014-06-23 13:13:08 -0700377} /* namespace uirenderer */
378} /* namespace android */