Backed out changeset a2cfe189c828 (bug 1215089)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Wed, 04 Oct 2017 16:25:34 +0200
changeset 427101 c61dc45fa1fe0daa6f894585db673baf3c5b9979
parent 427100 d5827209821639a68494bd591aa6292a2f0a648f
child 427102 ee5a9988ec6a213a9f2e561d53bd5c198f3bef79
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
bugs1215089
milestone58.0a1
backs outa2cfe189c82837e157566e931a75bf8dcd49dced
Backed out changeset a2cfe189c828 (bug 1215089)
gfx/gl/GLContext.cpp
gfx/gl/GLUploadHelpers.cpp
gfx/layers/opengl/CompositorOGL.cpp
gfx/layers/opengl/OGLShaderProgram.cpp
gfx/layers/opengl/OGLShaderProgram.h
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -3012,18 +3012,17 @@ GetBytesPerTexel(GLenum format, GLenum t
             case LOCAL_GL_RGBA:
             case LOCAL_GL_BGRA_EXT:
                 return 4 * multiplier;
             default:
                 break;
         }
     } else if (type == LOCAL_GL_UNSIGNED_SHORT_4_4_4_4 ||
                type == LOCAL_GL_UNSIGNED_SHORT_5_5_5_1 ||
-               type == LOCAL_GL_UNSIGNED_SHORT_5_6_5 ||
-               type == LOCAL_GL_UNSIGNED_SHORT)
+               type == LOCAL_GL_UNSIGNED_SHORT_5_6_5)
     {
         return 2;
     }
 
     gfxCriticalError() << "Unknown texture type " << type << " or format " << format;
     return 0;
 }
 
--- a/gfx/gl/GLUploadHelpers.cpp
+++ b/gfx/gl/GLUploadHelpers.cpp
@@ -459,24 +459,16 @@ UploadImageDataToTexture(GLContext* gl,
             surfaceFormat = SurfaceFormat::R5G6B5_UINT16;
             break;
         case SurfaceFormat::A8:
             internalFormat = format = LOCAL_GL_LUMINANCE;
             type = LOCAL_GL_UNSIGNED_BYTE;
             // We don't have a specific luminance shader
             surfaceFormat = SurfaceFormat::A8;
             break;
-        case SurfaceFormat::A16:
-            format = LOCAL_GL_LUMINANCE;
-            internalFormat = LOCAL_GL_LUMINANCE16;
-            type = LOCAL_GL_UNSIGNED_SHORT;
-            // We don't have a specific luminance shader
-            surfaceFormat = SurfaceFormat::A8;
-            pixelSize = 2;
-            break;
         default:
             NS_ASSERTION(false, "Unhandled image surface format!");
     }
 
     if (aOutUploadSize) {
         *aOutUploadSize = 0;
     }
 
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -827,28 +827,18 @@ CompositorOGL::GetShaderConfigFor(Effect
 {
   ShaderConfigOGL config;
 
   switch(aEffect->mType) {
   case EffectTypes::SOLID_COLOR:
     config.SetRenderColor(true);
     break;
   case EffectTypes::YCBCR:
-  {
     config.SetYCbCr(true);
-    EffectYCbCr* effectYCbCr =
-      static_cast<EffectYCbCr*>(aEffect);
-    uint32_t pixelBits = (8 * BytesPerPixel(SurfaceFormatForAlphaDepth(effectYCbCr->mDepth)));
-    uint32_t paddingBits = pixelBits - effectYCbCr->mDepth;
-    // OpenGL expects values between [0,255], this range needs to be adjusted
-    // according to the bit depth.
-    // So we will scale the YUV values by this amount.
-    config.SetColorMultiplier(pow(2, paddingBits));
     break;
-  }
   case EffectTypes::NV12:
     config.SetNV12(true);
     config.SetTextureTarget(LOCAL_GL_TEXTURE_RECTANGLE_ARB);
     break;
   case EffectTypes::COMPONENT_ALPHA:
   {
     config.SetComponentAlpha(true);
     EffectComponentAlpha* effectComponentAlpha =
--- a/gfx/layers/opengl/OGLShaderProgram.cpp
+++ b/gfx/layers/opengl/OGLShaderProgram.cpp
@@ -110,23 +110,16 @@ ShaderConfigOGL::SetOpacity(bool aEnable
 void
 ShaderConfigOGL::SetYCbCr(bool aEnabled)
 {
   SetFeature(ENABLE_TEXTURE_YCBCR, aEnabled);
   MOZ_ASSERT(!(mFeatures & ENABLE_TEXTURE_NV12));
 }
 
 void
-ShaderConfigOGL::SetColorMultiplier(uint32_t aMultiplier)
-{
-  MOZ_ASSERT(mFeatures & ENABLE_TEXTURE_YCBCR, "Multiplier only supported with YCbCr!");
-  mMultiplier = aMultiplier;
-}
-
-void
 ShaderConfigOGL::SetNV12(bool aEnabled)
 {
   SetFeature(ENABLE_TEXTURE_NV12, aEnabled);
   MOZ_ASSERT(!(mFeatures & ENABLE_TEXTURE_YCBCR));
 }
 
 void
 ShaderConfigOGL::SetComponentAlpha(bool aEnabled)
@@ -443,22 +436,21 @@ ProgramProfileOGL::GetProfileFor(ShaderC
           fs << "  COLOR_PRECISION float cb = " << texture2D << "(uCbTexture, coord * uCbCrTexCoordMultiplier).r;" << endl;
           fs << "  COLOR_PRECISION float cr = " << texture2D << "(uCbTexture, coord * uCbCrTexCoordMultiplier).a;" << endl;
         } else {
           fs << "  COLOR_PRECISION float y = " << texture2D << "(uYTexture, coord).r;" << endl;
           fs << "  COLOR_PRECISION float cb = " << texture2D << "(uCbTexture, coord).r;" << endl;
           fs << "  COLOR_PRECISION float cr = " << texture2D << "(uCbTexture, coord).a;" << endl;
         }
       }
+
+      fs << "  y = y - 0.06275;" << endl;
+      fs << "  cb = cb - 0.50196;" << endl;
+      fs << "  cr = cr - 0.50196;" << endl;
       fs << "  vec3 yuv = vec3(y, cb, cr);" << endl;
-      if (aConfig.mMultiplier != 1) {
-        fs << "  yuv *= " << aConfig.mMultiplier << ".0;" << endl;
-      }
-      fs << "  vec3 coeff = vec3(0.06275, 0.50196, 0.50196 );" << endl;
-      fs << "  yuv -= coeff;" << endl;
       fs << "  color.rgb = uYuvColorMatrix * yuv;" << endl;
       fs << "  color.a = 1.0;" << endl;
     } else if (aConfig.mFeatures & ENABLE_TEXTURE_COMPONENT_ALPHA) {
       if (aConfig.mFeatures & ENABLE_TEXTURE_RECT) {
         fs << "  COLOR_PRECISION vec3 onBlack = " << texture2D << "(uBlackTexture, coord * uTexCoordMultiplier).rgb;" << endl;
         fs << "  COLOR_PRECISION vec3 onWhite = " << texture2D << "(uWhiteTexture, coord * uTexCoordMultiplier).rgb;" << endl;
       } else {
         fs << "  COLOR_PRECISION vec3 onBlack = " << texture2D << "(uBlackTexture, coord).rgb;" << endl;
--- a/gfx/layers/opengl/OGLShaderProgram.h
+++ b/gfx/layers/opengl/OGLShaderProgram.h
@@ -207,61 +207,52 @@ public:
     float f1;
     float f16v[16];
   } mValue;
 };
 
 class ShaderConfigOGL
 {
 public:
-  ShaderConfigOGL()
-    : mFeatures(0)
-    , mMultiplier(1)
-    , mCompositionOp(gfx::CompositionOp::OP_OVER)
-  {
-  }
+  ShaderConfigOGL() :
+    mFeatures(0),
+    mCompositionOp(gfx::CompositionOp::OP_OVER)
+  {}
 
   void SetRenderColor(bool aEnabled);
   void SetTextureTarget(GLenum aTarget);
   void SetRBSwap(bool aEnabled);
   void SetNoAlpha(bool aEnabled);
   void SetOpacity(bool aEnabled);
   void SetYCbCr(bool aEnabled);
   void SetNV12(bool aEnabled);
   void SetComponentAlpha(bool aEnabled);
   void SetColorMatrix(bool aEnabled);
   void SetBlur(bool aEnabled);
   void SetMask(bool aEnabled);
   void SetDEAA(bool aEnabled);
   void SetCompositionOp(gfx::CompositionOp aOp);
   void SetNoPremultipliedAlpha();
   void SetDynamicGeometry(bool aEnabled);
-  void SetColorMultiplier(uint32_t aMultiplier);
 
-  bool operator< (const ShaderConfigOGL& other) const
-  {
+  bool operator< (const ShaderConfigOGL& other) const {
     return mFeatures < other.mFeatures ||
            (mFeatures == other.mFeatures &&
-            (int)mCompositionOp < (int)other.mCompositionOp) ||
-           (mFeatures == other.mFeatures &&
-            (int)mCompositionOp == (int)other.mCompositionOp &&
-            mMultiplier < other.mMultiplier);
+            (int)mCompositionOp < (int)other.mCompositionOp);
   }
 
 public:
-  void SetFeature(int aBitmask, bool aState)
-  {
+  void SetFeature(int aBitmask, bool aState) {
     if (aState)
       mFeatures |= aBitmask;
     else
       mFeatures &= (~aBitmask);
   }
 
   int mFeatures;
-  uint32_t mMultiplier;
   gfx::CompositionOp mCompositionOp;
 };
 
 static inline ShaderConfigOGL
 ShaderConfigFromTargetAndFormat(GLenum aTarget,
                                 gfx::SurfaceFormat aFormat)
 {
   ShaderConfigOGL config;
@@ -403,17 +394,17 @@ public:
   void SetTextureTransform(const gfx::Matrix4x4& aMatrix) {
     SetMatrixUniform(KnownUniform::TextureTransform, aMatrix);
   }
 
   void SetTextureRects(const gfx::Rect* aRects) {
     float vals[16] = { aRects[0].x, aRects[0].y, aRects[0].Width(), aRects[0].Height(),
                        aRects[1].x, aRects[1].y, aRects[1].Width(), aRects[1].Height(),
                        aRects[2].x, aRects[2].y, aRects[2].Width(), aRects[2].Height(),
-                       aRects[3].x, aRects[3].y, aRects[3].Width(), aRects[3].Height() };
+                       aRects[3].x, aRects[3].y, aRects[3].Width(), aRects[3].Height() }; 
     SetUniform(KnownUniform::TextureRects, 16, vals);
   }
 
   void SetRenderOffset(const nsIntPoint& aOffset) {
     float vals[4] = { float(aOffset.x), float(aOffset.y) };
     SetUniform(KnownUniform::RenderTargetOffset, 2, vals);
   }