Optimize shader binding changes.
This change also cleans up the internal API a little bit by using mat4
everywhere instead of float[16] (for the ortho matrix for instance.)
Change-Id: I35924c7dc17bad17f30307118d5ed437c2ed37e0
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp
index 98d254c..3b5e5da 100644
--- a/libs/hwui/Program.cpp
+++ b/libs/hwui/Program.cpp
@@ -59,6 +59,8 @@
}
glDeleteProgram(id);
}
+
+ mUse = false;
}
Program::~Program() {
@@ -69,6 +71,11 @@
void Program::use() {
glUseProgram(id);
+ mUse = true;
+}
+
+void Program::remove() {
+ mUse = false;
}
int Program::addAttrib(const char* name) {
@@ -130,13 +137,12 @@
transform = addUniform("transform");
}
-void DrawColorProgram::use(const float* projectionMatrix, const mat4& modelViewMatrix,
+void DrawColorProgram::set(const mat4& projectionMatrix, const mat4& modelViewMatrix,
const mat4& transformMatrix) {
mat4 t(projectionMatrix);
t.multiply(transformMatrix);
t.multiply(modelViewMatrix);
- Program::use();
glUniformMatrix4fv(transform, 1, GL_FALSE, &t.data[0]);
}