Bug 1373702 - (wip) WebGL fast video patch for MacIOSSurface draft
authorDaosheng Mu <daoshengmu@gmail.com>
Thu, 22 Jun 2017 18:09:03 +0800
changeset 598848 eb1e35fe2aead502056a3f16f88c33f8318a0d99
parent 597883 e1e4a481b7e88dce163b9cccc2fb72032023befa
child 634603 4445e635c9a92a0e6ec5690daf40b846565fd46a
push id65344
push userbmo:dmu@mozilla.com
push dateThu, 22 Jun 2017 10:09:25 +0000
bugs1373702
milestone56.0a1
Bug 1373702 - (wip) WebGL fast video patch for MacIOSSurface MozReview-Commit-ID: 8uGulISSRGJ
gfx/2d/MacIOSurface.cpp
gfx/gl/GLBlitHelper.cpp
--- a/gfx/2d/MacIOSurface.cpp
+++ b/gfx/2d/MacIOSurface.cpp
@@ -537,17 +537,17 @@ MacIOSurface::CGLTexImageIOSurface2D(moz
       internalFormat = format = (isCompatibilityProfile) ? (LOCAL_GL_LUMINANCE_ALPHA)
                                                           : (LOCAL_GL_RG);
     }
     type = LOCAL_GL_UNSIGNED_BYTE;
     if (aOutReadFormat) {
       *aOutReadFormat = mozilla::gfx::SurfaceFormat::NV12;
     }
   } else if (pixelFormat == '2vuy') {
-    MOZ_ASSERT(plane == 0);
+   // MOZ_ASSERT(plane == 0);
     // The YCBCR_422_APPLE ext is only available in compatibility profile. So,
     // we should use RGB_422_APPLE for core profile. The difference between
     // YCBCR_422_APPLE and RGB_422_APPLE is that the YCBCR_422_APPLE converts
     // the YCbCr value to RGB with REC 601 conversion. But the RGB_422_APPLE
     // doesn't contain color conversion. You should do the color conversion by
     // yourself for RGB_422_APPLE.
     //
     // https://www.khronos.org/registry/OpenGL/extensions/APPLE/APPLE_ycbcr_422.txt
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -86,17 +86,17 @@ GLBlitHelper::~GLBlitHelper()
     mFBO = 0;
 }
 
 // Allowed to be destructive of state we restore in functions below.
 bool
 GLBlitHelper::InitTexQuadProgram(BlitType target)
 {
     const char kTexBlit_VertShaderSource[] = "\
-        #version 100                                  \n\
+        #version 120                                  \n\
         #ifdef GL_ES                                  \n\
         precision mediump float;                      \n\
         #endif                                        \n\
         attribute vec2 aPosition;                     \n\
                                                       \n\
         uniform float uYflip;                         \n\
         varying vec2 vTexCoord;                       \n\
                                                       \n\
@@ -210,33 +210,32 @@ GLBlitHelper::InitTexQuadProgram(BlitTyp
             vec3 yuv = vec3(y, cb, cr);                                     \n\
             gl_FragColor.rgb = uYuvColorMatrix * yuv;                       \n\
             gl_FragColor.a = 1.0;                                           \n\
         }                                                                   \n\
     ";
 
 #ifdef XP_MACOSX
     const char kTexNV12PlanarBlit_FragShaderSource[] = "\
-        #version 100                                                             \n\
+        #version 120                                                             \n\
         #extension GL_ARB_texture_rectangle : require                            \n\
         #ifdef GL_ES                                                             \n\
         precision mediump float                                                  \n\
         #endif                                                                   \n\
         varying vec2 vTexCoord;                                                  \n\
         uniform sampler2DRect uYTexture;                                         \n\
         uniform sampler2DRect uCbCrTexture;                                      \n\
         uniform vec2 uYTexScale;                                                 \n\
         uniform vec2 uCbCrTexScale;                                              \n\
         void main()                                                              \n\
         {                                                                        \n\
             float y = texture2DRect(uYTexture, vTexCoord * uYTexScale).r;        \n\
             float cb = texture2DRect(uCbCrTexture, vTexCoord * uCbCrTexScale).r; \n\
             float cr = texture2DRect(uCbCrTexture, 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\
     ";
 #endif