Loading gfx/webrender_bindings/WebRenderTypes.h +2 −0 Original line number Diff line number Diff line Loading @@ -780,6 +780,8 @@ static inline wr::WrYuvColorSpace ToWrYuvColorSpace( return wr::WrYuvColorSpace::Rec709; case gfx::YUVColorSpace::BT2020: return wr::WrYuvColorSpace::Rec2020; case gfx::YUVColorSpace::Identity: return wr::WrYuvColorSpace::Identity; default: MOZ_ASSERT_UNREACHABLE("Tried to convert invalid YUVColorSpace."); } Loading gfx/wr/webrender/res/brush_yuv_image.glsl +3 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ flat varying vec4 vUvBounds_V; flat varying float vCoefficient; flat varying mat3 vYuvColorMatrix; flat varying vec3 vYuvOffsetVector; flat varying int vFormat; #ifdef WR_VERTEX_SHADER Loading Loading @@ -60,6 +61,7 @@ void yuv_brush_vs( vCoefficient = prim.coefficient; vYuvColorMatrix = get_yuv_color_matrix(prim.color_space); vYuvOffsetVector = get_yuv_offset_vector(prim.color_space); vFormat = prim.yuv_format; #ifdef WR_FEATURE_ALPHA_PASS Loading Loading @@ -94,6 +96,7 @@ Fragment yuv_brush_fs() { vec4 color = sample_yuv( vFormat, vYuvColorMatrix, vYuvOffsetVector, vCoefficient, vYuvLayers, vUv_Y, Loading gfx/wr/webrender/res/composite.glsl +3 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ #ifdef WR_FEATURE_YUV flat varying mat3 vYuvColorMatrix; flat varying vec3 vYuvOffsetVector; flat varying float vYuvCoefficient; flat varying int vYuvFormat; flat varying vec3 vYuvLayers; Loading Loading @@ -59,6 +60,7 @@ void main(void) { float yuv_coefficient = aParams.w; vYuvColorMatrix = get_yuv_color_matrix(yuv_color_space); vYuvOffsetVector = get_yuv_offset_vector(yuv_color_space); vYuvCoefficient = yuv_coefficient; vYuvFormat = yuv_format; Loading Loading @@ -120,6 +122,7 @@ void main(void) { vec4 color = sample_yuv( vYuvFormat, vYuvColorMatrix, vYuvOffsetVector, vYuvCoefficient, vYuvLayers, vUV_y, Loading gfx/wr/webrender/res/yuv.glsl +22 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #define YUV_COLOR_SPACE_REC601 0 #define YUV_COLOR_SPACE_REC709 1 #define YUV_COLOR_SPACE_REC2020 2 #define YUV_COLOR_SPACE_IDENTITY 3 // The constants added to the Y, U and V components are applied in the fragment shader. Loading Loading @@ -64,17 +65,36 @@ const mat3 YuvColorMatrixRec2020 = mat3( 1.67867410714286 , -0.650424318505057, 0.0 ); // The matrix is stored in column-major. // Identity is stored as GBR const mat3 IdentityColorMatrix = mat3( 0.0 , 1.0, 0.0, 0.0 , 0.0, 1.0, 1.0 , 0.0, 0.0 ); mat3 get_yuv_color_matrix(int color_space) { switch (color_space) { case YUV_COLOR_SPACE_REC601: return YuvColorMatrixRec601; case YUV_COLOR_SPACE_REC709: return YuvColorMatrixRec709; case YUV_COLOR_SPACE_IDENTITY: return IdentityColorMatrix; default: return YuvColorMatrixRec2020; } } vec3 get_yuv_offset_vector(int color_space) { switch (color_space) { case YUV_COLOR_SPACE_IDENTITY: return vec3(0.0, 0.0, 0.0); default: return vec3(0.06275, 0.50196, 0.50196); } } void write_uv_rect( vec2 uv0, vec2 uv1, Loading @@ -99,6 +119,7 @@ void write_uv_rect( vec4 sample_yuv( int format, mat3 yuv_color_matrix, vec3 yuv_offset_vector, float coefficient, vec3 yuv_layers, vec2 in_uv_y, Loading Loading @@ -148,7 +169,7 @@ vec4 sample_yuv( } // See the YuvColorMatrix definition for an explanation of where the constants come from. vec3 rgb = yuv_color_matrix * (yuv_value * coefficient - vec3(0.06275, 0.50196, 0.50196)); vec3 rgb = yuv_color_matrix * (yuv_value * coefficient - yuv_offset_vector); vec4 color = vec4(rgb, 1.0); return color; Loading gfx/wr/webrender_api/src/display_item.rs +1 −0 Original line number Diff line number Diff line Loading @@ -1293,6 +1293,7 @@ pub enum YuvColorSpace { Rec601 = 0, Rec709 = 1, Rec2020 = 2, Identity = 3, // aka RGB as per ISO/IEC 23091-2:2019 } #[repr(u8)] Loading Loading
gfx/webrender_bindings/WebRenderTypes.h +2 −0 Original line number Diff line number Diff line Loading @@ -780,6 +780,8 @@ static inline wr::WrYuvColorSpace ToWrYuvColorSpace( return wr::WrYuvColorSpace::Rec709; case gfx::YUVColorSpace::BT2020: return wr::WrYuvColorSpace::Rec2020; case gfx::YUVColorSpace::Identity: return wr::WrYuvColorSpace::Identity; default: MOZ_ASSERT_UNREACHABLE("Tried to convert invalid YUVColorSpace."); } Loading
gfx/wr/webrender/res/brush_yuv_image.glsl +3 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ flat varying vec4 vUvBounds_V; flat varying float vCoefficient; flat varying mat3 vYuvColorMatrix; flat varying vec3 vYuvOffsetVector; flat varying int vFormat; #ifdef WR_VERTEX_SHADER Loading Loading @@ -60,6 +61,7 @@ void yuv_brush_vs( vCoefficient = prim.coefficient; vYuvColorMatrix = get_yuv_color_matrix(prim.color_space); vYuvOffsetVector = get_yuv_offset_vector(prim.color_space); vFormat = prim.yuv_format; #ifdef WR_FEATURE_ALPHA_PASS Loading Loading @@ -94,6 +96,7 @@ Fragment yuv_brush_fs() { vec4 color = sample_yuv( vFormat, vYuvColorMatrix, vYuvOffsetVector, vCoefficient, vYuvLayers, vUv_Y, Loading
gfx/wr/webrender/res/composite.glsl +3 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ #ifdef WR_FEATURE_YUV flat varying mat3 vYuvColorMatrix; flat varying vec3 vYuvOffsetVector; flat varying float vYuvCoefficient; flat varying int vYuvFormat; flat varying vec3 vYuvLayers; Loading Loading @@ -59,6 +60,7 @@ void main(void) { float yuv_coefficient = aParams.w; vYuvColorMatrix = get_yuv_color_matrix(yuv_color_space); vYuvOffsetVector = get_yuv_offset_vector(yuv_color_space); vYuvCoefficient = yuv_coefficient; vYuvFormat = yuv_format; Loading Loading @@ -120,6 +122,7 @@ void main(void) { vec4 color = sample_yuv( vYuvFormat, vYuvColorMatrix, vYuvOffsetVector, vYuvCoefficient, vYuvLayers, vUV_y, Loading
gfx/wr/webrender/res/yuv.glsl +22 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #define YUV_COLOR_SPACE_REC601 0 #define YUV_COLOR_SPACE_REC709 1 #define YUV_COLOR_SPACE_REC2020 2 #define YUV_COLOR_SPACE_IDENTITY 3 // The constants added to the Y, U and V components are applied in the fragment shader. Loading Loading @@ -64,17 +65,36 @@ const mat3 YuvColorMatrixRec2020 = mat3( 1.67867410714286 , -0.650424318505057, 0.0 ); // The matrix is stored in column-major. // Identity is stored as GBR const mat3 IdentityColorMatrix = mat3( 0.0 , 1.0, 0.0, 0.0 , 0.0, 1.0, 1.0 , 0.0, 0.0 ); mat3 get_yuv_color_matrix(int color_space) { switch (color_space) { case YUV_COLOR_SPACE_REC601: return YuvColorMatrixRec601; case YUV_COLOR_SPACE_REC709: return YuvColorMatrixRec709; case YUV_COLOR_SPACE_IDENTITY: return IdentityColorMatrix; default: return YuvColorMatrixRec2020; } } vec3 get_yuv_offset_vector(int color_space) { switch (color_space) { case YUV_COLOR_SPACE_IDENTITY: return vec3(0.0, 0.0, 0.0); default: return vec3(0.06275, 0.50196, 0.50196); } } void write_uv_rect( vec2 uv0, vec2 uv1, Loading @@ -99,6 +119,7 @@ void write_uv_rect( vec4 sample_yuv( int format, mat3 yuv_color_matrix, vec3 yuv_offset_vector, float coefficient, vec3 yuv_layers, vec2 in_uv_y, Loading Loading @@ -148,7 +169,7 @@ vec4 sample_yuv( } // See the YuvColorMatrix definition for an explanation of where the constants come from. vec3 rgb = yuv_color_matrix * (yuv_value * coefficient - vec3(0.06275, 0.50196, 0.50196)); vec3 rgb = yuv_color_matrix * (yuv_value * coefficient - yuv_offset_vector); vec4 color = vec4(rgb, 1.0); return color; Loading
gfx/wr/webrender_api/src/display_item.rs +1 −0 Original line number Diff line number Diff line Loading @@ -1293,6 +1293,7 @@ pub enum YuvColorSpace { Rec601 = 0, Rec709 = 1, Rec2020 = 2, Identity = 3, // aka RGB as per ISO/IEC 23091-2:2019 } #[repr(u8)] Loading