Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b9db91c authored by Romain Guy's avatar Romain Guy
Browse files

Remove math from the vertex shader.

Change-Id: I02847a60a8734bf8b3d29ec12e76297795095e38
parent 8445ca6c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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);

+7 −7
Original line number Diff line number Diff line
@@ -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]);
}

///////////////////////////////////////////////////////////////////////////////
+13 −12
Original line number Diff line number Diff line
@@ -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;
};

+1 −3
Original line number Diff line number Diff line
@@ -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;
}

);
+1 −3
Original line number Diff line number Diff line
@@ -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;
}

);