Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NV12 and TEXTURE_EXTERNAL_OES target support in WR. #1150

Merged
merged 21 commits into from Apr 27, 2017
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
deeebf5
Remove the vStretchSize assignment in ps_image vertex shader
JerryShih Apr 19, 2017
06d7376
Add samplerExternalOES support.
JerryShih Apr 19, 2017
bfc555f
Remove the unused data member in YuvImage.
JerryShih Apr 19, 2017
9dfebbb
Add samplerExternalOES support in ps_image shader.
JerryShih Apr 20, 2017
a559829
Use preprocessor to select the yuv color matrix in ps_yuv_image shader.
JerryShih Apr 20, 2017
0f5a96f
Reorder some function calls in ps_yuv_image shader.
JerryShih Apr 20, 2017
c75bb28
Add samplerExternalOES, sampler2dRect target and NV12 format support …
JerryShih Apr 20, 2017
7f53f91
Add new package in webrender and webrender_traits.
JerryShih Apr 20, 2017
652735a
Add enum ImageBufferKind, ImageBufferKind and YuvColorSpace.
JerryShih Apr 20, 2017
5a65e6c
Update push_yuv_image() interface.
JerryShih Apr 20, 2017
f734c68
Remove the match of |_| with ExternalImageType type.
JerryShih Apr 20, 2017
41ce8dd
Pass ImageBufferKind, YuvFormat and YuvColorSpace in AlphaBatchKind t…
JerryShih Apr 20, 2017
9fe5754
Create the ps_image and ps_yuv_image arrays for different feature set…
JerryShih Apr 20, 2017
d3bd47e
Add yuv_image usage in sample.
JerryShih Apr 21, 2017
06ccad4
Set default yuv color space setting in ps_yuv_image.
JerryShih Apr 21, 2017
2e76503
Move the push_yuv_image() sample code from basic.rs to yuv.rs
JerryShih Apr 27, 2017
096f2c5
Update for review comment for ps_yuv_image shader.
JerryShih Apr 27, 2017
56b2d1d
Use a macro TEX_SAMPLE() to replace the different texture sampling fu…
JerryShih Apr 27, 2017
656303c
Remove the num::FromPrimitive usage for the enum YuvColorSpace, YuvFo…
JerryShih Apr 27, 2017
52b7331
Update for review comment.
JerryShih Apr 27, 2017
1d10e44
Add a YuvData type which contains the channel data and format informa…
JerryShih Apr 27, 2017
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use preprocessor to select the yuv color matrix in ps_yuv_image shader.

  • Loading branch information
JerryShih committed Apr 27, 2017
commit a559829b1919960207eb7a2d6c95e82a8639563a
@@ -3,6 +3,33 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// The constants added to the Y, U and V components are applied in the fragment shader.
#if defined(WR_FEATURE_YUV_REC601)
// From Rec601:
// [R] [1.1643835616438356, 0.0, 1.5960267857142858 ] [Y - 16]
// [G] = [1.1643835616438358, -0.3917622900949137, -0.8129676472377708 ] x [U - 128]
// [B] [1.1643835616438356, 2.017232142857143, 8.862867620416422e-17] [V - 128]
//
// For the range [0,1] instead of [0,255].
const mat3 YuvColorMatrix = mat3(
1.16438, 0.0, 1.59603,
1.16438, -0.39176, -0.81297,
1.16438, 2.01723, 0.0
);
#elif defined(WR_FEATURE_YUV_REC709)
// From Rec709:
// [R] [1.1643835616438356, 4.2781193979771426e-17, 1.7927410714285714] [Y - 16]
// [G] = [1.1643835616438358, -0.21324861427372963, -0.532909328559444 ] x [U - 128]
// [B] [1.1643835616438356, 2.1124017857142854, 0.0 ] [V - 128]
//
// For the range [0,1] instead of [0,255]:
const mat3 YuvColorMatrix = mat3(
1.16438, 0.0, 1.79274,
1.16438, -0.21325, -0.53291,
1.16438, 2.11240, 0.0
);
#endif

void main(void) {
#ifdef WR_FEATURE_TRANSFORM
float alpha = 0.0;
@@ -33,7 +60,7 @@ void main(void) {
float u = textureLod(sColor1, st_u, 0.0).r;
float v = textureLod(sColor2, st_v, 0.0).r;

// See the vertex shader for an explanation of where the constants come from.
vec3 rgb = vYuvColorMatrix * vec3(y - 0.06275, u - 0.50196, v - 0.50196);
// See the YuvColorMatrix definition for an explanation of where the constants come from.
vec3 rgb = YuvColorMatrix * vec3(yuv_value.x - 0.06275, yuv_value.y - 0.50196, yuv_value.z - 0.50196);
oFragColor = vec4(rgb, alpha);
}
@@ -11,8 +11,6 @@ flat varying vec2 vStretchSize;
flat varying vec2 vHalfTexelY; // Normalized length of the half of a Y texel.
flat varying vec2 vHalfTexelUv; // Normalized length of the half of u and v texels.

flat varying mat3 vYuvColorMatrix;

#ifdef WR_FEATURE_TRANSFORM
varying vec3 vLocalPos;
flat varying RectWithSize vLocalRect;
@@ -53,32 +53,6 @@ void main(void) {
vHalfTexelY = vec2(0.5) / y_texture_size;
vHalfTexelUv = vec2(0.5) / uv_texture_size;

// The constants added to the Y, U and V components are applied in the fragment shader.
if (image.color_space == YUV_REC601) {
// From Rec601:
// [R] [1.1643835616438356, 0.0, 1.5960267857142858 ] [Y - 16]
// [G] = [1.1643835616438358, -0.3917622900949137, -0.8129676472377708 ] x [U - 128]
// [B] [1.1643835616438356, 2.017232142857143, 8.862867620416422e-17] [V - 128]
//
// For the range [0,1] instead of [0,255].
vYuvColorMatrix = mat3(
1.16438, 0.0, 1.59603,
1.16438, -0.39176, -0.81297,
1.16438, 2.01723, 0.0
);
} else { // if (image.color_space == YUV_REC709)
// From Rec709:
// [R] [1.1643835616438356, 4.2781193979771426e-17, 1.7927410714285714] [Y - 16]
// [G] = [1.1643835616438358, -0.21324861427372963, -0.532909328559444 ] x [U - 128]
// [B] [1.1643835616438356, 2.1124017857142854, 0.0 ] [V - 128]
//
// For the range [0,1] instead of [0,255]:
vYuvColorMatrix = mat3(
1.16438, 0.0, 1.79274,
1.16438, -0.21325, -0.53291,
1.16438, 2.11240, 0.0
);
}

write_clip(vi.screen_pos, prim.clip_area);

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.