Bug 778091 - Use medium precision for SurfaceTexture shader r=vlad a=lsblakk
authorJames Willcox <jwillcox@mozilla.com>
Mon, 17 Sep 2012 15:50:33 -0400
changeset 109266 f306fa59ad2a52d91a7da4a761fd33dc30159ea0
parent 109265 b0ca21422a15752a3a2e036d038a1effb29d4baf
child 109267 dc0939428668435132e59ca7cfaee8bb3ee86797
push id1490
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 18:29:50 +0000
treeherdermozilla-beta@f335e7dacdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvlad, lsblakk
bugs778091
milestone17.0a2
Bug 778091 - Use medium precision for SurfaceTexture shader r=vlad a=lsblakk
gfx/layers/opengl/LayerManagerOGLShaders.h
gfx/layers/opengl/LayerManagerOGLShaders.txt
--- a/gfx/layers/opengl/LayerManagerOGLShaders.h
+++ b/gfx/layers/opengl/LayerManagerOGLShaders.h
@@ -99,18 +99,22 @@ vTexCoord = aTexCoord;\n\
 gl_Position = finalPosition;\n\
 }\n\
 ";
 
 static const char sSolidColorLayerFS[] = "/* sSolidColorLayerFS */\n\
 #define NO_LAYER_OPACITY 1\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -124,18 +128,22 @@ float mask = 1.0;\n\
 gl_FragColor = mask * uRenderColor;\n\
 }\n\
 ";
 
 static const char sSolidColorLayerMaskFS[] = "/* sSolidColorLayerMaskFS */\n\
 #define NO_LAYER_OPACITY 1\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -151,18 +159,22 @@ float mask = texture2D(uMaskTexture, vMa
 \n\
 gl_FragColor = mask * uRenderColor;\n\
 }\n\
 ";
 
 static const char sRGBATextureLayerFS[] = "/* sRGBATextureLayerFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -175,18 +187,22 @@ float mask = 1.0;\n\
 \n\
 gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBATextureLayerMaskFS[] = "/* sRGBATextureLayerMaskFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -202,18 +218,22 @@ float mask = texture2D(uMaskTexture, vMa
 \n\
 gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBATextureLayerMask3DFS[] = "/* sRGBATextureLayerMask3DFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -229,20 +249,25 @@ vec2 maskCoords = vMaskCoord.xy / vMaskC
 float mask = texture2D(uMaskTexture, maskCoords).r;\n\
 \n\
 gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBATextureLayerExternalFS[] = "/* sRGBATextureLayerExternalFS */\n\
 #extension GL_OES_EGL_image_external : require\n\
+#define MEDIUMP_SHADER 1\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -255,20 +280,25 @@ void main()\n\
 float mask = 1.0;\n\
 \n\
 gl_FragColor = texture2D(uTexture, (uTextureTransform * vec4(vTexCoord.x, vTexCoord.y, 0.0, 1.0)).xy) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBATextureLayerExternalMaskFS[] = "/* sRGBATextureLayerExternalMaskFS */\n\
 #extension GL_OES_EGL_image_external : require\n\
+#define MEDIUMP_SHADER 1\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -284,20 +314,25 @@ void main()\n\
 float mask = texture2D(uMaskTexture, vMaskCoord).r;\n\
 \n\
 gl_FragColor = texture2D(uTexture, (uTextureTransform * vec4(vTexCoord.x, vTexCoord.y, 0.0, 1.0)).xy) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBATextureLayerExternalMask3DFS[] = "/* sRGBATextureLayerExternalMask3DFS */\n\
 #extension GL_OES_EGL_image_external : require\n\
+#define MEDIUMP_SHADER 1\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -316,18 +351,22 @@ float mask = texture2D(uMaskTexture, mas
 gl_FragColor = texture2D(uTexture, (uTextureTransform * vec4(vTexCoord.x, vTexCoord.y, 0.0, 1.0)).xy) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBARectTextureLayerFS[] = "/* sRGBARectTextureLayerFS */\n\
 #extension GL_ARB_texture_rectangle : enable\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -350,18 +389,22 @@ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
 }\n\
 #endif\n\
 ";
 
 static const char sRGBARectTextureLayerMaskFS[] = "/* sRGBARectTextureLayerMaskFS */\n\
 #extension GL_ARB_texture_rectangle : enable\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -387,18 +430,22 @@ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
 }\n\
 #endif\n\
 ";
 
 static const char sRGBARectTextureLayerMask3DFS[] = "/* sRGBARectTextureLayerMask3DFS */\n\
 #extension GL_ARB_texture_rectangle : enable\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -425,18 +472,22 @@ gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
 }\n\
 #endif\n\
 ";
 
 static const char sRGBAExternalTextureLayerFS[] = "/* sRGBAExternalTextureLayerFS */\n\
 #extension GL_OES_EGL_image_external : require\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -450,18 +501,22 @@ float mask = 1.0;\n\
 gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBAExternalTextureLayerMaskFS[] = "/* sRGBAExternalTextureLayerMaskFS */\n\
 #extension GL_OES_EGL_image_external : require\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -478,18 +533,22 @@ float mask = texture2D(uMaskTexture, vMa
 gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBAExternalTextureLayerMask3DFS[] = "/* sRGBAExternalTextureLayerMask3DFS */\n\
 #extension GL_OES_EGL_image_external : require\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -506,18 +565,22 @@ float mask = texture2D(uMaskTexture, mas
 \n\
 gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sBGRATextureLayerFS[] = "/* sBGRATextureLayerFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -530,18 +593,22 @@ float mask = 1.0;\n\
 \n\
 gl_FragColor = texture2D(uTexture, vTexCoord).bgra * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sBGRATextureLayerMaskFS[] = "/* sBGRATextureLayerMaskFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -557,18 +624,22 @@ float mask = texture2D(uMaskTexture, vMa
 \n\
 gl_FragColor = texture2D(uTexture, vTexCoord).bgra * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBXTextureLayerFS[] = "/* sRGBXTextureLayerFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -581,18 +652,22 @@ float mask = 1.0;\n\
 \n\
 gl_FragColor = vec4(texture2D(uTexture, vTexCoord).rgb, 1.0) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sRGBXTextureLayerMaskFS[] = "/* sRGBXTextureLayerMaskFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -608,18 +683,22 @@ float mask = texture2D(uMaskTexture, vMa
 \n\
 gl_FragColor = vec4(texture2D(uTexture, vTexCoord).rgb, 1.0) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sBGRXTextureLayerFS[] = "/* sBGRXTextureLayerFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -632,18 +711,22 @@ float mask = 1.0;\n\
 \n\
 gl_FragColor = vec4(texture2D(uTexture, vTexCoord).bgr, 1.0) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sBGRXTextureLayerMaskFS[] = "/* sBGRXTextureLayerMaskFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -659,18 +742,22 @@ float mask = texture2D(uMaskTexture, vMa
 \n\
 gl_FragColor = vec4(texture2D(uTexture, vTexCoord).bgr, 1.0) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sYCbCrTextureLayerFS[] = "/* sYCbCrTextureLayerFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -699,18 +786,22 @@ float mask = 1.0;\n\
 \n\
 gl_FragColor = color * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sYCbCrTextureLayerMaskFS[] = "/* sYCbCrTextureLayerMaskFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -742,18 +833,22 @@ float mask = texture2D(uMaskTexture, vMa
 \n\
 gl_FragColor = color * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sComponentPass1FS[] = "/* sComponentPass1FS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -770,18 +865,22 @@ float mask = 1.0;\n\
 \n\
 gl_FragColor = alphas * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sComponentPassMask1FS[] = "/* sComponentPassMask1FS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -801,18 +900,22 @@ float mask = texture2D(uMaskTexture, vMa
 \n\
 gl_FragColor = alphas * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sComponentPass2FS[] = "/* sComponentPass2FS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -829,18 +932,22 @@ float mask = 1.0;\n\
 \n\
 gl_FragColor = vec4(onBlack, alphas.a) * uLayerOpacity * mask;\n\
 }\n\
 ";
 
 static const char sComponentPassMask2FS[] = "/* sComponentPassMask2FS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 #ifndef NO_LAYER_OPACITY\n\
 uniform float uLayerOpacity;\n\
 #endif\n\
 #ifdef GL_ES // for tiling, texcoord can be greater than the lowfp range\n\
 varying mediump vec2 vTexCoord;\n\
 #else\n\
 varying vec2 vTexCoord;\n\
@@ -872,33 +979,41 @@ void main()\n\
 gl_Position = aVertexCoord;\n\
 vTexCoord = aTexCoord;\n\
 }\n\
 ";
 
 static const char sCopy2DFS[] = "/* sCopy2DFS */\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 varying vec2 vTexCoord;\n\
 uniform sampler2D uTexture;\n\
 void main()\n\
 {\n\
 gl_FragColor = texture2D(uTexture, vTexCoord);\n\
 }\n\
 ";
 
 static const char sCopy2DRectFS[] = "/* sCopy2DRectFS */\n\
 #extension GL_ARB_texture_rectangle : enable\n\
 /* Fragment Shader */\n\
 #ifdef GL_ES\n\
+#ifdef MEDIUMP_SHADER\n\
+precision mediump float;\n\
+#else\n\
 precision lowp float;\n\
 #endif\n\
+#endif\n\
 \n\
 varying vec2 vTexCoord;\n\
 uniform vec2 uTexCoordMultiplier;\n\
 #ifndef GL_ES\n\
 uniform sampler2DRect uTexture;\n\
 void main()\n\
 {\n\
 gl_FragColor = texture2DRect(uTexture, vTexCoord * uTexCoordMultiplier);\n\
--- a/gfx/layers/opengl/LayerManagerOGLShaders.txt
+++ b/gfx/layers/opengl/LayerManagerOGLShaders.txt
@@ -131,18 +131,22 @@ void main()
 
 /*
  * Fragment shaders
  */
 
 @define FRAGMENT_SHADER_HEADER
 /* Fragment Shader */
 #ifdef GL_ES
+#ifdef MEDIUMP_SHADER
+precision mediump float;
+#else
 precision lowp float;
 #endif
+#endif
 @end
 
 // fragment shader header for layers
 @define LAYER_FRAGMENT<>
 $FRAGMENT_SHADER_HEADER$
 
 #ifndef NO_LAYER_OPACITY
 uniform float uLayerOpacity;
@@ -210,16 +214,17 @@ void main()
   gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;
 }
 @end
 
 // Single texture in RGBA format for use with GL_TEXTURE_EXTERNAL_OES
 @shader sRGBATextureLayerExternal<mask:,Mask,Mask3D>FS
 #extension GL_OES_EGL_image_external : require
 
+#define MEDIUMP_SHADER 1
 $LAYER_FRAGMENT<mask>$
 
 uniform samplerExternalOES uTexture;
 uniform mat4 uTextureTransform;
 
 void main()
 {
 $FRAGMENT_CALC_MASK<mask>$