From 202b4398901332701cb8c230fefdc13f6afbbd89 Mon Sep 17 00:00:00 2001 From: Andreas Gal Date: Wed, 21 May 2014 23:03:49 +0200 Subject: [PATCH] Bug 1012407 - Part 1: Reduce amount of data uploaded to GPU (layer quad rect instead of transform) r=Bas --- gfx/layers/opengl/OGLShaderProgram.cpp | 7 +++---- gfx/layers/opengl/OGLShaderProgram.h | 18 +++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/gfx/layers/opengl/OGLShaderProgram.cpp b/gfx/layers/opengl/OGLShaderProgram.cpp index 5ef580672c61..e77aa6386b5d 100644 --- a/gfx/layers/opengl/OGLShaderProgram.cpp +++ b/gfx/layers/opengl/OGLShaderProgram.cpp @@ -32,7 +32,7 @@ AddUniforms(ProgramProfileOGL& aProfile) static const char *sKnownUniformNames[] = { "uLayerTransform", "uMaskQuadTransform", - "uLayerQuadTransform", + "uLayerQuadRect", "uMatrixProj", "uTextureTransform", "uRenderTargetOffset", @@ -145,7 +145,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig) AddUniforms(result); vs << "uniform mat4 uMatrixProj;" << endl; - vs << "uniform mat4 uLayerQuadTransform;" << endl; + vs << "uniform vec4 uLayerQuadRect;" << endl; vs << "uniform mat4 uLayerTransform;" << endl; vs << "uniform vec4 uRenderTargetOffset;" << endl; @@ -164,8 +164,7 @@ ProgramProfileOGL::GetProfileFor(ShaderConfigOGL aConfig) } vs << "void main() {" << endl; - vs << " vec4 finalPosition = aVertexCoord;" << endl; - vs << " finalPosition = uLayerQuadTransform * finalPosition;" << endl; + vs << " vec4 finalPosition = vec4(aVertexCoord.xy * uLayerQuadRect.zw + uLayerQuadRect.xy, 0.0, 1.0);" << endl; vs << " finalPosition = uLayerTransform * finalPosition;" << endl; vs << " finalPosition.xyz /= finalPosition.w;" << endl; diff --git a/gfx/layers/opengl/OGLShaderProgram.h b/gfx/layers/opengl/OGLShaderProgram.h index 0e3f1980bb4a..c44e3c0bef57 100644 --- a/gfx/layers/opengl/OGLShaderProgram.h +++ b/gfx/layers/opengl/OGLShaderProgram.h @@ -52,7 +52,7 @@ public: LayerTransform = 0, MaskQuadTransform, - LayerQuadTransform, + LayerQuadRect, MatrixProj, TextureTransform, RenderTargetOffset, @@ -322,21 +322,13 @@ public: } void SetLayerQuadRect(const nsIntRect& aRect) { - gfx3DMatrix m; - m._11 = float(aRect.width); - m._22 = float(aRect.height); - m._41 = float(aRect.x); - m._42 = float(aRect.y); - SetMatrixUniform(KnownUniform::LayerQuadTransform, m); + float vals[4] = { float(aRect.x), float(aRect.y), float(aRect.width), float(aRect.height) }; + SetUniform(KnownUniform::LayerQuadRect, 4, vals); } void SetLayerQuadRect(const gfx::Rect& aRect) { - gfx3DMatrix m; - m._11 = aRect.width; - m._22 = aRect.height; - m._41 = aRect.x; - m._42 = aRect.y; - SetMatrixUniform(KnownUniform::LayerQuadTransform, m); + float vals[4] = { float(aRect.x), float(aRect.y), float(aRect.width), float(aRect.height) }; + SetUniform(KnownUniform::LayerQuadRect, 4, vals); } void SetProjectionMatrix(const gfx::Matrix4x4& aMatrix) {