summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2013-08-31 01:30:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-08-31 01:30:10 +0000
commit9b5534b0e5e1510f56e6a2c58ad0816167603ebd (patch)
tree8d8e55c28871493a84fb1d25f830e8665c7af938 /services
parent87967c186995d1500875c495cba8f04f7cff76cc (diff)
parenta8c386f1c36e916c1df18d41a22104d655a89817 (diff)
downloadframeworks_native-9b5534b0e5e1510f56e6a2c58ad0816167603ebd.zip
frameworks_native-9b5534b0e5e1510f56e6a2c58ad0816167603ebd.tar.gz
frameworks_native-9b5534b0e5e1510f56e6a2c58ad0816167603ebd.tar.bz2
Merge changes I8283a989,I64add89a into klp-dev
* changes: switch to use mat4 vector and matrix classes for graphics use
Diffstat (limited to 'services')
-rw-r--r--services/surfaceflinger/RenderEngine/Description.cpp6
-rw-r--r--services/surfaceflinger/RenderEngine/Description.h4
-rw-r--r--services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp2
-rw-r--r--services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp22
-rw-r--r--services/surfaceflinger/RenderEngine/Program.cpp4
-rw-r--r--services/surfaceflinger/RenderEngine/Texture.cpp8
-rw-r--r--services/surfaceflinger/RenderEngine/Texture.h5
7 files changed, 15 insertions, 36 deletions
diff --git a/services/surfaceflinger/RenderEngine/Description.cpp b/services/surfaceflinger/RenderEngine/Description.cpp
index 8e404b2..b0325c6 100644
--- a/services/surfaceflinger/RenderEngine/Description.cpp
+++ b/services/surfaceflinger/RenderEngine/Description.cpp
@@ -33,9 +33,7 @@ Description::Description() :
mOpaque = true;
mTextureEnabled = false;
- const GLfloat m[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
memset(mColor, 0, sizeof(mColor));
- memcpy(mProjectionMatrix, m, sizeof(mProjectionMatrix));
}
Description::~Description() {
@@ -78,8 +76,8 @@ void Description::setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf
mUniformsDirty = true;
}
-void Description::setProjectionMatrix(GLfloat const* mtx) {
- memcpy(mProjectionMatrix, mtx, sizeof(mProjectionMatrix));
+void Description::setProjectionMatrix(const mat4& mtx) {
+ mProjectionMatrix = mtx;
mUniformsDirty = true;
}
diff --git a/services/surfaceflinger/RenderEngine/Description.h b/services/surfaceflinger/RenderEngine/Description.h
index 862301b..0230762 100644
--- a/services/surfaceflinger/RenderEngine/Description.h
+++ b/services/surfaceflinger/RenderEngine/Description.h
@@ -49,7 +49,7 @@ class Description {
// color used when texturing is disabled
GLclampf mColor[4];
// projection matrix
- GLfloat mProjectionMatrix[16];
+ mat4 mProjectionMatrix;
public:
Description();
@@ -61,7 +61,7 @@ public:
void setTexture(const Texture& texture);
void disableTexture();
void setColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
- void setProjectionMatrix(GLfloat const* mtx);
+ void setProjectionMatrix(const mat4& mtx);
private:
bool mUniformsDirty;
diff --git a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
index 610061a..d0ae253 100644
--- a/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES11RenderEngine.cpp
@@ -160,7 +160,7 @@ void GLES11RenderEngine::setupLayerTexturing(const Texture& texture) {
glTexParameterx(target, GL_TEXTURE_MAG_FILTER, filter);
glTexParameterx(target, GL_TEXTURE_MIN_FILTER, filter);
glMatrixMode(GL_TEXTURE);
- glLoadMatrixf(texture.getMatrix());
+ glLoadMatrixf(texture.getMatrix().asArray());
glMatrixMode(GL_MODELVIEW);
glDisable(GL_TEXTURE_2D);
glEnable(GL_TEXTURE_EXTERNAL_OES);
diff --git a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
index 56c6e56..9754758 100644
--- a/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
+++ b/services/surfaceflinger/RenderEngine/GLES20RenderEngine.cpp
@@ -76,25 +76,9 @@ size_t GLES20RenderEngine::getMaxViewportDims() const {
void GLES20RenderEngine::setViewportAndProjection(
size_t vpw, size_t vph, size_t w, size_t h, bool yswap) {
-
- struct ortho {
- inline void operator() (GLfloat *m,
- GLfloat left, GLfloat right, GLfloat bottom, GLfloat top,
- GLfloat near, GLfloat far) const {
- memset(m, 0, 16*sizeof(GLfloat));
- m[ 0] = 2.0f / (right - left);
- m[ 5] = 2.0f / (top - bottom);
- m[10] =-2.0f / (far - near);
- m[15] = 1.0f;
- m[12] = -(right + left) / (right - left);
- m[13] = -(top + bottom) / (top - bottom);
- m[14] = -(far + near) / (far - near);
- }
- } ortho;
-
- GLfloat m[16];
- if (yswap) ortho(m, 0, w, h, 0, 0, 1);
- else ortho(m, 0, w, 0, h, 0, 1);
+ mat4 m;
+ if (yswap) m = mat4::ortho(0, w, h, 0, 0, 1);
+ else m = mat4::ortho(0, w, 0, h, 0, 1);
glViewport(0, 0, vpw, vph);
mState.setProjectionMatrix(m);
diff --git a/services/surfaceflinger/RenderEngine/Program.cpp b/services/surfaceflinger/RenderEngine/Program.cpp
index c5691d7..ece0905 100644
--- a/services/surfaceflinger/RenderEngine/Program.cpp
+++ b/services/surfaceflinger/RenderEngine/Program.cpp
@@ -129,7 +129,7 @@ void Program::setUniforms(const Description& desc) {
if (mSamplerLoc >= 0) {
glUniform1i(mSamplerLoc, 0);
- glUniformMatrix4fv(mTextureMatrixLoc, 1, GL_FALSE, desc.mTexture.getMatrix());
+ glUniformMatrix4fv(mTextureMatrixLoc, 1, GL_FALSE, desc.mTexture.getMatrix().asArray());
}
if (mAlphaPlaneLoc >= 0) {
glUniform1f(mAlphaPlaneLoc, desc.mPlaneAlpha);
@@ -138,7 +138,7 @@ void Program::setUniforms(const Description& desc) {
glUniform4fv(mColorLoc, 1, desc.mColor);
}
// these uniforms are always present
- glUniformMatrix4fv(mProjectionMatrixLoc, 1, GL_FALSE, desc.mProjectionMatrix);
+ glUniformMatrix4fv(mProjectionMatrixLoc, 1, GL_FALSE, desc.mProjectionMatrix.asArray());
}
} /* namespace android */
diff --git a/services/surfaceflinger/RenderEngine/Texture.cpp b/services/surfaceflinger/RenderEngine/Texture.cpp
index 2cb3b65..8875b6d 100644
--- a/services/surfaceflinger/RenderEngine/Texture.cpp
+++ b/services/surfaceflinger/RenderEngine/Texture.cpp
@@ -23,15 +23,11 @@ namespace android {
Texture::Texture() :
mTextureName(0), mTextureTarget(TEXTURE_2D),
mWidth(0), mHeight(0), mFiltering(false) {
- const float m[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
- memcpy(mTextureMatrix, m, sizeof(mTextureMatrix));
}
Texture::Texture(Target textureTarget, uint32_t textureName) :
mTextureName(textureName), mTextureTarget(textureTarget),
mWidth(0), mHeight(0), mFiltering(false) {
- const float m[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 };
- memcpy(mTextureMatrix, m, sizeof(mTextureMatrix));
}
void Texture::init(Target textureTarget, uint32_t textureName) {
@@ -44,7 +40,7 @@ Texture::~Texture() {
void Texture::setMatrix(float const* matrix) {
- memcpy(mTextureMatrix, matrix, sizeof(mTextureMatrix));
+ mTextureMatrix = mat4(matrix);
}
void Texture::setFiltering(bool enabled) {
@@ -64,7 +60,7 @@ uint32_t Texture::getTextureTarget() const {
return mTextureTarget;
}
-float const* Texture::getMatrix() const {
+const mat4& Texture::getMatrix() const {
return mTextureMatrix;
}
diff --git a/services/surfaceflinger/RenderEngine/Texture.h b/services/surfaceflinger/RenderEngine/Texture.h
index 981b475..8cf85fc 100644
--- a/services/surfaceflinger/RenderEngine/Texture.h
+++ b/services/surfaceflinger/RenderEngine/Texture.h
@@ -15,6 +15,7 @@
*/
#include <stdint.h>
+#include <ui/mat4.h>
#ifndef SF_RENDER_ENGINE_TEXTURE_H
#define SF_RENDER_ENGINE_TEXTURE_H
@@ -27,7 +28,7 @@ class Texture {
size_t mWidth;
size_t mHeight;
bool mFiltering;
- float mTextureMatrix[16];
+ mat4 mTextureMatrix;
public:
enum Target { TEXTURE_2D = 0x0DE1, TEXTURE_EXTERNAL = 0x8D65 };
@@ -45,7 +46,7 @@ public:
uint32_t getTextureName() const;
uint32_t getTextureTarget() const;
- float const* getMatrix() const;
+ const mat4& getMatrix() const;
bool getFiltering() const;
size_t getWidth() const;
size_t getHeight() const;