Remove math from the vertex shader.

Change-Id: I02847a60a8734bf8b3d29ec12e76297795095e38
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index 6d041ae..b783d3f 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -511,7 +511,7 @@
     mModelView.loadTranslate(left, top, 0.0f);
     mModelView.scale(right - left, bottom - top, 1.0f);
 
-    mDrawColorShader->use(&mOrthoMatrix[0], &mModelView.data[0], &mSnapshot->transform.data[0]);
+    mDrawColorShader->use(&mOrthoMatrix[0], mModelView, mSnapshot->transform);
 
     const GLvoid* p = &gDrawColorVertices[0].position[0];
 
@@ -548,7 +548,7 @@
     mModelView.loadTranslate(left, top, 0.0f);
     mModelView.scale(right - left, bottom - top, 1.0f);
 
-    mDrawTextureShader->use(&mOrthoMatrix[0], &mModelView.data[0], &mSnapshot->transform.data[0]);
+    mDrawTextureShader->use(&mOrthoMatrix[0], mModelView, mSnapshot->transform);
 
     chooseBlending(blend || alpha < 1.0f, mode, isPremultiplied);
 
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp
index 819e736..98d254c 100644
--- a/libs/hwui/Program.cpp
+++ b/libs/hwui/Program.cpp
@@ -127,17 +127,17 @@
 void DrawColorProgram::getAttribsAndUniforms() {
     position = addAttrib("position");
     color = addUniform("color");
-    projection = addUniform("projection");
-    modelView = addUniform("modelView");
     transform = addUniform("transform");
 }
 
-void DrawColorProgram::use(const GLfloat* projectionMatrix, const GLfloat* modelViewMatrix,
-        const GLfloat* transformMatrix) {
+void DrawColorProgram::use(const float* projectionMatrix, const mat4& modelViewMatrix,
+        const mat4& transformMatrix) {
+    mat4 t(projectionMatrix);
+    t.multiply(transformMatrix);
+    t.multiply(modelViewMatrix);
+
     Program::use();
-    glUniformMatrix4fv(projection, 1, GL_FALSE, projectionMatrix);
-    glUniformMatrix4fv(modelView, 1, GL_FALSE, modelViewMatrix);
-    glUniformMatrix4fv(transform, 1, GL_FALSE, transformMatrix);
+    glUniformMatrix4fv(transform, 1, GL_FALSE, &t.data[0]);
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h
index ee16a92..61d55a9 100644
--- a/libs/hwui/Program.h
+++ b/libs/hwui/Program.h
@@ -23,6 +23,8 @@
 #include <utils/KeyedVector.h>
 #include <utils/RefBase.h>
 
+#include "Matrix.h"
+
 namespace android {
 namespace uirenderer {
 
@@ -107,26 +109,18 @@
      * Binds the program with the specified projection, modelView and
      * transform matrices.
      */
-    void use(const GLfloat* projectionMatrix, const GLfloat* modelViewMatrix,
-             const GLfloat* transformMatrix);
+    void use(const float* projectionMatrix, const mat4& modelViewMatrix,
+             const mat4& transformMatrix);
 
     /**
      * Name of the position attribute.
      */
     int position;
-    /**
-     * Name of the color attribute.
-     */
-    int color;
 
     /**
-     * Name of the projection uniform.
+     * Name of the color uniform.
      */
-    int projection;
-    /**
-     * Name of the modelView uniform.
-     */
-    int modelView;
+    int color;
     /**
      * Name of the transform uniform.
      */
@@ -146,7 +140,14 @@
 public:
     DrawTextureProgram();
 
+    /**
+     * Name of the texture sampler uniform.
+     */
     int sampler;
+
+    /**
+     * Name of the texture coordinates attribute.
+     */
     int texCoords;
 };
 
diff --git a/libs/hwui/shaders/drawColor.vert b/libs/hwui/shaders/drawColor.vert
index 742ed98..20e2636 100644
--- a/libs/hwui/shaders/drawColor.vert
+++ b/libs/hwui/shaders/drawColor.vert
@@ -2,12 +2,10 @@
 
 attribute vec4 position;
 
-uniform mat4 projection;
-uniform mat4 modelView;
 uniform mat4 transform;
 
 void main(void) {
-    gl_Position = projection * transform * modelView * position;
+    gl_Position = transform * position;
 }
 
 );
diff --git a/libs/hwui/shaders/drawTexture.vert b/libs/hwui/shaders/drawTexture.vert
index 8abddb8..240aebf 100644
--- a/libs/hwui/shaders/drawTexture.vert
+++ b/libs/hwui/shaders/drawTexture.vert
@@ -3,15 +3,13 @@
 attribute vec4 position;
 attribute vec2 texCoords;
 
-uniform mat4 projection;
-uniform mat4 modelView;
 uniform mat4 transform;
 
 varying vec2 outTexCoords;
 
 void main(void) {
     outTexCoords = texCoords;
-    gl_Position = projection * transform * modelView * position;
+    gl_Position = transform * position;
 }
 
 );