Caches.h revision cc3c25622c731d14a6f01bce684330eccba7db5a
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright (C) 2010 The Android Open Source Project 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Licensed under the Apache License, Version 2.0 (the "License"); 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * you may not use this file except in compliance with the License. 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * You may obtain a copy of the License at 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * http://www.apache.org/licenses/LICENSE-2.0 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Unless required by applicable law or agreed to in writing, software 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * distributed under the License is distributed on an "AS IS" BASIS, 125e3f23d412006dc4db4e659864679f29341e113fTorne (Richard Coles) * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu * See the License for the specific language governing permissions and 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * limitations under the License. 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 165c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 175c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#ifndef ANDROID_HWUI_CACHES_H 185c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#define ANDROID_HWUI_CACHES_H 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef LOG_TAG 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) #define LOG_TAG "OpenGLRenderer" 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 245c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include <GLES3/gl3.h> 252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <utils/KeyedVector.h> 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <utils/Singleton.h> 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include <utils/Vector.h> 295c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <cutils/compiler.h> 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "thread/TaskProcessor.h" 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "thread/TaskManager.h" 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 355c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu#include "AssetAtlas.h" 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "FontRenderer.h" 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "GammaFontRenderer.h" 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "TextureCache.h" 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "LayerCache.h" 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "RenderBufferCache.h" 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "GradientCache.h" 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "PatchCache.h" 435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ProgramCache.h" 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "PathCache.h" 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "TextDropShadowCache.h" 465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "FboCache.h" 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ResourceCache.h" 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "Stencil.h" 495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "Dither.h" 505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace android { 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace uirenderer { 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Globals 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// GL ES 2.0 defines that at least 16 texture units must be supported 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define REQUIRED_TEXTURE_UNITS_COUNT 3 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Maximum number of quads that pre-allocated meshes can draw 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)static const uint32_t gMaxNumberOfQuads = 2048; 635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Generates simple and textured vertices 655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define FV(x, y, u, v) { x, y, u, v } 665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// This array is never used directly but used as a memcpy source in the 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// OpenGLRenderer constructor 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)static const TextureVertex gMeshVertices[] = { 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FV(0.0f, 0.0f, 0.0f, 0.0f), 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FV(1.0f, 0.0f, 1.0f, 0.0f), 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) FV(0.0f, 1.0f, 0.0f, 1.0f), 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) FV(1.0f, 1.0f, 1.0f, 1.0f) 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 7523730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)static const GLsizei gMeshStride = sizeof(TextureVertex); 7623730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)static const GLsizei gVertexStride = sizeof(Vertex); 7723730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)static const GLsizei gAlphaVertexStride = sizeof(AlphaVertex); 7823730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)static const GLsizei gMeshTextureOffset = 2 * sizeof(float); 792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)static const GLsizei gVertexAlphaOffset = 2 * sizeof(float); 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)static const GLsizei gVertexAAWidthOffset = 2 * sizeof(float); 812a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)static const GLsizei gVertexAALengthOffset = 3 * sizeof(float); 8223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)static const GLsizei gMeshCount = 4; 8323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 8423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Must define as many texture units as specified by REQUIRED_TEXTURE_UNITS_COUNT 852a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)static const GLenum gTextureUnits[] = { 862a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GL_TEXTURE0, 872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GL_TEXTURE1, 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GL_TEXTURE2 892a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 902a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 912a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 9223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)// Debug 9323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 9423730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles) 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct CacheLogger { 962a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) CacheLogger() { 972a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) INIT_LOGD("Creating OpenGL renderer caches"); 982a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) } 995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; // struct CacheLogger 1005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Caches 1035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/////////////////////////////////////////////////////////////////////////////// 1045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class DisplayList; 106cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) 1075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ANDROID_API Caches: public Singleton<Caches> { 1085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) Caches(); 1095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend class Singleton<Caches>; 1115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) CacheLogger mLogger; 1135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)public: 1155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) enum FlushMode { 1165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) kFlushMode_Layers = 0, 1175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) kFlushMode_Moderate, 1185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) kFlushMode_Full 1197d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) }; 1205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Initialize caches. 1235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1245f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) bool init(); 1255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 1265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Initialize global system properties. 1285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool initProperties(); 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Flush the cache. 1335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * 1345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * @param mode Indicates how much of the cache should be flushed 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void flush(FlushMode mode); 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Destroys all resources associated with this cache. This should 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * be called after a flush(kFlushMode_Full). 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void terminate(); 1432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) /** 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Indicates whether the renderer is in debug mode. 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * This debug mode provides limited information to app developers. 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DebugLevel getDebugLevel() const { 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return mDebugLevel; 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) } 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Returns a non-premultiplied ARGB color for the specified 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * amount of overdraw (1 for 1x, 2 for 2x, etc.) 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) uint32_t getOverdrawColor(uint32_t amount) const; 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Call this on each frame to ensure that garbage is deleted from 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * GPU memory. 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void clearGarbage(); 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Can be used to delete a layer from a non EGL thread. 1665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void deleteLayerDeferred(Layer* layer); 1685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /* 1705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Can be used to delete a display list from a non EGL thread. 1715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void deleteDisplayListDeferred(DisplayList* layer); 1735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Binds the VBO used to render simple textured quads. 1765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool bindMeshBuffer(); 1785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1805821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Binds the specified VBO if needed. 1815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool bindMeshBuffer(const GLuint buffer); 1835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Unbinds the VBO used to render simple textured quads. 186868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) */ 187868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool unbindMeshBuffer(); 188868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 1895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 190868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) * Binds a global indices buffer that can draw up to 1915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * gMaxNumberOfQuads quads. 1925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 1935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool bindIndicesBuffer(); 1945821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool bindIndicesBuffer(const GLuint buffer); 1955821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool unbindIndicesBuffer(); 1965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 1985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Binds the specified buffer as the current GL unpack pixel buffer. 1995821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 2005821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool bindPixelBuffer(const GLuint buffer); 2015821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2025821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 2035821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Resets the current unpack pixel buffer to 0 (default value.) 2045821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 2055821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) bool unbindPixelBuffer(); 2065821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2075821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 2085821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Binds an attrib to the specified float vertex pointer. 2095821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Assumes a stride of gMeshStride and a size of 2. 2105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 2115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void bindPositionVertexPointer(bool force, const GLvoid* vertices, GLsizei stride = gMeshStride); 212116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 213116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch /** 214116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * Binds an attrib to the specified float vertex pointer. 215116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch * Assumes a stride of gMeshStride and a size of 2. 216116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch */ 2175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void bindTexCoordsVertexPointer(bool force, const GLvoid* vertices, GLsizei stride = gMeshStride); 2185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 2205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Resets the vertex pointers. 2215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 2225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void resetVertexPointers(); 2235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void resetTexCoordsVertexPointer(); 2245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void enableTexCoordsVertexArray(); 2265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void disableTexCoordsVertexArray(); 2275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2285c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu /** 2295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Activate the specified texture unit. The texture unit must 2305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * be specified using an integer number (0 for GL_TEXTURE0 etc.) 2315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 2325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void activeTexture(GLuint textureUnit); 2335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 2355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Invalidate the cached value of the active texture unit. 2365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 2375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) void resetActiveTexture(); 2385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 2402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Binds the specified texture as a GL_TEXTURE_2D texture. 2412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * All texture bindings must be performed with this method or 2422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * bindTexture(GLenum, GLuint). 2432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */ 2442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void bindTexture(GLuint texture); 2452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 2462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) /** 2472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Binds the specified texture with the specified render target. 2482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * All texture bindings must be performed with this method or 2492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * bindTexture(GLuint). 2502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */ 2512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) void bindTexture(GLenum target, GLuint texture); 2525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 2535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) /** 2545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Deletes the specified texture and clears it from the cache 2555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * of bound textures. 2565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * All textures must be deleted using this method. 257 */ 258 void deleteTexture(GLuint texture); 259 260 /** 261 * Signals that the cache of bound textures should be cleared. 262 * Other users of the context may have altered which textures are bound. 263 */ 264 void resetBoundTextures(); 265 266 /** 267 * Sets the scissor for the current surface. 268 */ 269 bool setScissor(GLint x, GLint y, GLint width, GLint height); 270 271 /** 272 * Resets the scissor state. 273 */ 274 void resetScissor(); 275 276 bool enableScissor(); 277 bool disableScissor(); 278 void setScissorEnabled(bool enabled); 279 280 void startTiling(GLuint x, GLuint y, GLuint width, GLuint height, bool discard); 281 void endTiling(); 282 283 /** 284 * Returns the mesh used to draw regions. Calling this method will 285 * bind a VBO of type GL_ELEMENT_ARRAY_BUFFER that contains the 286 * indices for the region mesh. 287 */ 288 TextureVertex* getRegionMesh(); 289 290 /** 291 * Displays the memory usage of each cache and the total sum. 292 */ 293 void dumpMemoryUsage(); 294 void dumpMemoryUsage(String8& log); 295 296 bool hasRegisteredFunctors(); 297 void registerFunctors(uint32_t functorCount); 298 void unregisterFunctors(uint32_t functorCount); 299 300 bool blend; 301 GLenum lastSrcMode; 302 GLenum lastDstMode; 303 Program* currentProgram; 304 bool scissorEnabled; 305 306 bool drawDeferDisabled; 307 bool drawReorderDisabled; 308 309 // VBO to draw with 310 GLuint meshBuffer; 311 312 // Misc 313 GLint maxTextureSize; 314 315 // Debugging 316 bool debugLayersUpdates; 317 bool debugOverdraw; 318 319 enum StencilClipDebug { 320 kStencilHide, 321 kStencilShowHighlight, 322 kStencilShowRegion 323 }; 324 StencilClipDebug debugStencilClip; 325 326 TextureCache textureCache; 327 LayerCache layerCache; 328 RenderBufferCache renderBufferCache; 329 GradientCache gradientCache; 330 ProgramCache programCache; 331 PathCache pathCache; 332 PatchCache patchCache; 333 TextDropShadowCache dropShadowCache; 334 FboCache fboCache; 335 ResourceCache resourceCache; 336 337 GammaFontRenderer* fontRenderer; 338 339 TaskManager tasks; 340 341 Dither dither; 342 Stencil stencil; 343 344 AssetAtlas assetAtlas; 345 346 bool gpuPixelBuffersEnabled; 347 348 // Debug methods 349 PFNGLINSERTEVENTMARKEREXTPROC eventMark; 350 PFNGLPUSHGROUPMARKEREXTPROC startMark; 351 PFNGLPOPGROUPMARKEREXTPROC endMark; 352 353 PFNGLLABELOBJECTEXTPROC setLabel; 354 PFNGLGETOBJECTLABELEXTPROC getLabel; 355 356 // TEMPORARY properties 357 void initTempProperties(); 358 void setTempProperty(const char* name, const char* value); 359 bool propertyEnable3d; 360 bool propertyDirtyViewport; // flag set when dirtying the viewport 361 float propertyCameraDistance; 362 363 // These scaling factors range from 0 to 1, to scale the light position 364 // within the bound of (screenwidth, screenheight, max(screenwidth, screenheight)); 365 // The default scale is (0.5, 0, 1) which put the light at 366 // (screenwidth / 2, 0, max(screenwidth, screenheight)). 367 float propertyLightPosXScale; 368 float propertyLightPosYScale; 369 float propertyLightPosZScale; 370 int propertyShadowStrength; 371 372private: 373 enum OverdrawColorSet { 374 kColorSet_Default = 0, 375 kColorSet_Deuteranomaly 376 }; 377 378 void initFont(); 379 void initExtensions(); 380 void initConstraints(); 381 void initStaticProperties(); 382 383 static void eventMarkNull(GLsizei length, const GLchar* marker) { } 384 static void startMarkNull(GLsizei length, const GLchar* marker) { } 385 static void endMarkNull() { } 386 387 static void setLabelNull(GLenum type, uint object, GLsizei length, 388 const char* label) { } 389 static void getLabelNull(GLenum type, uint object, GLsizei bufferSize, 390 GLsizei* length, char* label) { 391 if (length) *length = 0; 392 if (label) *label = '\0'; 393 } 394 395 GLuint mCurrentBuffer; 396 GLuint mCurrentIndicesBuffer; 397 GLuint mCurrentPixelBuffer; 398 const void* mCurrentPositionPointer; 399 GLsizei mCurrentPositionStride; 400 const void* mCurrentTexCoordsPointer; 401 GLsizei mCurrentTexCoordsStride; 402 403 bool mTexCoordsArrayEnabled; 404 405 GLuint mTextureUnit; 406 407 GLint mScissorX; 408 GLint mScissorY; 409 GLint mScissorWidth; 410 GLint mScissorHeight; 411 412 Extensions& mExtensions; 413 414 // Used to render layers 415 TextureVertex* mRegionMesh; 416 417 // Global index buffer 418 GLuint mMeshIndices; 419 420 mutable Mutex mGarbageLock; 421 Vector<Layer*> mLayerGarbage; 422 Vector<DisplayList*> mDisplayListGarbage; 423 424 DebugLevel mDebugLevel; 425 bool mInitialized; 426 427 uint32_t mFunctorsCount; 428 429 GLuint mBoundTextures[REQUIRED_TEXTURE_UNITS_COUNT]; 430 431 OverdrawColorSet mOverdrawDebugColorSet; 432}; // class Caches 433 434}; // namespace uirenderer 435}; // namespace android 436 437#endif // ANDROID_HWUI_CACHES_H 438