From 09a83acdf281e63c55b619bc7f4ba9b45f2b57e3 Mon Sep 17 00:00:00 2001 From: James Willcox Date: Mon, 17 Sep 2012 15:50:33 -0400 Subject: [PATCH] Bug 778091 - Use medium precision for SurfaceTexture shader r=vlad --- gfx/layers/opengl/LayerManagerOGLShaders.h | 115 +++++++++++++++++++ gfx/layers/opengl/LayerManagerOGLShaders.txt | 5 + 2 files changed, 120 insertions(+) diff --git a/gfx/layers/opengl/LayerManagerOGLShaders.h b/gfx/layers/opengl/LayerManagerOGLShaders.h index f95f57b65a03..ffe7ae36fd5f 100644 --- a/gfx/layers/opengl/LayerManagerOGLShaders.h +++ b/gfx/layers/opengl/LayerManagerOGLShaders.h @@ -104,8 +104,12 @@ 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\ @@ -129,8 +133,12 @@ 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\ @@ -156,8 +164,12 @@ gl_FragColor = mask * uRenderColor;\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\ @@ -180,8 +192,12 @@ gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\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\ @@ -207,8 +223,12 @@ gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\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\ @@ -234,10 +254,15 @@ gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\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\ @@ -260,10 +285,15 @@ gl_FragColor = texture2D(uTexture, (uTextureTransform * vec4(vTexCoord.x, vTexCo 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\ @@ -289,10 +319,15 @@ gl_FragColor = texture2D(uTexture, (uTextureTransform * vec4(vTexCoord.x, vTexCo 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\ @@ -321,8 +356,12 @@ 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\ @@ -355,8 +394,12 @@ static const char sRGBARectTextureLayerMaskFS[] = "/* sRGBARectTextureLayerMaskF #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\ @@ -392,8 +435,12 @@ static const char sRGBARectTextureLayerMask3DFS[] = "/* sRGBARectTextureLayerMas #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\ @@ -430,8 +477,12 @@ static const char sRGBAExternalTextureLayerFS[] = "/* sRGBAExternalTextureLayerF #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\ @@ -455,8 +506,12 @@ static const char sRGBAExternalTextureLayerMaskFS[] = "/* sRGBAExternalTextureLa #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\ @@ -483,8 +538,12 @@ static const char sRGBAExternalTextureLayerMask3DFS[] = "/* sRGBAExternalTexture #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\ @@ -511,8 +570,12 @@ gl_FragColor = texture2D(uTexture, vTexCoord) * uLayerOpacity * mask;\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\ @@ -535,8 +598,12 @@ gl_FragColor = texture2D(uTexture, vTexCoord).bgra * uLayerOpacity * mask;\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\ @@ -562,8 +629,12 @@ gl_FragColor = texture2D(uTexture, vTexCoord).bgra * uLayerOpacity * mask;\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\ @@ -586,8 +657,12 @@ gl_FragColor = vec4(texture2D(uTexture, vTexCoord).rgb, 1.0) * uLayerOpacity * m 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\ @@ -613,8 +688,12 @@ gl_FragColor = vec4(texture2D(uTexture, vTexCoord).rgb, 1.0) * uLayerOpacity * m 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\ @@ -637,8 +716,12 @@ gl_FragColor = vec4(texture2D(uTexture, vTexCoord).bgr, 1.0) * uLayerOpacity * m 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\ @@ -664,8 +747,12 @@ gl_FragColor = vec4(texture2D(uTexture, vTexCoord).bgr, 1.0) * uLayerOpacity * m 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\ @@ -704,8 +791,12 @@ gl_FragColor = color * uLayerOpacity * mask;\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\ @@ -747,8 +838,12 @@ gl_FragColor = color * uLayerOpacity * mask;\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\ @@ -775,8 +870,12 @@ gl_FragColor = alphas * uLayerOpacity * mask;\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\ @@ -806,8 +905,12 @@ gl_FragColor = alphas * uLayerOpacity * mask;\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\ @@ -834,8 +937,12 @@ gl_FragColor = vec4(onBlack, alphas.a) * uLayerOpacity * mask;\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\ @@ -877,8 +984,12 @@ vTexCoord = aTexCoord;\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\ @@ -892,8 +1003,12 @@ 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\ diff --git a/gfx/layers/opengl/LayerManagerOGLShaders.txt b/gfx/layers/opengl/LayerManagerOGLShaders.txt index c39368b60e0d..d49d104a9bae 100644 --- a/gfx/layers/opengl/LayerManagerOGLShaders.txt +++ b/gfx/layers/opengl/LayerManagerOGLShaders.txt @@ -136,8 +136,12 @@ $VERTEX_MASK_STUFF$ @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 @@ -215,6 +219,7 @@ $FRAGMENT_CALC_MASK$ @shader sRGBATextureLayerExternalFS #extension GL_OES_EGL_image_external : require +#define MEDIUMP_SHADER 1 $LAYER_FRAGMENT$ uniform samplerExternalOES uTexture;