Bug 1191527 - Fix the YCbCr shaders in BlitImageToFramebuffer. r=jgilbert
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 07 Aug 2015 15:37:54 -0400
changeset 288527 d5ce8d41ffbfa30f3c030577915406187b80235d
parent 288526 ff5f77b0dc71f6ee25f68a04d1db04857e53d1a9
child 288528 4e63305fe592b0131892eb432cc7332e850ca752
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1191527
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1191527 - Fix the YCbCr shaders in BlitImageToFramebuffer. r=jgilbert
gfx/gl/GLBlitHelper.cpp
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -273,29 +273,29 @@ GLBlitHelper::InitTexQuadProgram(BlitTyp
 
     For [0,1] instead of [0,255], and to 5 places:
     [R] [1.16438, 0.00000, 1.59603] [ Y - 0.06275]
     [G] = [1.16438, -0.39176, -0.81297] x [Cb - 0.50196]
     [B] [1.16438, 2.01723, 0.00000] [Cr - 0.50196]
     */
     const char kTexYUVPlanarBlit_FragShaderSource[] = "\
         #ifdef GL_ES                                                        \n\
-        precision mediump float                                             \n\
+        precision mediump float;                                            \n\
         #endif                                                              \n\
         varying vec2 vTexCoord;                                             \n\
         uniform sampler2D uYTexture;                                        \n\
         uniform sampler2D uCbTexture;                                       \n\
         uniform sampler2D uCrTexture;                                       \n\
         uniform vec2 uYTexScale;                                            \n\
         uniform vec2 uCbCrTexScale;                                         \n\
         void main()                                                         \n\
         {                                                                   \n\
-            float y = texture2D(uYTexture, vTexCoord * uYTexScale).r;       \n\
-            float cb = texture2D(uCbTexture, vTexCoord * uCbCrTexScale).r;  \n\
-            float cr = texture2D(uCrTexture, vTexCoord * uCbCrTexScale).r;  \n\
+            float y = texture2D(uYTexture, vTexCoord * uYTexScale).a;       \n\
+            float cb = texture2D(uCbTexture, vTexCoord * uCbCrTexScale).a;  \n\
+            float cr = texture2D(uCrTexture, vTexCoord * uCbCrTexScale).a;  \n\
             y = (y - 0.06275) * 1.16438;                                    \n\
             cb = cb - 0.50196;                                              \n\
             cr = cr - 0.50196;                                              \n\
             gl_FragColor.r = y + cr * 1.59603;                              \n\
             gl_FragColor.g = y - 0.81297 * cr - 0.39176 * cb;               \n\
             gl_FragColor.b = y + cb * 2.01723;                              \n\
             gl_FragColor.a = 1.0;                                           \n\
         }                                                                   \n\
@@ -636,40 +636,40 @@ GLBlitHelper::BindAndUploadYUVTexture(Ch
                                       void* data,
                                       bool needsAllocation)
 {
     MOZ_ASSERT(which < Channel_Max, "Invalid channel!");
     GLuint* srcTexArr[3] = {&mSrcTexY, &mSrcTexCb, &mSrcTexCr};
     GLuint& tex = *srcTexArr[which];
     if (!tex) {
         MOZ_ASSERT(needsAllocation);
-        tex = CreateTexture(mGL, LOCAL_GL_LUMINANCE, LOCAL_GL_LUMINANCE, LOCAL_GL_UNSIGNED_BYTE,
+        tex = CreateTexture(mGL, LOCAL_GL_ALPHA, LOCAL_GL_ALPHA, LOCAL_GL_UNSIGNED_BYTE,
                             gfx::IntSize(width, height), false);
     }
     mGL->fActiveTexture(LOCAL_GL_TEXTURE0 + which);
 
     mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, tex);
     if (!needsAllocation) {
         mGL->fTexSubImage2D(LOCAL_GL_TEXTURE_2D,
                             0,
                             0,
                             0,
                             width,
                             height,
-                            LOCAL_GL_LUMINANCE,
+                            LOCAL_GL_ALPHA,
                             LOCAL_GL_UNSIGNED_BYTE,
                             data);
     } else {
         mGL->fTexImage2D(LOCAL_GL_TEXTURE_2D,
                          0,
-                         LOCAL_GL_LUMINANCE,
+                         LOCAL_GL_ALPHA,
                          width,
                          height,
                          0,
-                         LOCAL_GL_LUMINANCE,
+                         LOCAL_GL_ALPHA,
                          LOCAL_GL_UNSIGNED_BYTE,
                          data);
     }
 }
 
 void
 GLBlitHelper::BindAndUploadEGLImage(EGLImage image, GLuint target)
 {