diff options
| author | 2010-07-09 18:53:25 -0700 | |
|---|---|---|
| committer | 2010-07-09 18:53:25 -0700 | |
| commit | 0b9db91c3dc8007b47c8fd4fb9dd85be97201a88 (patch) | |
| tree | f8de431ac029c79d581e54b8ba52afe8a90e3e6b | |
| parent | 8445ca6c3ba9b7cee6d20f5919e3b3ba8e6b8c96 (diff) | |
Remove math from the vertex shader.
Change-Id: I02847a60a8734bf8b3d29ec12e76297795095e38
| -rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 4 | ||||
| -rw-r--r-- | libs/hwui/Program.cpp | 14 | ||||
| -rw-r--r-- | libs/hwui/Program.h | 25 | ||||
| -rw-r--r-- | libs/hwui/shaders/drawColor.vert | 4 | ||||
| -rw-r--r-- | libs/hwui/shaders/drawTexture.vert | 4 |
5 files changed, 24 insertions, 27 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 6d041ae48426..b783d3f36ce0 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -511,7 +511,7 @@ void OpenGLRenderer::drawColorRect(float left, float top, float right, float bot 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 @@ void OpenGLRenderer::drawTextureMesh(float left, float top, float right, float b 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 819e7368aad3..98d254cc9fdb 100644 --- a/libs/hwui/Program.cpp +++ b/libs/hwui/Program.cpp @@ -127,17 +127,17 @@ DrawColorProgram::DrawColorProgram(const char* vertex, const char* fragment): 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 ee16a92f2d32..61d55a9ffe3f 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 @@ public: * 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. - */ - int projection; - /** - * Name of the modelView uniform. + * Name of the color uniform. */ - int modelView; + int color; /** * Name of the transform uniform. */ @@ -146,7 +140,14 @@ class DrawTextureProgram: public DrawColorProgram { 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 742ed989e65c..20e26363e1e4 100644 --- a/libs/hwui/shaders/drawColor.vert +++ b/libs/hwui/shaders/drawColor.vert @@ -2,12 +2,10 @@ SHADER_SOURCE(gDrawColorVertexShader, 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 8abddb87f9d1..240aebf2c1f2 100644 --- a/libs/hwui/shaders/drawTexture.vert +++ b/libs/hwui/shaders/drawTexture.vert @@ -3,15 +3,13 @@ SHADER_SOURCE(gDrawTextureVertexShader, 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; } ); |