OpenGLRenderer.h revision 8ba548f81d1ab5f1750cbf86098c4a14e0b8bead
1e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy/* 2e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Copyright (C) 2010 The Android Open Source Project 3e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 4e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Licensed under the Apache License, Version 2.0 (the "License"); 5e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * you may not use this file except in compliance with the License. 6e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * You may obtain a copy of the License at 7e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 8e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * http://www.apache.org/licenses/LICENSE-2.0 9e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * 10e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * Unless required by applicable law or agreed to in writing, software 11e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * distributed under the License is distributed on an "AS IS" BASIS, 12e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * See the License for the specific language governing permissions and 14e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy * limitations under the License. 15e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy */ 16e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 179d5316e3f56d138504565ff311145ac01621dff4Romain Guy#ifndef ANDROID_UI_OPENGL_RENDERER_H 189d5316e3f56d138504565ff311145ac01621dff4Romain Guy#define ANDROID_UI_OPENGL_RENDERER_H 199d5316e3f56d138504565ff311145ac01621dff4Romain Guy 209d5316e3f56d138504565ff311145ac01621dff4Romain Guy#include <GLES2/gl2.h> 219d5316e3f56d138504565ff311145ac01621dff4Romain Guy#include <GLES2/gl2ext.h> 2285bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy 23ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include <SkBitmap.h> 24f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy#include <SkMatrix.h> 25ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include <SkPaint.h> 2685bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy#include <SkXfermode.h> 27e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 28bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy#include <utils/RefBase.h> 29bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 30f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy#include "Matrix.h" 315cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Program.h" 32bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy#include "Rect.h" 335cbbce535744b89df5ecea95de21ee3733298260Romain Guy#include "Snapshot.h" 34ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include "Texture.h" 35ce0537b80087a6225273040a987414b1dd081aa0Romain Guy#include "TextureCache.h" 36bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 37e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guynamespace android { 389d5316e3f56d138504565ff311145ac01621dff4Romain Guynamespace uirenderer { 39e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 40f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy/////////////////////////////////////////////////////////////////////////////// 41f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy// Support 42f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy/////////////////////////////////////////////////////////////////////////////// 43f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 445cbbce535744b89df5ecea95de21ee3733298260Romain Guy/** 455cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Simple structure to describe a vertex with a position. 465cbbce535744b89df5ecea95de21ee3733298260Romain Guy * This is used to draw filled rectangles without a texture. 475cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 48c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guystruct SimpleVertex { 497ae7ac48aa2b53453c9805075171ecd5bcafd7deRomain Guy float position[2]; 50c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy}; // struct SimpleVertex 519d5316e3f56d138504565ff311145ac01621dff4Romain Guy 525cbbce535744b89df5ecea95de21ee3733298260Romain Guy/** 535cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Simple structure to describe a vertex with a position and a texture. 545cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 55bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guystruct TextureVertex { 56bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy float position[2]; 57bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy float texture[2]; 58bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy}; // struct TextureVertex 599d5316e3f56d138504565ff311145ac01621dff4Romain Guy 60026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy/** 61026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * Structure mapping Skia xfermodes to OpenGL blending factors. 62026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy */ 63026c5e16704e817cac7d9c382914c947e34f87e0Romain Guystruct Blender { 64026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy SkXfermode::Mode mode; 65026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy GLenum src; 66026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy GLenum dst; 67026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy}; // struct Blender 68026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy 69f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy/////////////////////////////////////////////////////////////////////////////// 70f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy// Renderer 71f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy/////////////////////////////////////////////////////////////////////////////// 72f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 735cbbce535744b89df5ecea95de21ee3733298260Romain Guy/** 745cbbce535744b89df5ecea95de21ee3733298260Romain Guy * OpenGL renderer used to draw accelerated 2D graphics. The API is a 755cbbce535744b89df5ecea95de21ee3733298260Romain Guy * simplified version of Skia's Canvas API. 765cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 7785bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guyclass OpenGLRenderer { 78e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guypublic: 7985bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy OpenGLRenderer(); 8085bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy ~OpenGLRenderer(); 81e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 82e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy void setViewport(int width, int height); 83e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy void prepare(); 8408ae317c21ec3086b5017672bba87420cc38a407Romain Guy 85bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy int getSaveCount() const; 86bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy int save(int flags); 87bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy void restore(); 88bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy void restoreToCount(int saveCount); 89bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 90bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy int saveLayer(float left, float top, float right, float bottom, const SkPaint* p, int flags); 91bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy int saveLayerAlpha(float left, float top, float right, float bottom, int alpha, int flags); 92bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy 93f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy void translate(float dx, float dy); 94f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy void rotate(float degrees); 95f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy void scale(float sx, float sy); 96f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 97f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy void setMatrix(SkMatrix* matrix); 98f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy void getMatrix(SkMatrix* matrix); 99f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy void concatMatrix(SkMatrix* matrix); 100f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy 1019d5316e3f56d138504565ff311145ac01621dff4Romain Guy const Rect& getClipBounds(); 102c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy bool quickReject(float left, float top, float right, float bottom); 103bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy bool clipRect(float left, float top, float right, float bottom); 104bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 105c1396e93b6a5286a5183c00c781b62e940a12c1fRomain Guy void drawBitmap(SkBitmap* bitmap, float left, float top, const SkPaint* paint); 1068ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy void drawBitmap(SkBitmap* bitmap, float srcLeft, float srcTop, float srcRight, float srcBottom, 1078ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy float dstLeft, float dstTop, float dstRight, float dstBottom, 1088ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy const SkMatrix* matrix, const SkPaint* paint); 10985bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy void drawColor(int color, SkXfermode::Mode mode); 110bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy void drawRect(float left, float top, float right, float bottom, const SkPaint* paint); 11185bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy 11208ae317c21ec3086b5017672bba87420cc38a407Romain Guyprivate: 1135cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 1145cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Saves the current state of the renderer as a new snapshot. 1155cbbce535744b89df5ecea95de21ee3733298260Romain Guy * The new snapshot is saved in mSnapshot and the previous snapshot 1165cbbce535744b89df5ecea95de21ee3733298260Romain Guy * is linked from mSnapshot->previous. 1175cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 1185cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @return The new save count. This value can be passed to #restoreToCount() 1195cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 120bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy int saveSnapshot(); 1215cbbce535744b89df5ecea95de21ee3733298260Romain Guy 1225cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 1235cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Restores the current snapshot; mSnapshot becomes mSnapshot->previous. 1245cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 1255cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @return True if the clip should be also reapplied by calling 1265cbbce535744b89df5ecea95de21ee3733298260Romain Guy * #setScissorFromClip(). 1275cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 128bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy bool restoreSnapshot(); 129bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 1305cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 1315cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Sets the clipping rectangle using glScissor. The clip is defined by 1325cbbce535744b89df5ecea95de21ee3733298260Romain Guy * the current snapshot's clipRect member. 1335cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 134bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy void setScissorFromClip(); 135bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 1365cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 137d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * Compose the layer defined in the current snapshot with the layer 138d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * defined by the previous snapshot. 139d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * 140d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * The current snapshot *must* be a layer (flag kFlagIsLayer set.) 141d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * 142d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param curent The current snapshot containing the layer to compose 143d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param previous The previous snapshot to compose the current layer with 144d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy */ 145d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy void composeLayer(sp<Snapshot> current, sp<Snapshot> previous); 146d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy 147d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy /** 148d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * Creates a new layer stored in the specified snapshot. 149d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * 150d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param snapshot The snapshot associated with the new layer 151d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param left The left coordinate of the layer 152d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param top The top coordinate of the layer 153d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param right The right coordinate of the layer 154d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param bottom The bottom coordinate of the layer 155d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param alpha The translucency of the layer 156d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param mode The blending mode of the layer 157d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param flags The layer save flags 158d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * 159d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @return True if the layer was successfully created, false otherwise 160d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy */ 161d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy bool createLayer(sp<Snapshot> snapshot, float left, float top, float right, float bottom, 162d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy int alpha, SkXfermode::Mode mode, int flags); 163d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy 164d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy /** 1655cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Draws a colored rectangle with the specified color. The specified coordinates 1665cbbce535744b89df5ecea95de21ee3733298260Romain Guy * are transformed by the current snapshot's transform matrix. 1675cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 1685cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param left The left coordinate of the rectangle 1695cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param top The top coordinate of the rectangle 1705cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param right The right coordinate of the rectangle 1715cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param bottom The bottom coordinate of the rectangle 1725cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param color The rectangle's ARGB color, defined as a packed 32 bits word 173026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param mode The Skia xfermode to use 1745cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 175026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy void drawColorRect(float left, float top, float right, float bottom, 176026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy int color, SkXfermode::Mode mode); 1775cbbce535744b89df5ecea95de21ee3733298260Romain Guy 1785cbbce535744b89df5ecea95de21ee3733298260Romain Guy /** 1795cbbce535744b89df5ecea95de21ee3733298260Romain Guy * Draws a textured rectangle with the specified texture. The specified coordinates 1805cbbce535744b89df5ecea95de21ee3733298260Romain Guy * are transformed by the current snapshot's transform matrix. 1815cbbce535744b89df5ecea95de21ee3733298260Romain Guy * 1825cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param left The left coordinate of the rectangle 1835cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param top The top coordinate of the rectangle 1845cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param right The right coordinate of the rectangle 1855cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param bottom The bottom coordinate of the rectangle 1865cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param texture The texture name to map onto the rectangle 1875cbbce535744b89df5ecea95de21ee3733298260Romain Guy * @param alpha An additional translucency parameter, between 0.0f and 1.0f 188d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param mode The blending mode 189c1396e93b6a5286a5183c00c781b62e940a12c1fRomain Guy * @param blend True if the texture contains an alpha channel 190d55a86120dd1e8ebcc6906c9ffd463f7460348daRomain Guy * @param isPremultiplied Indicates whether the texture has premultiplied alpha 1915cbbce535744b89df5ecea95de21ee3733298260Romain Guy */ 192bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy void drawTextureRect(float left, float top, float right, float bottom, GLuint texture, 193c1396e93b6a5286a5183c00c781b62e940a12c1fRomain Guy float alpha, SkXfermode::Mode mode, bool blend, bool isPremultiplied = false); 194c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 195026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy /** 196026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * Resets the texture coordinates stored in mDrawTextureVertices. Setting the values 197026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * back to default is achieved by calling: 198026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * 1998ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * resetDrawTextureTexCoords(0.0f, 0.0f, 1.0f, 1.0f); 200026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * 201026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param u1 The left coordinate of the texture 202026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param v1 The bottom coordinate of the texture 203026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param u2 The right coordinate of the texture 204026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy * @param v2 The top coordinate of the texture 205026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy */ 206026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy void resetDrawTextureTexCoords(float u1, float v1, float u2, float v2); 207026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy 2088ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy /** 2098ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * Gets the alpha and xfermode out of a paint object. If the paint is null 2108ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * alpha will be 255 and the xfermode will be SRC_OVER. 2118ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * 2128ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * @param paint The paint to extract values from 2138ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * @param alpha Where to store the resulting alpha 2148ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy * @param mode Where to store the resulting xfermode 2158ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy */ 2168ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy inline void getAlphaAndMode(const SkPaint* paint, int* alpha, SkXfermode::Mode* mode); 2178ba548f81d1ab5f1750cbf86098c4a14e0b8beadRomain Guy 218bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy // Dimensions of the drawing surface 219bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy int mWidth, mHeight; 220bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 22185bf02fc16784d935fb9eebfa9cb20fe46ff7951Romain Guy // Matrix used for ortho projection in shaders 22208ae317c21ec3086b5017672bba87420cc38a407Romain Guy float mOrthoMatrix[16]; 223bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy 224c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy // Model-view matrix used to position/size objects 225c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy mat4 mModelView; 226c7d53494f1fbd9f9d74af89053ff9fdb1ccbac6cRomain Guy 227bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy // Number of saved states 228bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy int mSaveCount; 229f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy // Base state 230f6a11b8a9e25ff9861bbba19251bea84d8a5daf2Romain Guy Snapshot mFirstSnapshot; 231bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy // Current state 232bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy sp<Snapshot> mSnapshot; 2339d5316e3f56d138504565ff311145ac01621dff4Romain Guy 2349d5316e3f56d138504565ff311145ac01621dff4Romain Guy // Shaders 2359d5316e3f56d138504565ff311145ac01621dff4Romain Guy sp<DrawColorProgram> mDrawColorShader; 236bd6b79b40247aea7bfe13d0831c6c0472df6c636Romain Guy sp<DrawTextureProgram> mDrawTextureShader; 237026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy 238026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy // Used to draw textured quads 239026c5e16704e817cac7d9c382914c947e34f87e0Romain Guy TextureVertex mDrawTextureVertices[4]; 240ce0537b80087a6225273040a987414b1dd081aa0Romain Guy 241ce0537b80087a6225273040a987414b1dd081aa0Romain Guy // Used to cache all drawBitmap textures 242ce0537b80087a6225273040a987414b1dd081aa0Romain Guy TextureCache mTextureCache; 243bb9524b6bdddc7ac77d8628daa8b366b8a7be4a4Romain Guy}; // class OpenGLRenderer 244e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 2459d5316e3f56d138504565ff311145ac01621dff4Romain Guy}; // namespace uirenderer 246e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy}; // namespace android 247e4d011201cea40d46cb2b2eef401db8fddc5c9c6Romain Guy 2489d5316e3f56d138504565ff311145ac01621dff4Romain Guy#endif // ANDROID_UI_OPENGL_RENDERER_H 249