Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Auto merge of #22202 - servo:webgl, r=jdm
Clean up some code on the WebGL texture upload paths

This doesn't actually change anything… yet.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22202)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Nov 17, 2018
2 parents e50e262 + af2b4db commit 6b1fccf
Show file tree
Hide file tree
Showing 19 changed files with 758 additions and 666 deletions.
77 changes: 51 additions & 26 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions components/canvas/canvas_data.rs
Expand Up @@ -69,7 +69,7 @@ impl<'a> CanvasData<'a> {
let source_rect = source_rect.ceil();
// It discards the extra pixels (if any) that won't be painted
let image_data = if Rect::from_size(image_size).contains_rect(&source_rect) {
pixels::get_rect(&image_data, image_size.to_u32(), source_rect.to_u32()).into()
pixels::rgba8_get_rect(&image_data, image_size.to_u32(), source_rect.to_u32()).into()
} else {
image_data.into()
};
Expand Down Expand Up @@ -510,7 +510,7 @@ impl<'a> CanvasData<'a> {
pub fn put_image_data(&mut self, mut imagedata: Vec<u8>, rect: Rect<u32>) {
assert_eq!(imagedata.len() % 4, 0);
assert_eq!(rect.size.area() as usize, imagedata.len() / 4);
pixels::byte_swap_and_premultiply_inplace(&mut imagedata);
pixels::rgba8_byte_swap_and_premultiply_inplace(&mut imagedata);
let source_surface = self
.drawtarget
.create_source_surface_from_data(
Expand Down Expand Up @@ -602,7 +602,7 @@ impl<'a> CanvasData<'a> {
return vec![];
}
let data_surface = self.drawtarget.snapshot().get_data_surface();
pixels::get_rect(
pixels::rgba8_get_rect(
unsafe { data_surface.data() },
canvas_size.to_u32(),
read_rect.to_u32(),
Expand Down
70 changes: 40 additions & 30 deletions components/canvas/webgl_thread.rs
Expand Up @@ -635,7 +635,7 @@ impl<VR: WebVRRenderHandler + 'static> WebGLThread<VR> {
let src_slice = &orig_pixels[src_start..src_start + stride];
(&mut pixels[dst_start..dst_start + stride]).clone_from_slice(&src_slice[..stride]);
}
pixels::byte_swap_colors_inplace(&mut pixels);
pixels::rgba8_byte_swap_colors_inplace(&mut pixels);
pixels
}

Expand Down Expand Up @@ -1042,47 +1042,57 @@ impl WebGLImpl {
WebGLCommand::SetViewport(x, y, width, height) => {
ctx.gl().viewport(x, y, width, height);
},
WebGLCommand::TexImage2D(
WebGLCommand::TexImage2D {
target,
level,
internal,
width,
height,
format,
data_type,
ref chan,
) => ctx.gl().tex_image_2d(
target,
level,
internal,
internal_format,
width,
height,
0,
format,
data_type,
Some(&chan.recv().unwrap()),
),
WebGLCommand::TexSubImage2D(
target,
level,
xoffset,
yoffset,
x,
y,
width,
height,
ref chan,
) => ctx.gl().tex_sub_image_2d(
unpacking_alignment,
ref receiver,
} => {
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,
width as i32,
height as i32,
0,
format,
data_type,
Some(&receiver.recv().unwrap()),
);
},
WebGLCommand::TexSubImage2D {
target,
level,
xoffset,
yoffset,
x,
y,
width,
height,
&chan.recv().unwrap(),
),
format,
data_type,
unpacking_alignment,
ref receiver,
} => {
ctx.gl()
.pixel_store_i(gl::UNPACK_ALIGNMENT, unpacking_alignment as i32);
ctx.gl().tex_sub_image_2d(
target,
level as i32,
xoffset,
yoffset,
width as i32,
height as i32,
format,
data_type,
&receiver.recv().unwrap(),
);
},
WebGLCommand::DrawingBufferWidth(ref sender) => sender
.send(ctx.borrow_draw_buffer().unwrap().size().width)
.unwrap(),
Expand Down
5 changes: 4 additions & 1 deletion components/canvas_traits/Cargo.toml
Expand Up @@ -14,14 +14,17 @@ path = "lib.rs"
webgl_backtrace = []

[dependencies]
byteorder = "1"
cssparser = "0.25"
euclid = "0.19"
ipc-channel = "0.11"
gleam = "0.6"
gleam = "0.6.7"
half = "1"
lazy_static = "1"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
offscreen_gl_context = {version = "0.21", features = ["serde"]}
pixels = {path = "../pixels"}
serde = "1.0"
serde_bytes = "0.10"
servo_config = {path = "../config"}
Expand Down
1 change: 1 addition & 0 deletions components/canvas_traits/lib.rs
Expand Up @@ -14,5 +14,6 @@ extern crate malloc_size_of_derive;
extern crate serde;

pub mod canvas;
#[macro_use]
pub mod webgl;
mod webgl_channel;

0 comments on commit 6b1fccf

Please sign in to comment.