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

Send an IpcSharedMemory in tex_image_2d and tex_sub_image_2d #22225

Merged
merged 9 commits into from Nov 21, 2018

Call prepare_pixels on the WebGL thread

  • Loading branch information
nox committed Nov 20, 2018
commit ca62b5c318bc101dce49be99302dae0abed1dfd2
@@ -1045,25 +1045,40 @@ impl WebGLImpl {
WebGLCommand::TexImage2D {
target,
level,
internal_format,
effective_internal_format,
size,
format,
data_type,
effective_data_type,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
ref receiver,
} => {
let pixels = prepare_pixels(
format,
data_type,
size,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
receiver.recv().unwrap(),
);

ctx.gl()
.pixel_store_i(gl::UNPACK_ALIGNMENT, unpacking_alignment as i32);
ctx.gl().tex_image_2d(
target,
level as i32,
internal_format as i32,
effective_internal_format as i32,
size.width as i32,
size.height as i32,
0,
format,
data_type,
Some(&receiver.recv().unwrap()),
format.as_gl_constant(),
effective_data_type,
Some(&pixels),
);
},
WebGLCommand::TexSubImage2D {
@@ -1074,9 +1089,24 @@ impl WebGLImpl {
size,
format,
data_type,
effective_data_type,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
ref receiver,
} => {
let pixels = prepare_pixels(
format,
data_type,
size,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
receiver.recv().unwrap(),
);

ctx.gl()
.pixel_store_i(gl::UNPACK_ALIGNMENT, unpacking_alignment as i32);
ctx.gl().tex_sub_image_2d(
@@ -1086,9 +1116,9 @@ impl WebGLImpl {
yoffset,
size.width as i32,
size.height as i32,
format,
data_type,
&receiver.recv().unwrap(),
format.as_gl_constant(),
effective_data_type,
&pixels,
);
},
WebGLCommand::DrawingBufferWidth(ref sender) => sender
@@ -275,11 +275,17 @@ pub enum WebGLCommand {
TexImage2D {
target: u32,
level: u32,
internal_format: u32,
// FIXME(nox): This should be computed on the WebGL thread.
effective_internal_format: u32,
size: Size2D<u32>,
format: u32,
data_type: u32,
format: TexFormat,
data_type: TexDataType,
// FIXME(nox): This should be computed on the WebGL thread.
effective_data_type: u32,
unpacking_alignment: u32,
alpha_treatment: Option<AlphaTreatment>,
y_axis_treatment: YAxisTreatment,
tex_source: TexSource,
receiver: IpcBytesReceiver,
},
TexSubImage2D {
@@ -288,9 +294,14 @@ pub enum WebGLCommand {
xoffset: i32,
yoffset: i32,
size: Size2D<u32>,
format: u32,
data_type: u32,
format: TexFormat,
data_type: TexDataType,
// FIXME(nox): This should be computed on the WebGL thread.
effective_data_type: u32,
unpacking_alignment: u32,
alpha_treatment: Option<AlphaTreatment>,
y_axis_treatment: YAxisTreatment,
tex_source: TexSource,
receiver: IpcBytesReceiver,
},
DrawingBufferWidth(WebGLSender<i32>),
@@ -671,7 +682,8 @@ pub fn is_gles() -> bool {
macro_rules! gl_enums {
($(pub enum $name:ident { $($variant:ident = $mod:ident::$constant:ident,)+ })*) => {
$(
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf)]
#[derive(PartialEq, Serialize)]
#[repr(u32)]
pub enum $name { $($variant = $mod::$constant,)+ }

@@ -755,19 +767,19 @@ impl TexDataType {
}
}

#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
pub enum AlphaTreatment {
Premultiply,
Unmultiply,
}

#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
pub enum YAxisTreatment {
AsIs,
Flipped,
}

#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq)]
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)]
pub enum TexSource {
FromHtmlElement,
FromArray,
@@ -89,7 +89,7 @@ script_layout_interface = {path = "../script_layout_interface"}
script_plugins = {path = "../script_plugins"}
script_traits = {path = "../script_traits"}
selectors = { path = "../selectors" }
serde = "1.0"
serde = {version = "1", features = ["derive"]}
serde_bytes = "0.10"
servo_allocator = {path = "../allocator"}
servo_arc = {path = "../servo_arc"}
@@ -6,7 +6,7 @@
use backtrace::Backtrace;
use canvas_traits::webgl::WebGLError::*;
use canvas_traits::webgl::{
self, webgl_channel, AlphaTreatment, DOMToTextureCommand, Parameter, TexDataType, TexFormat,
webgl_channel, AlphaTreatment, DOMToTextureCommand, Parameter, TexDataType, TexFormat,
TexParameter, TexSource, WebGLCommand, WebGLCommandBacktrace, WebGLContextShareMode,
WebGLError, WebGLFramebufferBindingRequest, WebGLMsg, WebGLMsgSender, WebGLProgramId,
WebGLResult, WebGLSLVersion, WebGLSender, WebGLVersion, WebVRCommand, YAxisTreatment,
@@ -643,7 +643,7 @@ impl WebGLRenderingContext {
texture: &WebGLTexture,
target: TexImageTarget,
data_type: TexDataType,
internal_format: TexFormat,
format: TexFormat,
level: u32,
_border: u32,
unpacking_alignment: u32,
@@ -658,7 +658,7 @@ impl WebGLRenderingContext {
pixels.size.width,
pixels.size.height,
1,
internal_format,
format,
level,
Some(data_type)
)
@@ -679,36 +679,30 @@ impl WebGLRenderingContext {
YAxisTreatment::AsIs
};

let buff = webgl::prepare_pixels(
internal_format,
data_type,
pixels.size,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
pixels.data,
);

let format = internal_format.as_gl_constant();
let data_type = data_type.as_gl_constant();
let internal_format = self
let effective_internal_format = self
.extension_manager
.get_effective_tex_internal_format(format, data_type);
.get_effective_tex_internal_format(format.as_gl_constant(), data_type.as_gl_constant());
let effective_data_type = self
.extension_manager
.effective_type(data_type.as_gl_constant());

// TODO(emilio): convert colorspace if requested
let (sender, receiver) = ipc::bytes_channel().unwrap();
self.send_command(WebGLCommand::TexImage2D {
target: target.as_gl_constant(),
level,
internal_format,
effective_internal_format,
size: pixels.size,
format,
data_type: self.extension_manager.effective_type(data_type),
data_type,
effective_data_type,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
receiver,
});
sender.send(&buff).unwrap();
sender.send(&pixels.data).unwrap();

if let Some(fb) = self.bound_framebuffer.get() {
fb.invalidate_texture(&*texture);
@@ -765,16 +759,9 @@ impl WebGLRenderingContext {
YAxisTreatment::AsIs
};

let buff = webgl::prepare_pixels(
format,
data_type,
pixels.size,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
pixels.data,
);
let effective_data_type = self
.extension_manager
.effective_type(data_type.as_gl_constant());

This comment has been minimized.

Copy link
@emilio

emilio Nov 21, 2018

Member

Why doesn't textSubImage2D need to go through the EM in order to get the effective internal format?

This comment has been minimized.

Copy link
@nox

nox Nov 21, 2018

Author Member

It was like that before, and using it makes everything panic on the GL side.


// TODO(emilio): convert colorspace if requested
let (sender, receiver) = ipc::bytes_channel().unwrap();
@@ -784,14 +771,16 @@ impl WebGLRenderingContext {
xoffset,
yoffset,
size: pixels.size,
format: format.as_gl_constant(),
data_type: self
.extension_manager
.effective_type(data_type.as_gl_constant()),
format,
data_type,
effective_data_type,
unpacking_alignment,
alpha_treatment,
y_axis_treatment,
tex_source,
receiver,
});
sender.send(&buff).unwrap();
sender.send(&pixels.data).unwrap();
}

fn get_gl_extensions(&self) -> String {
@@ -46,6 +46,8 @@ extern crate malloc_size_of_derive;
#[macro_use]
extern crate profile_traits;
#[macro_use]
extern crate serde;
#[macro_use]
extern crate servo_atoms;
#[macro_use]
extern crate style;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.