diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-09-24 20:41:54 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-09-24 20:43:04 +0200 |
commit | 0ab9ddaf4d67e968ad22ec296fbeda02ce1a468d (patch) | |
tree | f09d2551d13cba47a801b16379c68d36dd781500 /android | |
parent | f789cd425e7808cca01058b0843ed0cda045bcb6 (diff) |
android: LayerRenderer - use highp and flip in vertex shader
Change-Id: Ia517b0d94fdfb3f8fdd9b9c383c8fb337173932c
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java index 5146b229bdf8..34c5c61b116d 100644 --- a/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java +++ b/android/experimental/LOAndroid3/src/java/org/mozilla/gecko/gfx/LayerRenderer.java @@ -99,6 +99,11 @@ public class LayerRenderer implements GLSurfaceView.Renderer { // The shaders run on the GPU directly, the vertex shader is only applying the // matrix transform detailed above + + // Note we flip the y-coordinate in the vertex shader from a + // coordinate system with (0,0) in the top left to one with (0,0) in + // the bottom left. + public static final String DEFAULT_VERTEX_SHADER = "uniform mat4 uTMatrix;\n" + "attribute vec4 vPosition;\n" + @@ -106,18 +111,21 @@ public class LayerRenderer implements GLSurfaceView.Renderer { "varying vec2 vTexCoord;\n" + "void main() {\n" + " gl_Position = uTMatrix * vPosition;\n" + - " vTexCoord = aTexCoord;\n" + + " vTexCoord.x = aTexCoord.x;\n" + + " vTexCoord.y = 1.0 - aTexCoord.y;\n" + "}\n"; - // Note we flip the y-coordinate in the fragment shader from a - // coordinate system with (0,0) in the top left to one with (0,0) in - // the bottom left. + // We use highp because the screenshot textures + // we use are large and we stretch them alot + // so we need all the precision we can get. + // Unfortunately, highp is not required by ES 2.0 + // so on GPU's like Mali we end up getting mediump public static final String DEFAULT_FRAGMENT_SHADER = - "precision mediump float;\n" + + "precision highp float;\n" + "varying vec2 vTexCoord;\n" + "uniform sampler2D sTexture;\n" + "void main() {\n" + - " gl_FragColor = texture2D(sTexture, vec2(vTexCoord.x, 1.0 - vTexCoord.y));\n" + + " gl_FragColor = texture2D(sTexture, vTexCoord);\n" + "}\n"; public void setCheckerboardBitmap(Bitmap bitmap, float pageWidth, float pageHeight) { |