summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2012-09-26 16:49:28 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-09-26 16:49:29 -0700
commit244a0bcadc167ed8519c7e34c62e116c1adc2dbe (patch)
treedd2ec331c91601b3925e90f4e0bb0b669099b3ca /libs
parent13987fb43255ccb3802d415e32b1c5caf14291bb (diff)
parent39284b763a09688468ed3799ebd2ebb76ea5dfd5 (diff)
downloadframeworks_base-244a0bcadc167ed8519c7e34c62e116c1adc2dbe.zip
frameworks_base-244a0bcadc167ed8519c7e34c62e116c1adc2dbe.tar.gz
frameworks_base-244a0bcadc167ed8519c7e34c62e116c1adc2dbe.tar.bz2
Merge "Make gradients beautiful again Bug #7239634" into jb-mr1-dev
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Program.cpp9
-rw-r--r--libs/hwui/Program.h5
-rw-r--r--libs/hwui/ProgramCache.cpp15
3 files changed, 19 insertions, 10 deletions
diff --git a/libs/hwui/Program.cpp b/libs/hwui/Program.cpp
index 5b1b57d..f0b5553 100644
--- a/libs/hwui/Program.cpp
+++ b/libs/hwui/Program.cpp
@@ -81,6 +81,7 @@ Program::Program(const ProgramDescription& description, const char* vertex, cons
if (mInitialized) {
transform = addUniform("transform");
+ projection = addUniform("projection");
}
}
@@ -152,18 +153,20 @@ GLuint Program::buildShader(const char* source, GLenum type) {
void Program::set(const mat4& projectionMatrix, const mat4& modelViewMatrix,
const mat4& transformMatrix, bool offset) {
- mat4 t(projectionMatrix);
+ mat4 p(projectionMatrix);
if (offset) {
// offset screenspace xy by an amount that compensates for typical precision
// issues in GPU hardware that tends to paint hor/vert lines in pixels shifted
// up and to the left.
// This offset value is based on an assumption that some hardware may use as
// little as 12.4 precision, so we offset by slightly more than 1/16.
- t.translate(.375, .375, 0);
+ p.translate(.375, .375, 0);
}
- t.multiply(transformMatrix);
+
+ mat4 t(transformMatrix);
t.multiply(modelViewMatrix);
+ glUniformMatrix4fv(projection, 1, GL_FALSE, &p.data[0]);
glUniformMatrix4fv(transform, 1, GL_FALSE, &t.data[0]);
}
diff --git a/libs/hwui/Program.h b/libs/hwui/Program.h
index b1cb446..7e3aacf 100644
--- a/libs/hwui/Program.h
+++ b/libs/hwui/Program.h
@@ -374,6 +374,11 @@ public:
*/
int transform;
+ /**
+ * Name of the projection uniform.
+ */
+ int projection;
+
protected:
/**
* Adds an attribute with the specified name.
diff --git a/libs/hwui/ProgramCache.cpp b/libs/hwui/ProgramCache.cpp
index 7bc2b37..f536ade 100644
--- a/libs/hwui/ProgramCache.cpp
+++ b/libs/hwui/ProgramCache.cpp
@@ -48,6 +48,7 @@ const char* gVS_Header_Attributes_AAVertexShapeParameters =
const char* gVS_Header_Uniforms_TextureTransform =
"uniform mat4 mainTextureTransform;\n";
const char* gVS_Header_Uniforms =
+ "uniform mat4 projection;\n" \
"uniform mat4 transform;\n";
const char* gVS_Header_Uniforms_IsPoint =
"uniform mediump float pointSize;\n";
@@ -104,28 +105,28 @@ const char* gVS_Main_OutTransformedTexCoords =
const char* gVS_Main_OutGradient[6] = {
// Linear
" linear = vec2((screenSpace * position).x, 0.5);\n"
- " ditherTexCoords = (gl_Position * ditherSize).xy;\n",
+ " ditherTexCoords = (transform * position).xy * ditherSize;\n",
" linear = (screenSpace * position).x;\n"
- " ditherTexCoords = (gl_Position * ditherSize).xy;\n",
+ " ditherTexCoords = (transform * position).xy * ditherSize;\n",
// Circular
" circular = (screenSpace * position).xy;\n"
- " ditherTexCoords = (gl_Position * ditherSize).xy;\n",
+ " ditherTexCoords = (transform * position).xy * ditherSize;\n",
" circular = (screenSpace * position).xy;\n"
- " ditherTexCoords = (gl_Position * ditherSize).xy;\n",
+ " ditherTexCoords = (transform * position).xy * ditherSize;\n",
// Sweep
" sweep = (screenSpace * position).xy;\n"
- " ditherTexCoords = (gl_Position * ditherSize).xy;\n",
+ " ditherTexCoords = (transform * position).xy * ditherSize;\n",
" sweep = (screenSpace * position).xy;\n"
- " ditherTexCoords = (gl_Position * ditherSize).xy;\n",
+ " ditherTexCoords = (transform * position).xy * ditherSize;\n",
};
const char* gVS_Main_OutBitmapTexCoords =
" outBitmapTexCoords = (textureTransform * position).xy * textureDimension;\n";
const char* gVS_Main_OutPointBitmapTexCoords =
" outPointBitmapTexCoords = (textureTransform * position).xy * textureDimension;\n";
const char* gVS_Main_Position =
- " gl_Position = transform * position;\n";
+ " gl_Position = projection * transform * position;\n";
const char* gVS_Main_PointSize =
" gl_PointSize = pointSize;\n";
const char* gVS_Main_AALine =