summaryrefslogtreecommitdiffstats
path: root/libs/hwui/Caches.cpp
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2011-12-12 20:35:21 -0800
committerRomain Guy <romainguy@google.com>2011-12-12 20:35:21 -0800
commitf3a910b423db7ad79cf61518bdd9278c048ad0d8 (patch)
treea0ae14d597ee14202ec6ca60cedfb446ff470379 /libs/hwui/Caches.cpp
parentd71dd367af604571c7d00ca473184a1b9240eca2 (diff)
downloadframeworks_base-f3a910b423db7ad79cf61518bdd9278c048ad0d8.zip
frameworks_base-f3a910b423db7ad79cf61518bdd9278c048ad0d8.tar.gz
frameworks_base-f3a910b423db7ad79cf61518bdd9278c048ad0d8.tar.bz2
Optimize state changes
Change-Id: Iae59bc8dfd6427d0967472462cc1994987092827
Diffstat (limited to 'libs/hwui/Caches.cpp')
-rw-r--r--libs/hwui/Caches.cpp38
1 files changed, 34 insertions, 4 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index f293cba..4da576d 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -73,6 +73,9 @@ void Caches::init() {
glBufferData(GL_ARRAY_BUFFER, sizeof(gMeshVertices), gMeshVertices, GL_STATIC_DRAW);
mCurrentBuffer = meshBuffer;
+ mCurrentPositionPointer = this;
+ mCurrentTexCoordsPointer = this;
+
mRegionMesh = NULL;
blend = false;
@@ -218,24 +221,51 @@ void Caches::flush(FlushMode mode) {
// VBO
///////////////////////////////////////////////////////////////////////////////
-void Caches::bindMeshBuffer() {
- bindMeshBuffer(meshBuffer);
+bool Caches::bindMeshBuffer() {
+ return bindMeshBuffer(meshBuffer);
}
-void Caches::bindMeshBuffer(const GLuint buffer) {
+bool Caches::bindMeshBuffer(const GLuint buffer) {
if (mCurrentBuffer != buffer) {
glBindBuffer(GL_ARRAY_BUFFER, buffer);
mCurrentBuffer = buffer;
+ return true;
}
+ return false;
}
-void Caches::unbindMeshBuffer() {
+bool Caches::unbindMeshBuffer() {
if (mCurrentBuffer) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
mCurrentBuffer = 0;
+ return true;
+ }
+ return false;
+}
+
+void Caches::bindPositionVertexPointer(bool force, GLuint slot, GLvoid* vertices, GLsizei stride) {
+ if (force || vertices != mCurrentPositionPointer) {
+ glVertexAttribPointer(slot, 2, GL_FLOAT, GL_FALSE, stride, vertices);
+ mCurrentPositionPointer = vertices;
}
}
+void Caches::bindTexCoordsVertexPointer(bool force, GLuint slot, GLvoid* vertices) {
+ if (force || vertices != mCurrentTexCoordsPointer) {
+ glVertexAttribPointer(slot, 2, GL_FLOAT, GL_FALSE, gMeshStride, vertices);
+ mCurrentTexCoordsPointer = vertices;
+ }
+}
+
+void Caches::resetVertexPointers() {
+ mCurrentPositionPointer = this;
+ mCurrentTexCoordsPointer = this;
+}
+
+void Caches::resetTexCoordsVertexPointer() {
+ mCurrentTexCoordsPointer = this;
+}
+
TextureVertex* Caches::getRegionMesh() {
// Create the mesh, 2 triangles and 4 vertices per rectangle in the region
if (!mRegionMesh) {