Bug 975937 - Crash in mozilla::layers::ShaderProgramOGL::Activate(). r=gal
authorMorris Tseng <mtseng@mozilla.com>
Wed, 26 Feb 2014 09:04:47 -0500
changeset 171028 f6b60344ed5ff8dcb9ce908f785c7c7c56613c4e
parent 171027 e4c29a3a002ebae08429fecbb8bc6b463dd4da1b
child 171029 58053e39e2d4b5567836a9ab10b3cac9e3c1cc15
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersgal
bugs975937
milestone30.0a1
Bug 975937 - Crash in mozilla::layers::ShaderProgramOGL::Activate(). r=gal
gfx/layers/opengl/OGLShaderProgram.cpp
--- a/gfx/layers/opengl/OGLShaderProgram.cpp
+++ b/gfx/layers/opengl/OGLShaderProgram.cpp
@@ -178,16 +178,22 @@ ProgramProfileOGL::GetProfileFor(ShaderC
 
   if (!(aConfig.mFeatures & ENABLE_RENDER_COLOR)) {
     vs << "  vTexCoord = (uTextureTransform * vec4(aTexCoord.x, aTexCoord.y, 0.0, 1.0)).xy;" << endl;
   }
 
   vs << "  gl_Position = finalPosition;" << endl;
   vs << "}" << endl;
 
+  if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
+    fs << "#extension GL_ARB_texture_rectangle : require" << endl;
+  }
+  if (aConfig.mFeatures & ENABLE_TEXTURE_EXTERNAL) {
+    fs << "#extension GL_OES_EGL_image_external : require" << endl;
+  }
   fs << "#ifdef GL_ES" << endl;
   fs << "precision mediump float;" << endl;
   fs << "#define COLOR_PRECISION lowp" << endl;
   fs << "#else" << endl;
   fs << "#define COLOR_PRECISION" << endl;
   fs << "#endif" << endl;
   if (aConfig.mFeatures & ENABLE_RENDER_COLOR) {
     fs << "uniform COLOR_PRECISION vec4 uRenderColor;" << endl;
@@ -208,24 +214,22 @@ ProgramProfileOGL::GetProfileFor(ShaderC
       fs << "uniform COLOR_PRECISION float uLayerOpacity;" << endl;
     }
   }
 
   const char *sampler2D = "sampler2D";
   const char *texture2D = "texture2D";
 
   if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
-    fs << "#extension GL_ARB_texture_rectangle : require" << endl;
     fs << "uniform vec2 uTexCoordMultiplier;" << endl;
     sampler2D = "sampler2DRect";
     texture2D = "texture2DRect";
   }
 
   if (aConfig.mFeatures & ENABLE_TEXTURE_EXTERNAL) {
-    fs << "#extension GL_OES_EGL_image_external : require" << endl;
     sampler2D = "samplerExternalOES";
   }
 
   if (aConfig.mFeatures & ENABLE_TEXTURE_YCBCR) {
     fs << "uniform sampler2D uYTexture;" << endl;
     fs << "uniform sampler2D uCbTexture;" << endl;
     fs << "uniform sampler2D uCrTexture;" << endl;
   } else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {