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

Prev

Add a YuvData type which contains the channel data and format informa…

…tion.
  • Loading branch information
JerryShih committed Apr 27, 2017
commit 1d10e4480a8e860fab4847c51f18b535fa9eda51
@@ -18,7 +18,7 @@ use webrender_traits::{ClipRegion, ColorF, Epoch};
use webrender_traits::{DeviceIntPoint, DeviceUintSize, LayoutPoint, LayoutRect, LayoutSize};
use webrender_traits::{ImageData, ImageDescriptor, ImageFormat};
use webrender_traits::{PipelineId, TransformStyle};
use webrender_traits::{YuvColorSpace, YuvFormat};
use webrender_traits::{YuvColorSpace, YuvData};

#[derive(Debug)]
enum Gesture {
@@ -278,20 +278,14 @@ fn main() {
builder.push_yuv_image(
LayoutRect::new(LayoutPoint::new(100.0, 0.0), LayoutSize::new(100.0, 100.0)),
ClipRegion::simple(&bounds),
yuv_chanel1,
Some(yuv_chanel2),
None,
YuvFormat::NV12,
YuvData::NV12(yuv_chanel1, yuv_chanel2),
YuvColorSpace::Rec601,
);

builder.push_yuv_image(
LayoutRect::new(LayoutPoint::new(300.0, 0.0), LayoutSize::new(100.0, 100.0)),
ClipRegion::simple(&bounds),
yuv_chanel1,
Some(yuv_chanel2_1),
Some(yuv_chanel3),
YuvFormat::PlanarYCbCr,
YuvData::PlanarYCbCr(yuv_chanel1, yuv_chanel2_1, yuv_chanel3),
YuvColorSpace::Rec601,
);

@@ -348,4 +342,5 @@ fn main() {
renderer.render(DeviceUintSize::new(width, height));
window.swap_buffers().ok();
}
}
}

@@ -594,10 +594,7 @@ impl Frame {
context.builder.add_yuv_image(clip_and_scroll,
item.rect,
&item.clip,
info.plane_0_image_key,
info.plane_1_image_key,
info.plane_2_image_key,
info.format,
info.yuv_data,
info.color_space);
}
SpecificDisplayItem::Text(ref text_info) => {
@@ -31,7 +31,7 @@ use webrender_traits::{ClipId, ClipRegion, ColorF, DeviceIntPoint, DeviceIntRect
use webrender_traits::{DeviceUintRect, DeviceUintSize, ExtendMode, FontKey, FontRenderMode};
use webrender_traits::{GlyphOptions, ImageKey, ImageRendering, ItemRange, LayerPoint, LayerRect};
use webrender_traits::{LayerSize, LayerToScrollTransform, PipelineId, RepeatMode, TileOffset};
use webrender_traits::{TransformStyle, WebGLContextId, YuvColorSpace, YuvFormat};
use webrender_traits::{TransformStyle, WebGLContextId, YuvColorSpace, YuvData};

#[derive(Debug, Clone)]
struct ImageBorderSegment {
@@ -1014,18 +1014,17 @@ impl FrameBuilder {
clip_and_scroll: ClipAndScrollInfo,
rect: LayerRect,
clip_region: &ClipRegion,
plane_0_image_key: ImageKey,
plane_1_image_key: Option<ImageKey>,
plane_2_image_key: Option<ImageKey>,
format: YuvFormat,
yuv_data: YuvData,
color_space: YuvColorSpace) {
let format = yuv_data.get_format();
let yuv_key = match yuv_data {
YuvData::NV12(plane_0, plane_1) => [plane_0, plane_1, ImageKey::new(0, 0)],
YuvData::PlanarYCbCr(plane_0, plane_1, plane_2) =>
[plane_0, plane_1, plane_2],
};

let prim_cpu = YuvImagePrimitiveCpu {
yuv_key: [
plane_0_image_key,
plane_1_image_key.unwrap_or(ImageKey::new(0, 0)),
plane_2_image_key.unwrap_or(ImageKey::new(0, 0)),
],
yuv_key: yuv_key,
yuv_texture_id: [SourceTexture::Invalid, SourceTexture::Invalid, SourceTexture::Invalid],
yuv_resource_address: GpuStoreAddress(0),
format: format,
@@ -355,11 +355,7 @@ pub enum ImageRendering {

#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
pub struct YuvImageDisplayItem {
// YUV image could have 1 to 3 planes.
pub plane_0_image_key: ImageKey,
pub plane_1_image_key: Option<ImageKey>,
pub plane_2_image_key: Option<ImageKey>,
pub format: YuvFormat,
pub yuv_data: YuvData,
pub color_space: YuvColorSpace,
}

@@ -379,6 +375,21 @@ impl YuvColorSpace {
}
}

#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum YuvData {
NV12(ImageKey, ImageKey),
PlanarYCbCr(ImageKey, ImageKey, ImageKey),
}

impl YuvData {
pub fn get_format(&self) -> YuvFormat {
match *self {
YuvData::NV12(..) => YuvFormat::NV12,
YuvData::PlanarYCbCr(..) => YuvFormat::PlanarYCbCr,
}
}
}

#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum YuvFormat {
NV12 = 0,
@@ -14,7 +14,7 @@ use {ImageRendering, ItemRange, LayoutPoint, LayoutRect, LayoutSize, LayoutTrans
use {MixBlendMode, PipelineId, PropertyBinding, PushStackingContextDisplayItem, RadialGradient};
use {RadialGradientDisplayItem, RectangleDisplayItem, ScrollPolicy, SpecificDisplayItem};
use {StackingContext, TextDisplayItem, TransformStyle, WebGLContextId, WebGLDisplayItem};
use {YuvColorSpace, YuvFormat, YuvImageDisplayItem};
use {YuvColorSpace, YuvData, YuvImageDisplayItem};

#[derive(Clone, Deserialize, Serialize)]
pub struct AuxiliaryLists {
@@ -179,32 +179,14 @@ impl DisplayListBuilder {
self.push_item(item, rect, clip);
}

/// Push a yuv image. The number of input plane should match the format.
/// e.g.
/// NV12 should have 2 planes.
///
/// All planar data should use the same buffer type.
/// Push a yuv image. All planar data in yuv image should use the same buffer type.
pub fn push_yuv_image(&mut self,
rect: LayoutRect,
clip: ClipRegion,
plane_0_image_key: ImageKey,
plane_1_image_key: Option<ImageKey>,
plane_2_image_key: Option<ImageKey>,
format: YuvFormat,
yuv_data: YuvData,
color_space: YuvColorSpace) {
// Check the plane number for the YuvFormat.
match format.get_plane_num() {
1 => debug_assert!(plane_1_image_key.is_none() && plane_2_image_key.is_none()),
2 => debug_assert!(plane_1_image_key.is_some() && plane_2_image_key.is_none()),
3 => debug_assert!(plane_1_image_key.is_some() && plane_2_image_key.is_some()),
_ => debug_assert!(false),
}

let item = SpecificDisplayItem::YuvImage(YuvImageDisplayItem {
plane_0_image_key: plane_0_image_key,
plane_1_image_key: plane_1_image_key,
plane_2_image_key: plane_2_image_key,
format: format,
yuv_data: yuv_data,
color_space: color_space,
});
self.push_item(item, rect, clip);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.