blob: e764778ab72518fbb0077b2d97dcf1e0816dc592 [file] [log] [blame]
Romain Guye4d01122010-06-16 18:44:05 -07001/*
2 * Copyright (C) 2010 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 */
16
Romain Guy85bf02f2010-06-22 13:11:24 -070017#define LOG_TAG "OpenGLRenderer"
Romain Guye4d01122010-06-16 18:44:05 -070018
19#include <stdlib.h>
20#include <stdint.h>
21#include <sys/types.h>
22
Romain Guy5cbbce52010-06-27 22:59:20 -070023#include <SkCanvas.h>
24
Romain Guye4d01122010-06-16 18:44:05 -070025#include <utils/Log.h>
26
Romain Guy85bf02f2010-06-22 13:11:24 -070027#include "OpenGLRenderer.h"
Romain Guye4d01122010-06-16 18:44:05 -070028
29namespace android {
Romain Guy9d5316e2010-06-24 19:30:36 -070030namespace uirenderer {
31
32///////////////////////////////////////////////////////////////////////////////
33// Defines
34///////////////////////////////////////////////////////////////////////////////
35
Romain Guybd6b79b2010-06-26 00:13:53 -070036#define SV(x, y) { { x, y } }
37#define FV(x, y, u, v) { { x, y }, { u, v } }
Romain Guy9d5316e2010-06-24 19:30:36 -070038
39///////////////////////////////////////////////////////////////////////////////
40// Globals
41///////////////////////////////////////////////////////////////////////////////
42
Romain Guyc7d53492010-06-25 13:41:57 -070043const SimpleVertex gDrawColorVertices[] = {
Romain Guybd6b79b2010-06-26 00:13:53 -070044 SV(0.0f, 0.0f),
45 SV(1.0f, 0.0f),
46 SV(0.0f, 1.0f),
47 SV(1.0f, 1.0f)
Romain Guy9d5316e2010-06-24 19:30:36 -070048};
Romain Guyc7d53492010-06-25 13:41:57 -070049const GLsizei gDrawColorVertexStride = sizeof(SimpleVertex);
50const GLsizei gDrawColorVertexCount = 4;
Romain Guy9d5316e2010-06-24 19:30:36 -070051
Romain Guy5cbbce52010-06-27 22:59:20 -070052TextureVertex gDrawTextureVertices[] = {
Romain Guybd6b79b2010-06-26 00:13:53 -070053 FV(0.0f, 0.0f, 0.0f, 1.0f),
54 FV(1.0f, 0.0f, 1.0f, 1.0f),
55 FV(0.0f, 1.0f, 0.0f, 0.0f),
56 FV(1.0f, 1.0f, 1.0f, 0.0f)
57};
58const GLsizei gDrawTextureVertexStride = sizeof(TextureVertex);
59const GLsizei gDrawTextureVertexCount = 4;
60
Romain Guy5cbbce52010-06-27 22:59:20 -070061static inline void resetDrawTextureTexCoords(float u1, float v1, float u2, float v2) {
62 gDrawTextureVertices[0].texture[0] = u1;
63 gDrawTextureVertices[0].texture[1] = v2;
64 gDrawTextureVertices[1].texture[0] = u2;
65 gDrawTextureVertices[1].texture[1] = v2;
66 gDrawTextureVertices[2].texture[0] = u1;
67 gDrawTextureVertices[2].texture[1] = v1;
68 gDrawTextureVertices[3].texture[0] = u2;
69 gDrawTextureVertices[3].texture[1] = v1;
Romain Guy9d5316e2010-06-24 19:30:36 -070070}
Romain Guye4d01122010-06-16 18:44:05 -070071
Romain Guyf6a11b82010-06-23 17:47:49 -070072///////////////////////////////////////////////////////////////////////////////
73// Constructors/destructor
74///////////////////////////////////////////////////////////////////////////////
75
Romain Guy85bf02f2010-06-22 13:11:24 -070076OpenGLRenderer::OpenGLRenderer() {
77 LOGD("Create OpenGLRenderer");
Romain Guy9d5316e2010-06-24 19:30:36 -070078
79 mDrawColorShader = new DrawColorProgram;
Romain Guybd6b79b2010-06-26 00:13:53 -070080 mDrawTextureShader = new DrawTextureProgram;
Romain Guye4d01122010-06-16 18:44:05 -070081}
82
Romain Guy85bf02f2010-06-22 13:11:24 -070083OpenGLRenderer::~OpenGLRenderer() {
84 LOGD("Destroy OpenGLRenderer");
Romain Guye4d01122010-06-16 18:44:05 -070085}
86
Romain Guyf6a11b82010-06-23 17:47:49 -070087///////////////////////////////////////////////////////////////////////////////
88// Setup
89///////////////////////////////////////////////////////////////////////////////
90
Romain Guy85bf02f2010-06-22 13:11:24 -070091void OpenGLRenderer::setViewport(int width, int height) {
Romain Guy08ae3172010-06-21 19:35:50 -070092 glViewport(0, 0, width, height);
93
94 mat4 ortho;
Romain Guyc7d53492010-06-25 13:41:57 -070095 ortho.loadOrtho(0, width, height, 0, -1, 1);
Romain Guy08ae3172010-06-21 19:35:50 -070096 ortho.copyTo(mOrthoMatrix);
Romain Guybb9524b2010-06-22 18:56:38 -070097
98 mWidth = width;
99 mHeight = height;
Romain Guye4d01122010-06-16 18:44:05 -0700100}
101
Romain Guy85bf02f2010-06-22 13:11:24 -0700102void OpenGLRenderer::prepare() {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700103 mSnapshot = &mFirstSnapshot;
104 mSaveCount = 0;
Romain Guyf6a11b82010-06-23 17:47:49 -0700105
Romain Guy08ae3172010-06-21 19:35:50 -0700106 glDisable(GL_SCISSOR_TEST);
Romain Guybb9524b2010-06-22 18:56:38 -0700107
Romain Guy08ae3172010-06-21 19:35:50 -0700108 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
109 glClear(GL_COLOR_BUFFER_BIT);
Romain Guybb9524b2010-06-22 18:56:38 -0700110
Romain Guy08ae3172010-06-21 19:35:50 -0700111 glEnable(GL_SCISSOR_TEST);
Romain Guyc7d53492010-06-25 13:41:57 -0700112 glScissor(0, 0, mWidth, mHeight);
Romain Guyf6a11b82010-06-23 17:47:49 -0700113
Romain Guybb9524b2010-06-22 18:56:38 -0700114 mSnapshot->clipRect.set(0.0f, 0.0f, mWidth, mHeight);
115}
116
Romain Guyf6a11b82010-06-23 17:47:49 -0700117///////////////////////////////////////////////////////////////////////////////
118// State management
119///////////////////////////////////////////////////////////////////////////////
120
Romain Guybb9524b2010-06-22 18:56:38 -0700121int OpenGLRenderer::getSaveCount() const {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700122 return mSaveCount;
Romain Guybb9524b2010-06-22 18:56:38 -0700123}
124
125int OpenGLRenderer::save(int flags) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700126 return saveSnapshot();
Romain Guybb9524b2010-06-22 18:56:38 -0700127}
128
129void OpenGLRenderer::restore() {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700130 if (mSaveCount == 0) return;
Romain Guybb9524b2010-06-22 18:56:38 -0700131
Romain Guy7ae7ac42010-06-25 13:46:18 -0700132 if (restoreSnapshot()) {
133 setScissorFromClip();
134 }
Romain Guybb9524b2010-06-22 18:56:38 -0700135}
136
137void OpenGLRenderer::restoreToCount(int saveCount) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700138 if (saveCount <= 0 || saveCount > mSaveCount) return;
Romain Guybb9524b2010-06-22 18:56:38 -0700139
Romain Guy7ae7ac42010-06-25 13:46:18 -0700140 bool restoreClip = false;
Romain Guybb9524b2010-06-22 18:56:38 -0700141
Romain Guy7ae7ac42010-06-25 13:46:18 -0700142 while (mSaveCount != saveCount - 1) {
143 restoreClip |= restoreSnapshot();
144 }
Romain Guybb9524b2010-06-22 18:56:38 -0700145
Romain Guy7ae7ac42010-06-25 13:46:18 -0700146 if (restoreClip) {
147 setScissorFromClip();
148 }
Romain Guybb9524b2010-06-22 18:56:38 -0700149}
150
151int OpenGLRenderer::saveSnapshot() {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700152 mSnapshot = new Snapshot(mSnapshot);
153 return ++mSaveCount;
Romain Guybb9524b2010-06-22 18:56:38 -0700154}
155
156bool OpenGLRenderer::restoreSnapshot() {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700157 bool restoreClip = mSnapshot->flags & Snapshot::kFlagClipSet;
Romain Guybd6b79b2010-06-26 00:13:53 -0700158 bool restoreLayer = mSnapshot->flags & Snapshot::kFlagIsLayer;
Romain Guybb9524b2010-06-22 18:56:38 -0700159
Romain Guybd6b79b2010-06-26 00:13:53 -0700160 sp<Snapshot> current = mSnapshot;
161 sp<Snapshot> previous = mSnapshot->previous;
162
163 if (restoreLayer) {
164 // Unbind current FBO and restore previous one
165 // Most of the time, previous->fbo will be 0 to bind the default buffer
166 glBindFramebuffer(GL_FRAMEBUFFER, previous->fbo);
167
Romain Guy5cbbce52010-06-27 22:59:20 -0700168 // Restore the clip from the previous snapshot
169 const Rect& clip = previous->getMappedClip();
170 glScissor(clip.left, mHeight - clip.bottom, clip.getWidth(), clip.getHeight());
Romain Guybd6b79b2010-06-26 00:13:53 -0700171
Romain Guy5cbbce52010-06-27 22:59:20 -0700172 // Compute the correct texture coordinates for the FBO texture
173 // The texture is currently as big as the window but drawn with
174 // a quad of the appropriate size
175 const Rect& layer = current->layer;
176 Rect texCoords(current->layer);
177 mSnapshot->transform.mapRect(texCoords);
178
179 const float u1 = texCoords.left / float(mWidth);
180 const float v1 = (mHeight - texCoords.top) / float(mHeight);
181 const float u2 = texCoords.right / float(mWidth);
182 const float v2 = (mHeight - texCoords.bottom) / float(mHeight);
183
184 resetDrawTextureTexCoords(u1, v1, u2, v1);
185
186 drawTextureRect(layer.left, layer.top, layer.right, layer.bottom,
187 current->texture, current->alpha);
188
189 resetDrawTextureTexCoords(0.0f, 1.0f, 1.0f, 0.0f);
Romain Guybd6b79b2010-06-26 00:13:53 -0700190
191 glDeleteFramebuffers(1, &current->fbo);
192 glDeleteTextures(1, &current->texture);
193 }
194
195 mSnapshot = previous;
Romain Guy7ae7ac42010-06-25 13:46:18 -0700196 mSaveCount--;
Romain Guyf6a11b82010-06-23 17:47:49 -0700197
Romain Guy7ae7ac42010-06-25 13:46:18 -0700198 return restoreClip;
Romain Guybb9524b2010-06-22 18:56:38 -0700199}
200
Romain Guyf6a11b82010-06-23 17:47:49 -0700201///////////////////////////////////////////////////////////////////////////////
Romain Guybd6b79b2010-06-26 00:13:53 -0700202// Layers
203///////////////////////////////////////////////////////////////////////////////
204
205int OpenGLRenderer::saveLayer(float left, float top, float right, float bottom,
206 const SkPaint* p, int flags) {
207 // TODO Implement
208 return saveSnapshot();
209}
210
211int OpenGLRenderer::saveLayerAlpha(float left, float top, float right, float bottom,
212 int alpha, int flags) {
213 int count = saveSnapshot();
214
215 mSnapshot->flags |= Snapshot::kFlagIsLayer;
216 mSnapshot->alpha = alpha / 255.0f;
217 mSnapshot->layer.set(left, top, right, bottom);
218
219 // Generate the FBO and attach the texture
220 glGenFramebuffers(1, &mSnapshot->fbo);
221 glBindFramebuffer(GL_FRAMEBUFFER, mSnapshot->fbo);
222
223 // Generate the texture in which the FBO will draw
224 glGenTextures(1, &mSnapshot->texture);
225 glBindTexture(GL_TEXTURE_2D, mSnapshot->texture);
226
227 // The FBO will not be scaled, so we can use lower quality filtering
228 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
229 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
Romain Guy5cbbce52010-06-27 22:59:20 -0700230 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
231 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
Romain Guybd6b79b2010-06-26 00:13:53 -0700232
233 // TODO ***** IMPORTANT *****
234 // Creating a texture-backed FBO works only if the texture is the same size
235 // as the original rendering buffer (in this case, mWidth and mHeight.)
236 // This is expensive and wasteful and must be fixed.
Romain Guy5cbbce52010-06-27 22:59:20 -0700237 // TODO Additionally we should use an FBO cache
Romain Guybd6b79b2010-06-26 00:13:53 -0700238
239 const GLsizei width = mWidth; //right - left;
240 const GLsizei height = mHeight; //bottom - right;
241
242 const GLint format = (flags & SkCanvas::kHasAlphaLayer_SaveFlag) ? GL_RGBA : GL_RGB;
243 glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, NULL);
244 glBindTexture(GL_TEXTURE_2D, 0);
245
246 // Bind texture to FBO
247 glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
248 mSnapshot->texture, 0);
249
250 GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
251 if (status != GL_FRAMEBUFFER_COMPLETE) {
252 LOGD("Framebuffer incomplete %d", status);
253
254 glDeleteFramebuffers(1, &mSnapshot->fbo);
255 glDeleteTextures(1, &mSnapshot->texture);
256 }
257
258 return count;
259}
260
261///////////////////////////////////////////////////////////////////////////////
Romain Guyf6a11b82010-06-23 17:47:49 -0700262// Transforms
263///////////////////////////////////////////////////////////////////////////////
264
265void OpenGLRenderer::translate(float dx, float dy) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700266 mSnapshot->transform.translate(dx, dy, 0.0f);
267 mSnapshot->flags |= Snapshot::kFlagDirtyTransform;
Romain Guyf6a11b82010-06-23 17:47:49 -0700268}
269
270void OpenGLRenderer::rotate(float degrees) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700271 mSnapshot->transform.rotate(degrees, 0.0f, 0.0f, 1.0f);
272 mSnapshot->flags |= Snapshot::kFlagDirtyTransform;
Romain Guyf6a11b82010-06-23 17:47:49 -0700273}
274
275void OpenGLRenderer::scale(float sx, float sy) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700276 mSnapshot->transform.scale(sx, sy, 1.0f);
277 mSnapshot->flags |= Snapshot::kFlagDirtyTransform;
Romain Guyf6a11b82010-06-23 17:47:49 -0700278}
279
280void OpenGLRenderer::setMatrix(SkMatrix* matrix) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700281 mSnapshot->transform.load(*matrix);
282 mSnapshot->flags |= Snapshot::kFlagDirtyTransform;
Romain Guyf6a11b82010-06-23 17:47:49 -0700283}
284
285void OpenGLRenderer::getMatrix(SkMatrix* matrix) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700286 mSnapshot->transform.copyTo(*matrix);
Romain Guyf6a11b82010-06-23 17:47:49 -0700287}
288
289void OpenGLRenderer::concatMatrix(SkMatrix* matrix) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700290 mat4 m(*matrix);
291 mSnapshot->transform.multiply(m);
292 mSnapshot->flags |= Snapshot::kFlagDirtyTransform;
Romain Guyf6a11b82010-06-23 17:47:49 -0700293}
294
295///////////////////////////////////////////////////////////////////////////////
296// Clipping
297///////////////////////////////////////////////////////////////////////////////
298
Romain Guybb9524b2010-06-22 18:56:38 -0700299void OpenGLRenderer::setScissorFromClip() {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700300 const Rect& clip = mSnapshot->getMappedClip();
301 glScissor(clip.left, mHeight - clip.bottom, clip.getWidth(), clip.getHeight());
Romain Guy9d5316e2010-06-24 19:30:36 -0700302}
303
304const Rect& OpenGLRenderer::getClipBounds() {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700305 return mSnapshot->clipRect;
Romain Guybb9524b2010-06-22 18:56:38 -0700306}
307
Romain Guyc7d53492010-06-25 13:41:57 -0700308bool OpenGLRenderer::quickReject(float left, float top, float right, float bottom) {
309 /*
310 * The documentation of quickReject() indicates that the specified rect
311 * is transformed before being compared to the clip rect. However, the
312 * clip rect is not stored transformed in the snapshot and can thus be
313 * compared directly
314 *
315 * The following code can be used instead to performed a mapped comparison:
316 *
317 * mSnapshot->transform.mapRect(r);
318 * const Rect& clip = mSnapshot->getMappedClip();
319 * return !clip.intersects(r);
320 */
Romain Guyc7d53492010-06-25 13:41:57 -0700321 Rect r(left, top, right, bottom);
322 return !mSnapshot->clipRect.intersects(r);
323}
324
Romain Guybb9524b2010-06-22 18:56:38 -0700325bool OpenGLRenderer::clipRect(float left, float top, float right, float bottom) {
Romain Guy7ae7ac42010-06-25 13:46:18 -0700326 bool clipped = mSnapshot->clipRect.intersect(left, top, right, bottom);
327 if (clipped) {
328 mSnapshot->flags |= Snapshot::kFlagClipSet;
329 setScissorFromClip();
330 }
331 return clipped;
Romain Guye4d01122010-06-16 18:44:05 -0700332}
333
Romain Guyf6a11b82010-06-23 17:47:49 -0700334///////////////////////////////////////////////////////////////////////////////
335// Drawing
336///////////////////////////////////////////////////////////////////////////////
337
Romain Guy85bf02f2010-06-22 13:11:24 -0700338void OpenGLRenderer::drawColor(int color, SkXfermode::Mode mode) {
Romain Guyc7d53492010-06-25 13:41:57 -0700339 // TODO: Set the transfer mode
340 const Rect& clip = mSnapshot->clipRect;
341 drawColorRect(clip.left, clip.top, clip.right, clip.bottom, color);
342}
Romain Guy9d5316e2010-06-24 19:30:36 -0700343
Romain Guybd6b79b2010-06-26 00:13:53 -0700344void OpenGLRenderer::drawRect(float left, float top, float right, float bottom, const SkPaint* p) {
Romain Guyc7d53492010-06-25 13:41:57 -0700345 // TODO Support more than just color
346 // TODO: Set the transfer mode
Romain Guybd6b79b2010-06-26 00:13:53 -0700347 drawColorRect(left, top, right, bottom, p->getColor());
Romain Guyc7d53492010-06-25 13:41:57 -0700348}
Romain Guy9d5316e2010-06-24 19:30:36 -0700349
Romain Guyc7d53492010-06-25 13:41:57 -0700350void OpenGLRenderer::drawColorRect(float left, float top, float right, float bottom, int color) {
351 GLfloat a = ((color >> 24) & 0xFF) / 255.0f;
352 GLfloat r = ((color >> 16) & 0xFF) / 255.0f;
353 GLfloat g = ((color >> 8) & 0xFF) / 255.0f;
354 GLfloat b = ((color ) & 0xFF) / 255.0f;
Romain Guy9d5316e2010-06-24 19:30:36 -0700355
Romain Guyc7d53492010-06-25 13:41:57 -0700356 mModelView.loadTranslate(left, top, 0.0f);
357 mModelView.scale(right - left, bottom - top, 1.0f);
Romain Guy9d5316e2010-06-24 19:30:36 -0700358
Romain Guyc7d53492010-06-25 13:41:57 -0700359 mDrawColorShader->use(&mOrthoMatrix[0], &mModelView.data[0], &mSnapshot->transform.data[0]);
Romain Guy9d5316e2010-06-24 19:30:36 -0700360
Romain Guyc7d53492010-06-25 13:41:57 -0700361 const GLvoid* p = &gDrawColorVertices[0].position[0];
Romain Guy9d5316e2010-06-24 19:30:36 -0700362
Romain Guyc7d53492010-06-25 13:41:57 -0700363 glEnableVertexAttribArray(mDrawColorShader->position);
364 glVertexAttribPointer(mDrawColorShader->position, 2, GL_FLOAT, GL_FALSE,
365 gDrawColorVertexStride, p);
366 glVertexAttrib4f(mDrawColorShader->color, r, g, b, a);
Romain Guy9d5316e2010-06-24 19:30:36 -0700367
Romain Guyc7d53492010-06-25 13:41:57 -0700368 glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawColorVertexCount);
Romain Guy9d5316e2010-06-24 19:30:36 -0700369
Romain Guyc7d53492010-06-25 13:41:57 -0700370 glDisableVertexAttribArray(mDrawColorShader->position);
Romain Guy85bf02f2010-06-22 13:11:24 -0700371}
372
Romain Guybd6b79b2010-06-26 00:13:53 -0700373void OpenGLRenderer::drawTextureRect(float left, float top, float right, float bottom,
374 GLuint texture, float alpha) {
375 mModelView.loadTranslate(left, top, 0.0f);
376 mModelView.scale(right - left, bottom - top, 1.0f);
377
378 mDrawTextureShader->use(&mOrthoMatrix[0], &mModelView.data[0], &mSnapshot->transform.data[0]);
379
Romain Guy5cbbce52010-06-27 22:59:20 -0700380 // TODO Correctly set the blend function, based on texture format and xfermode
Romain Guybd6b79b2010-06-26 00:13:53 -0700381 glEnable(GL_BLEND);
382 glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
383
384 glBindTexture(GL_TEXTURE_2D, texture);
385
386 glActiveTexture(GL_TEXTURE0);
387 glUniform1i(mDrawTextureShader->sampler, 0);
388
389 const GLvoid* p = &gDrawTextureVertices[0].position[0];
390 const GLvoid* t = &gDrawTextureVertices[0].texture[0];
391
392 glEnableVertexAttribArray(mDrawTextureShader->position);
393 glVertexAttribPointer(mDrawTextureShader->position, 2, GL_FLOAT, GL_FALSE,
394 gDrawTextureVertexStride, p);
395
396 glEnableVertexAttribArray(mDrawTextureShader->texCoords);
397 glVertexAttribPointer(mDrawTextureShader->texCoords, 2, GL_FLOAT, GL_FALSE,
398 gDrawTextureVertexStride, t);
399
400 glVertexAttrib4f(mDrawTextureShader->color, 1.0f, 1.0f, 1.0f, alpha);
401
402 glDrawArrays(GL_TRIANGLE_STRIP, 0, gDrawTextureVertexCount);
403
404 glDisableVertexAttribArray(mDrawTextureShader->position);
405 glDisableVertexAttribArray(mDrawTextureShader->texCoords);
406
407 glBindTexture(GL_TEXTURE_2D, 0);
408 glDisable(GL_BLEND);
409}
410
Romain Guy9d5316e2010-06-24 19:30:36 -0700411}; // namespace uirenderer
Romain Guye4d01122010-06-16 18:44:05 -0700412}; // namespace android