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

Remove the num::FromPrimitive usage for the enum YuvColorSpace, YuvFo…

…rmat and ImageBufferKind.
  • Loading branch information
JerryShih committed Apr 27, 2017
commit 656303c15409980badb4371923b5507d64a19cf9

Some generated files are not rendered by default. Learn more.

@@ -30,8 +30,6 @@ webrender_traits = {path = "../webrender_traits"}
bitflags = "0.7"
gamma-lut = "0.1"
thread_profiler = "0.1.1"
enum_primitive = "0.1.1"
num = "0.1.32"

[dev-dependencies]
angle = {git = "https://github.com/servo/angle", branch = "servo"}
@@ -45,10 +45,6 @@ extern crate bitflags;
#[macro_use]
extern crate thread_profiler;

#[macro_use]
extern crate enum_primitive;
extern crate num;

mod border;
mod clip_scroll_node;
mod clip_scroll_tree;
@@ -22,7 +22,6 @@ use internal_types::{CacheTextureId, RendererFrame, ResultMsg, TextureUpdateOp};
use internal_types::{TextureUpdateList, PackedVertex, RenderTargetMode};
use internal_types::{ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE, SourceTexture};
use internal_types::{BatchTextures, TextureSampler};
use num::FromPrimitive;
use prim_store::GradientData;
use profiler::{Profiler, BackendProfileCounters};
use profiler::{GpuProfileTag, RendererProfileTimers, RendererProfileCounters};
@@ -56,6 +55,7 @@ use webrender_traits::{ImageDescriptor, BlobImageRenderer};
use webrender_traits::channel;
use webrender_traits::VRCompositorHandler;
use webrender_traits::{YuvColorSpace, YuvFormat};
use webrender_traits::{YUV_COLOR_SPACES, YUV_FORMATS};

pub const GPU_DATA_TEXTURE_POOL: usize = 5;
pub const MAX_VERTEX_TEXTURE_WIDTH: usize = 1024;
@@ -82,42 +82,41 @@ const GPU_TAG_PRIM_BORDER_EDGE: GpuProfileTag = GpuProfileTag { label: "BorderEd
const GPU_TAG_PRIM_CACHE_IMAGE: GpuProfileTag = GpuProfileTag { label: "CacheImage", color: debug_colors::SILVER };
const GPU_TAG_BLUR: GpuProfileTag = GpuProfileTag { label: "Blur", color: debug_colors::VIOLET };

enum_from_primitive! {
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum ImageBufferKind {
Texture2D = 0,
TextureRect = 1,
TextureExternal = 2,
TotalNum = 3,
}
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub enum ImageBufferKind {
Texture2D = 0,
TextureRect = 1,
TextureExternal = 2,
}
pub const IMAGE_BUFFER_KINDS: [ImageBufferKind; 3] = [
ImageBufferKind::Texture2D,
ImageBufferKind::TextureRect,
ImageBufferKind::TextureExternal
];

impl ImageBufferKind {
pub fn get_feature_string(&self) -> &'static str {
match *self {
ImageBufferKind::Texture2D => "",
ImageBufferKind::TextureRect => "TEXTURE_RECT",
ImageBufferKind::TextureExternal => "TEXTURE_EXTERNAL",
ImageBufferKind::TotalNum => "Invalid",
}
}

pub fn is_platform_support(&self, gl_type: &gl::GlType) -> bool {
pub fn has_platform_support(&self, gl_type: &gl::GlType) -> bool {
match *gl_type {
gl::GlType::Gles => {
match *self {
ImageBufferKind::Texture2D => true,
ImageBufferKind::TextureRect => true,
ImageBufferKind::TextureExternal => true,
ImageBufferKind::TotalNum => false,
}
}
gl::GlType::Gl => {
match *self {
ImageBufferKind::Texture2D => true,
ImageBufferKind::TextureRect => true,
ImageBufferKind::TextureExternal => false,
ImageBufferKind::TotalNum => false,
}
}
}
@@ -716,12 +715,12 @@ impl Renderer {
let mut image_features = Vec::new();
let mut ps_image: Vec<Option<PrimitiveShader>> = Vec::new();
// PrimitiveShader is not clonable. Use push() to initialize the vec.
for _ in 0..(ImageBufferKind::TotalNum as usize) {
for _ in 0..IMAGE_BUFFER_KINDS.len() {
ps_image.push(None);
}
for buffer_kind in 0..(ImageBufferKind::TotalNum as usize) {
if ImageBufferKind::from_usize(buffer_kind).unwrap().is_platform_support(&gl_type) {
let feature_string = ImageBufferKind::from_usize(buffer_kind).unwrap().get_feature_string();
for buffer_kind in 0..IMAGE_BUFFER_KINDS.len() {
if IMAGE_BUFFER_KINDS[buffer_kind].has_platform_support(&gl_type) {
let feature_string = IMAGE_BUFFER_KINDS[buffer_kind].get_feature_string();
if feature_string != "" {
image_features.push(feature_string);
}
@@ -738,27 +737,27 @@ impl Renderer {

// All yuv_image configuration.
let mut yuv_features = Vec::new();
let yuv_shader_num = (ImageBufferKind::TotalNum as usize) *
(YuvFormat::TotalNum as usize) *
(YuvColorSpace::TotalNum as usize);
let yuv_shader_num = IMAGE_BUFFER_KINDS.len() *
YUV_FORMATS.len() *
YUV_COLOR_SPACES.len();
let mut ps_yuv_image: Vec<Option<PrimitiveShader>> = Vec::new();
// PrimitiveShader is not clonable. Use push() to initialize the vec.
for _ in 0..yuv_shader_num {
ps_yuv_image.push(None);
}
for buffer_kind in 0..(ImageBufferKind::TotalNum as usize) {
if ImageBufferKind::from_usize(buffer_kind).unwrap().is_platform_support(&gl_type) {
for format_kind in 0..(YuvFormat::TotalNum as usize) {
for color_space_kind in 0..(YuvColorSpace::TotalNum as usize) {
let feature_string = ImageBufferKind::from_usize(buffer_kind).unwrap().get_feature_string();
for buffer_kind in 0..IMAGE_BUFFER_KINDS.len() {
if IMAGE_BUFFER_KINDS[buffer_kind].has_platform_support(&gl_type) {
for format_kind in 0..YUV_FORMATS.len() {
for color_space_kind in 0..YUV_COLOR_SPACES.len() {
let feature_string = IMAGE_BUFFER_KINDS[buffer_kind].get_feature_string();
if feature_string != "" {
yuv_features.push(feature_string);
}
let feature_string = YuvFormat::from_usize(format_kind).unwrap().get_feature_string();
let feature_string = YUV_FORMATS[format_kind].get_feature_string();
if feature_string != "" {
yuv_features.push(feature_string);
}
let feature_string = YuvColorSpace::from_usize(color_space_kind).unwrap().get_feature_string();
let feature_string = YUV_COLOR_SPACES[color_space_kind].get_feature_string();
if feature_string != "" {
yuv_features.push(feature_string);
}
@@ -769,9 +768,9 @@ impl Renderer {
&yuv_features,
options.precache_shaders)
};
let index = Renderer::get_yuv_shader_index(ImageBufferKind::from_usize(buffer_kind).unwrap(),
YuvFormat::from_usize(format_kind).unwrap(),
YuvColorSpace::from_usize(color_space_kind).unwrap());
let index = Renderer::get_yuv_shader_index(IMAGE_BUFFER_KINDS[buffer_kind],
YUV_FORMATS[format_kind],
YUV_COLOR_SPACES[color_space_kind]);
ps_yuv_image[index] = Some(shader);
yuv_features.clear();
}
@@ -1075,7 +1074,7 @@ impl Renderer {
}

fn get_yuv_shader_index(buffer_kind: ImageBufferKind, format: YuvFormat, color_space: YuvColorSpace) -> usize {
((buffer_kind as usize) * (YuvFormat::TotalNum as usize) + (format as usize)) * (YuvColorSpace::TotalNum as usize) + (color_space as usize)
((buffer_kind as usize) * YUV_FORMATS.len() + (format as usize)) * YUV_COLOR_SPACES.len() + (color_space as usize)
}

pub fn gl(&self) -> &gl::Gl {
@@ -21,8 +21,6 @@ offscreen_gl_context = {version = "0.8", features = ["serde"], optional = true}
serde = "0.9"
serde_derive = "0.9"
time = "0.1"
enum_primitive = "0.1.1"
num = "0.1.32"

[target.'cfg(target_os = "macos")'.dependencies]
core-foundation = "0.3"
@@ -363,48 +363,41 @@ pub struct YuvImageDisplayItem {
pub color_space: YuvColorSpace,
}

enum_from_primitive! {
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum YuvColorSpace {
Rec601 = 0,
Rec709 = 1,
TotalNum = 2,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum YuvColorSpace {
Rec601 = 0,
Rec709 = 1,
}
pub const YUV_COLOR_SPACES: [YuvColorSpace; 2] = [YuvColorSpace::Rec601, YuvColorSpace::Rec709];

impl YuvColorSpace {
pub fn get_feature_string(&self) -> &'static str {
match *self {
YuvColorSpace::Rec601 => "YUV_REC601",
YuvColorSpace::Rec709 => "YUV_REC709",
YuvColorSpace::TotalNum => "Invalid",
}
}
}

enum_from_primitive! {
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum YuvFormat {
NV12 = 0,
PlanarYCbCr = 1,
TotalNum = 2,
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub enum YuvFormat {
NV12 = 0,
PlanarYCbCr = 1,
}
pub const YUV_FORMATS: [YuvFormat; 2] = [YuvFormat::NV12, YuvFormat::PlanarYCbCr];

impl YuvFormat {
pub fn get_plane_num(&self) -> usize {
match *self {
YuvFormat::NV12 => 2,
YuvFormat::PlanarYCbCr => 3,
YuvFormat::TotalNum => 0,
}
}

pub fn get_feature_string(&self) -> &'static str {
match *self {
YuvFormat::NV12 => "NV12",
YuvFormat::PlanarYCbCr => "",
YuvFormat::TotalNum => "Invalid",
}
}
}
@@ -31,10 +31,6 @@ extern crate core_graphics;
#[cfg(target_os = "windows")]
extern crate dwrote;

#[macro_use]
extern crate enum_primitive;
extern crate num;

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