blob: 4fa820058fb22bce447f65ba8a2eb542a9f73262 [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 Craik9fded232015-11-11 16:42:34 -080093 mLayerPool.clear();
94
Chris Craik96a5c4c2015-01-27 15:46:35 -080095 // TODO: reset all cached state in state objects
John Reck49bc4ac2015-01-29 12:53:38 -080096 std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerLostGlContext);
John Reckebd52612014-12-10 16:47:36 -080097 mAssetAtlas.terminate();
Chris Craik96a5c4c2015-01-27 15:46:35 -080098
Chris Craik44eb2c02015-01-29 09:45:09 -080099 mCaches->terminate();
100
101 delete mBlend;
102 mBlend = nullptr;
Chris Craik96a5c4c2015-01-27 15:46:35 -0800103 delete mMeshState;
104 mMeshState = nullptr;
105 delete mScissor;
106 mScissor = nullptr;
107 delete mStencil;
108 mStencil = nullptr;
Chris Craik1d477422014-08-26 17:30:15 -0700109}
110
Chris Craik9fded232015-11-11 16:42:34 -0800111void RenderState::flush(Caches::FlushMode mode) {
112 switch (mode) {
113 case Caches::FlushMode::Full:
114 // fall through
115 case Caches::FlushMode::Moderate:
116 // fall through
117 case Caches::FlushMode::Layers:
118 mLayerPool.clear();
119 break;
120 }
121 mCaches->flush(mode);
122}
123
John Reck3b202512014-06-23 13:13:08 -0700124void RenderState::setViewport(GLsizei width, GLsizei height) {
125 mViewportWidth = width;
126 mViewportHeight = height;
127 glViewport(0, 0, mViewportWidth, mViewportHeight);
128}
129
130
131void RenderState::getViewport(GLsizei* outWidth, GLsizei* outHeight) {
132 *outWidth = mViewportWidth;
133 *outHeight = mViewportHeight;
134}
135
136void RenderState::bindFramebuffer(GLuint fbo) {
137 if (mFramebuffer != fbo) {
138 mFramebuffer = fbo;
139 glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
140 }
141}
142
Chris Craik818c9fb2015-10-23 14:33:42 -0700143GLuint RenderState::genFramebuffer() {
144 GLuint ret;
145 glGenFramebuffers(1, &ret);
146 return ret;
147}
148
149void RenderState::deleteFramebuffer(GLuint fbo) {
150 if (mFramebuffer == fbo) {
151 // GL defines that deleting the currently bound FBO rebinds FBO 0.
152 // Reflect this in our cached value.
153 mFramebuffer = 0;
154 }
155 glDeleteFramebuffers(1, &fbo);
156}
157
John Reck3b202512014-06-23 13:13:08 -0700158void RenderState::invokeFunctor(Functor* functor, DrawGlInfo::Mode mode, DrawGlInfo* info) {
John Reck95cd24b2015-08-04 11:17:39 -0700159 if (mode == DrawGlInfo::kModeProcessNoContext) {
160 // If there's no context we don't need to interrupt as there's
161 // no gl state to save/restore
162 (*functor)(mode, info);
163 } else {
164 interruptForFunctorInvoke();
165 (*functor)(mode, info);
166 resumeFromFunctorInvoke();
167 }
John Reck3b202512014-06-23 13:13:08 -0700168}
169
170void RenderState::interruptForFunctorInvoke() {
Chris Craik6c15ffa2015-02-02 13:50:55 -0800171 mCaches->setProgram(nullptr);
Chris Craik44eb2c02015-01-29 09:45:09 -0800172 mCaches->textureState().resetActiveTexture();
Chris Craik96a5c4c2015-01-27 15:46:35 -0800173 meshState().unbindMeshBuffer();
174 meshState().unbindIndicesBuffer();
175 meshState().resetVertexPointers();
176 meshState().disableTexCoordsVertexArray();
John Reck3b202512014-06-23 13:13:08 -0700177 debugOverdraw(false, false);
178}
179
180void RenderState::resumeFromFunctorInvoke() {
181 glViewport(0, 0, mViewportWidth, mViewportHeight);
182 glBindFramebuffer(GL_FRAMEBUFFER, mFramebuffer);
183 debugOverdraw(false, false);
184
185 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
186
Chris Craik65fe5ee2015-01-26 18:06:29 -0800187 scissor().invalidate();
Chris Craik44eb2c02015-01-29 09:45:09 -0800188 blend().invalidate();
John Reck3b202512014-06-23 13:13:08 -0700189
Chris Craik44eb2c02015-01-29 09:45:09 -0800190 mCaches->textureState().activateTexture(0);
191 mCaches->textureState().resetBoundTextures();
John Reck3b202512014-06-23 13:13:08 -0700192}
193
194void RenderState::debugOverdraw(bool enable, bool clear) {
Chris Craik2507c342015-05-04 14:36:49 -0700195 if (Properties::debugOverdraw && mFramebuffer == 0) {
John Reck3b202512014-06-23 13:13:08 -0700196 if (clear) {
Chris Craik65fe5ee2015-01-26 18:06:29 -0800197 scissor().setEnabled(false);
Chris Craik96a5c4c2015-01-27 15:46:35 -0800198 stencil().clear();
John Reck3b202512014-06-23 13:13:08 -0700199 }
200 if (enable) {
Chris Craik96a5c4c2015-01-27 15:46:35 -0800201 stencil().enableDebugWrite();
John Reck3b202512014-06-23 13:13:08 -0700202 } else {
Chris Craik96a5c4c2015-01-27 15:46:35 -0800203 stencil().disable();
John Reck3b202512014-06-23 13:13:08 -0700204 }
205 }
206}
207
John Reck0e89e2b2014-10-31 14:49:06 -0700208void RenderState::requireGLContext() {
209 assertOnGLThread();
John Reckd7db4d72015-05-20 07:18:55 -0700210 LOG_ALWAYS_FATAL_IF(!mRenderThread.eglManager().hasEglContext(),
211 "No GL context!");
John Reck0e89e2b2014-10-31 14:49:06 -0700212}
213
214void RenderState::assertOnGLThread() {
215 pthread_t curr = pthread_self();
216 LOG_ALWAYS_FATAL_IF(!pthread_equal(mThreadId, curr), "Wrong thread!");
217}
218
John Reck0e89e2b2014-10-31 14:49:06 -0700219class DecStrongTask : public renderthread::RenderTask {
220public:
221 DecStrongTask(VirtualLightRefBase* object) : mObject(object) {}
222
Chris Craikd41c4d82015-01-05 15:51:13 -0800223 virtual void run() override {
224 mObject->decStrong(nullptr);
225 mObject = nullptr;
John Reck0e89e2b2014-10-31 14:49:06 -0700226 delete this;
227 }
228
229private:
230 VirtualLightRefBase* mObject;
231};
232
233void RenderState::postDecStrong(VirtualLightRefBase* object) {
234 mRenderThread.queue(new DecStrongTask(object));
235}
236
Chris Craik6c15ffa2015-02-02 13:50:55 -0800237///////////////////////////////////////////////////////////////////////////////
238// Render
239///////////////////////////////////////////////////////////////////////////////
240
Chris Craik12efe642015-09-28 15:52:12 -0700241void RenderState::render(const Glop& glop, const Matrix4& orthoMatrix) {
Chris Craik6c15ffa2015-02-02 13:50:55 -0800242 const Glop::Mesh& mesh = glop.mesh;
Chris Craikef250742015-02-25 17:16:16 -0800243 const Glop::Mesh::Vertices& vertices = mesh.vertices;
244 const Glop::Mesh::Indices& indices = mesh.indices;
Chris Craik0519c8102015-02-11 13:17:06 -0800245 const Glop::Fill& fill = glop.fill;
Chris Craik6c15ffa2015-02-02 13:50:55 -0800246
Chris Craik0519c8102015-02-11 13:17:06 -0800247 // ---------------------------------------------
248 // ---------- Program + uniform setup ----------
249 // ---------------------------------------------
250 mCaches->setProgram(fill.program);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800251
Chris Craik0519c8102015-02-11 13:17:06 -0800252 if (fill.colorEnabled) {
253 fill.program->setColor(fill.color);
254 }
Chris Craik6c15ffa2015-02-02 13:50:55 -0800255
Chris Craik12efe642015-09-28 15:52:12 -0700256 fill.program->set(orthoMatrix,
Chris Craik6c15ffa2015-02-02 13:50:55 -0800257 glop.transform.modelView,
Chris Craik53e51e42015-06-01 10:35:35 -0700258 glop.transform.meshTransform(),
259 glop.transform.transformFlags & TransformFlags::OffsetByFudgeFactor);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800260
Chris Craik0519c8102015-02-11 13:17:06 -0800261 // Color filter uniforms
Chris Craikb9ce116d2015-08-20 15:14:06 -0700262 if (fill.filterMode == ProgramDescription::ColorFilterMode::Blend) {
Chris Craikef250742015-02-25 17:16:16 -0800263 const FloatColor& color = fill.filter.color;
Chris Craik117bdbc2015-02-05 10:12:38 -0800264 glUniform4f(mCaches->program().getUniform("colorBlend"),
265 color.r, color.g, color.b, color.a);
Chris Craikb9ce116d2015-08-20 15:14:06 -0700266 } else if (fill.filterMode == ProgramDescription::ColorFilterMode::Matrix) {
Chris Craik117bdbc2015-02-05 10:12:38 -0800267 glUniformMatrix4fv(mCaches->program().getUniform("colorMatrix"), 1, GL_FALSE,
Chris Craikef250742015-02-25 17:16:16 -0800268 fill.filter.matrix.matrix);
Chris Craik117bdbc2015-02-05 10:12:38 -0800269 glUniform4fv(mCaches->program().getUniform("colorMatrixVector"), 1,
Chris Craikef250742015-02-25 17:16:16 -0800270 fill.filter.matrix.vector);
Chris Craik117bdbc2015-02-05 10:12:38 -0800271 }
272
Chris Craik0519c8102015-02-11 13:17:06 -0800273 // Round rect clipping uniforms
274 if (glop.roundRectClipState) {
275 // TODO: avoid query, and cache values (or RRCS ptr) in program
276 const RoundRectClipState* state = glop.roundRectClipState;
277 const Rect& innerRect = state->innerRect;
278 glUniform4f(fill.program->getUniform("roundRectInnerRectLTRB"),
279 innerRect.left, innerRect.top,
280 innerRect.right, innerRect.bottom);
281 glUniformMatrix4fv(fill.program->getUniform("roundRectInvTransform"),
282 1, GL_FALSE, &state->matrix.data[0]);
283
284 // add half pixel to round out integer rect space to cover pixel centers
285 float roundedOutRadius = state->radius + 0.5f;
286 glUniform1f(fill.program->getUniform("roundRectRadius"),
287 roundedOutRadius);
288 }
Chris Craikef250742015-02-25 17:16:16 -0800289
Chris Craik117bdbc2015-02-05 10:12:38 -0800290 // --------------------------------
Chris Craik6c15ffa2015-02-02 13:50:55 -0800291 // ---------- Mesh setup ----------
Chris Craik117bdbc2015-02-05 10:12:38 -0800292 // --------------------------------
293 // vertices
Chris Craikef250742015-02-25 17:16:16 -0800294 const bool force = meshState().bindMeshBufferInternal(vertices.bufferObject)
295 || (vertices.position != nullptr);
296 meshState().bindPositionVertexPointer(force, vertices.position, vertices.stride);
Chris Craik117bdbc2015-02-05 10:12:38 -0800297
298 // indices
Chris Craikef250742015-02-25 17:16:16 -0800299 meshState().bindIndicesBufferInternal(indices.bufferObject);
Chris Craik117bdbc2015-02-05 10:12:38 -0800300
Chris Craik53e51e42015-06-01 10:35:35 -0700301 if (vertices.attribFlags & VertexAttribFlags::TextureCoord) {
Chris Craik26bf3422015-02-26 16:28:17 -0800302 const Glop::Fill::TextureData& texture = fill.texture;
303 // texture always takes slot 0, shader samplers increment from there
Chris Craik0519c8102015-02-11 13:17:06 -0800304 mCaches->textureState().activateTexture(0);
305
Chris Craik26bf3422015-02-26 16:28:17 -0800306 if (texture.clamp != GL_INVALID_ENUM) {
Chris Craik5f1356c2015-05-27 11:06:21 -0700307 texture.texture->setWrap(texture.clamp, true, false, texture.target);
Chris Craik30036092015-02-12 10:41:39 -0800308 }
Chris Craik26bf3422015-02-26 16:28:17 -0800309 if (texture.filter != GL_INVALID_ENUM) {
Chris Craik5f1356c2015-05-27 11:06:21 -0700310 texture.texture->setFilter(texture.filter, true, false, texture.target);
Chris Craik30036092015-02-12 10:41:39 -0800311 }
Chris Craik0519c8102015-02-11 13:17:06 -0800312
Chris Craik26bf3422015-02-26 16:28:17 -0800313 mCaches->textureState().bindTexture(texture.target, texture.texture->id);
Chris Craik0519c8102015-02-11 13:17:06 -0800314 meshState().enableTexCoordsVertexArray();
Chris Craikef250742015-02-25 17:16:16 -0800315 meshState().bindTexCoordsVertexPointer(force, vertices.texCoord, vertices.stride);
Chris Craik26bf3422015-02-26 16:28:17 -0800316
317 if (texture.textureTransform) {
318 glUniformMatrix4fv(fill.program->getUniform("mainTextureTransform"), 1,
319 GL_FALSE, &texture.textureTransform->data[0]);
320 }
Chris Craik6c15ffa2015-02-02 13:50:55 -0800321 } else {
322 meshState().disableTexCoordsVertexArray();
323 }
Chris Craikef250742015-02-25 17:16:16 -0800324 int colorLocation = -1;
Chris Craik53e51e42015-06-01 10:35:35 -0700325 if (vertices.attribFlags & VertexAttribFlags::Color) {
Chris Craikef250742015-02-25 17:16:16 -0800326 colorLocation = fill.program->getAttrib("colors");
327 glEnableVertexAttribArray(colorLocation);
328 glVertexAttribPointer(colorLocation, 4, GL_FLOAT, GL_FALSE, vertices.stride, vertices.color);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800329 }
Chris Craikef250742015-02-25 17:16:16 -0800330 int alphaLocation = -1;
Chris Craik53e51e42015-06-01 10:35:35 -0700331 if (vertices.attribFlags & VertexAttribFlags::Alpha) {
Chris Craikef250742015-02-25 17:16:16 -0800332 // NOTE: alpha vertex position is computed assuming no VBO
333 const void* alphaCoords = ((const GLbyte*) vertices.position) + kVertexAlphaOffset;
334 alphaLocation = fill.program->getAttrib("vtxAlpha");
335 glEnableVertexAttribArray(alphaLocation);
336 glVertexAttribPointer(alphaLocation, 1, GL_FLOAT, GL_FALSE, vertices.stride, alphaCoords);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800337 }
Chris Craik922d3a72015-02-13 17:47:21 -0800338 // Shader uniforms
Chris Craikef250742015-02-25 17:16:16 -0800339 SkiaShader::apply(*mCaches, fill.skiaShaderData);
Chris Craik922d3a72015-02-13 17:47:21 -0800340
Chris Craik117bdbc2015-02-05 10:12:38 -0800341 // ------------------------------------
Chris Craik6c15ffa2015-02-02 13:50:55 -0800342 // ---------- GL state setup ----------
Chris Craik117bdbc2015-02-05 10:12:38 -0800343 // ------------------------------------
Chris Craik03188872015-02-02 18:39:33 -0800344 blend().setFactors(glop.blend.src, glop.blend.dst);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800345
Chris Craik117bdbc2015-02-05 10:12:38 -0800346 // ------------------------------------
Chris Craik2ab95d72015-02-06 15:25:51 -0800347 // ---------- Actual drawing ----------
Chris Craik117bdbc2015-02-05 10:12:38 -0800348 // ------------------------------------
Chris Craikef250742015-02-25 17:16:16 -0800349 if (indices.bufferObject == meshState().getQuadListIBO()) {
Chris Craik2ab95d72015-02-06 15:25:51 -0800350 // Since the indexed quad list is of limited length, we loop over
351 // the glDrawXXX method while updating the vertex pointer
Chris Craik0519c8102015-02-11 13:17:06 -0800352 GLsizei elementsCount = mesh.elementCount;
Chris Craikef250742015-02-25 17:16:16 -0800353 const GLbyte* vertexData = static_cast<const GLbyte*>(vertices.position);
Chris Craik2ab95d72015-02-06 15:25:51 -0800354 while (elementsCount > 0) {
Chris Craik9db58c02015-08-19 15:19:18 -0700355 GLsizei drawCount = std::min(elementsCount, (GLsizei) kMaxNumberOfQuads * 6);
Chris Craik2ab95d72015-02-06 15:25:51 -0800356
Chris Craikf27133d2015-02-19 09:51:53 -0800357 // rebind pointers without forcing, since initial bind handled above
Chris Craikef250742015-02-25 17:16:16 -0800358 meshState().bindPositionVertexPointer(false, vertexData, vertices.stride);
Chris Craik53e51e42015-06-01 10:35:35 -0700359 if (vertices.attribFlags & VertexAttribFlags::TextureCoord) {
Chris Craikf27133d2015-02-19 09:51:53 -0800360 meshState().bindTexCoordsVertexPointer(false,
Chris Craikef250742015-02-25 17:16:16 -0800361 vertexData + kMeshTextureOffset, vertices.stride);
Chris Craikf27133d2015-02-19 09:51:53 -0800362 }
363
Chris Craik2ab95d72015-02-06 15:25:51 -0800364 glDrawElements(mesh.primitiveMode, drawCount, GL_UNSIGNED_SHORT, nullptr);
365 elementsCount -= drawCount;
Chris Craikef250742015-02-25 17:16:16 -0800366 vertexData += (drawCount / 6) * 4 * vertices.stride;
Chris Craik2ab95d72015-02-06 15:25:51 -0800367 }
Chris Craikef250742015-02-25 17:16:16 -0800368 } else if (indices.bufferObject || indices.indices) {
369 glDrawElements(mesh.primitiveMode, mesh.elementCount, GL_UNSIGNED_SHORT, indices.indices);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800370 } else {
Chris Craik0519c8102015-02-11 13:17:06 -0800371 glDrawArrays(mesh.primitiveMode, 0, mesh.elementCount);
Chris Craik6c15ffa2015-02-02 13:50:55 -0800372 }
Chris Craik117bdbc2015-02-05 10:12:38 -0800373
Chris Craik2ab95d72015-02-06 15:25:51 -0800374 // -----------------------------------
375 // ---------- Mesh teardown ----------
376 // -----------------------------------
Chris Craik53e51e42015-06-01 10:35:35 -0700377 if (vertices.attribFlags & VertexAttribFlags::Alpha) {
Chris Craikef250742015-02-25 17:16:16 -0800378 glDisableVertexAttribArray(alphaLocation);
379 }
Chris Craik53e51e42015-06-01 10:35:35 -0700380 if (vertices.attribFlags & VertexAttribFlags::Color) {
Chris Craikef250742015-02-25 17:16:16 -0800381 glDisableVertexAttribArray(colorLocation);
Chris Craik117bdbc2015-02-05 10:12:38 -0800382 }
383}
384
385void RenderState::dump() {
386 blend().dump();
387 meshState().dump();
388 scissor().dump();
389 stencil().dump();
Chris Craik6c15ffa2015-02-02 13:50:55 -0800390}
391
John Reck3b202512014-06-23 13:13:08 -0700392} /* namespace uirenderer */
393} /* namespace android */