mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
task -> thread
This commit is contained in:
parent
f00532bab0
commit
1f02c4ebbb
119 changed files with 1209 additions and 1207 deletions
|
@ -22,10 +22,10 @@ use std::borrow::ToOwned;
|
|||
use std::mem;
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
use util::opts;
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use util::vec::byte_swap;
|
||||
|
||||
impl<'a> CanvasPaintTask<'a> {
|
||||
impl<'a> CanvasPaintThread<'a> {
|
||||
/// It reads image data from the canvas
|
||||
/// canvas_size: The size of the canvas we're reading from
|
||||
/// read_rect: The area of the canvas we want to read from
|
||||
|
@ -57,7 +57,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct CanvasPaintTask<'a> {
|
||||
pub struct CanvasPaintThread<'a> {
|
||||
drawtarget: DrawTarget,
|
||||
/// TODO(pcwalton): Support multiple paths.
|
||||
path_builder: PathBuilder,
|
||||
|
@ -101,11 +101,11 @@ impl<'a> CanvasPaintState<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> CanvasPaintTask<'a> {
|
||||
fn new(size: Size2D<i32>) -> CanvasPaintTask<'a> {
|
||||
let draw_target = CanvasPaintTask::create(size);
|
||||
impl<'a> CanvasPaintThread<'a> {
|
||||
fn new(size: Size2D<i32>) -> CanvasPaintThread<'a> {
|
||||
let draw_target = CanvasPaintThread::create(size);
|
||||
let path_builder = draw_target.create_path_builder();
|
||||
CanvasPaintTask {
|
||||
CanvasPaintThread {
|
||||
drawtarget: draw_target,
|
||||
path_builder: path_builder,
|
||||
state: CanvasPaintState::new(),
|
||||
|
@ -113,7 +113,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Creates a new `CanvasPaintTask` and returns the out-of-process sender and the in-process
|
||||
/// Creates a new `CanvasPaintThread` and returns the out-of-process sender and the in-process
|
||||
/// sender for it.
|
||||
pub fn start(size: Size2D<i32>) -> (IpcSender<CanvasMsg>, Sender<CanvasMsg>) {
|
||||
// TODO(pcwalton): Ask the pipeline to create this for us instead of spawning it directly.
|
||||
|
@ -121,8 +121,8 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
let (out_of_process_chan, out_of_process_port) = ipc::channel::<CanvasMsg>().unwrap();
|
||||
let (in_process_chan, in_process_port) = channel();
|
||||
ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone());
|
||||
spawn_named("CanvasTask".to_owned(), move || {
|
||||
let mut painter = CanvasPaintTask::new(size);
|
||||
spawn_named("CanvasThread".to_owned(), move || {
|
||||
let mut painter = CanvasPaintThread::new(size);
|
||||
loop {
|
||||
let msg = in_process_port.recv();
|
||||
match msg.unwrap() {
|
||||
|
@ -202,7 +202,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
}
|
||||
}
|
||||
}
|
||||
CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D task"),
|
||||
CanvasMsg::WebGL(_) => panic!("Wrong message sent to Canvas2D thread"),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -516,7 +516,7 @@ impl<'a> CanvasPaintTask<'a> {
|
|||
}
|
||||
|
||||
fn recreate(&mut self, size: Size2D<i32>) {
|
||||
self.drawtarget = CanvasPaintTask::create(size);
|
||||
self.drawtarget = CanvasPaintThread::create(size);
|
||||
}
|
||||
|
||||
fn send_pixel_contents(&mut self, chan: IpcSender<IpcSharedMemory>) {
|
|
@ -22,6 +22,6 @@ extern crate num;
|
|||
extern crate offscreen_gl_context;
|
||||
extern crate util;
|
||||
|
||||
pub mod canvas_paint_task;
|
||||
pub mod canvas_paint_thread;
|
||||
mod premultiplytable;
|
||||
pub mod webgl_paint_task;
|
||||
pub mod webgl_paint_thread;
|
||||
|
|
|
@ -14,17 +14,17 @@ use layers::platform::surface::NativeSurface;
|
|||
use offscreen_gl_context::{ColorAttachmentType, GLContext, GLContextAttributes, NativeGLContext};
|
||||
use std::borrow::ToOwned;
|
||||
use std::sync::mpsc::{Sender, channel};
|
||||
use util::task::spawn_named;
|
||||
use util::thread::spawn_named;
|
||||
use util::vec::byte_swap;
|
||||
|
||||
pub struct WebGLPaintTask {
|
||||
pub struct WebGLPaintThread {
|
||||
size: Size2D<i32>,
|
||||
original_context_size: Size2D<i32>,
|
||||
gl_context: GLContext<NativeGLContext>,
|
||||
}
|
||||
|
||||
impl WebGLPaintTask {
|
||||
fn new(size: Size2D<i32>, attrs: GLContextAttributes) -> Result<WebGLPaintTask, &'static str> {
|
||||
impl WebGLPaintThread {
|
||||
fn new(size: Size2D<i32>, attrs: GLContextAttributes) -> Result<WebGLPaintThread, &'static str> {
|
||||
let context = try!(GLContext::new(size, attrs, ColorAttachmentType::Texture, None));
|
||||
|
||||
// NOTE: As of right now this is always equal to the size parameter,
|
||||
|
@ -32,7 +32,7 @@ impl WebGLPaintTask {
|
|||
// the requested size, tries with the nearest powers of two, for example.
|
||||
let real_size = context.borrow_draw_buffer().unwrap().size();
|
||||
|
||||
Ok(WebGLPaintTask {
|
||||
Ok(WebGLPaintThread {
|
||||
size: real_size,
|
||||
original_context_size: real_size,
|
||||
gl_context: context
|
||||
|
@ -183,7 +183,7 @@ impl WebGLPaintTask {
|
|||
assert!(gl::get_error() == gl::NO_ERROR);
|
||||
}
|
||||
|
||||
/// Creates a new `WebGLPaintTask` and returns the out-of-process sender and the in-process
|
||||
/// Creates a new `WebGLPaintThread` and returns the out-of-process sender and the in-process
|
||||
/// sender for it.
|
||||
pub fn start(size: Size2D<i32>, attrs: GLContextAttributes)
|
||||
-> Result<(IpcSender<CanvasMsg>, Sender<CanvasMsg>), &'static str> {
|
||||
|
@ -191,11 +191,11 @@ impl WebGLPaintTask {
|
|||
let (in_process_chan, in_process_port) = channel();
|
||||
let (result_chan, result_port) = channel();
|
||||
ROUTER.route_ipc_receiver_to_mpsc_sender(out_of_process_port, in_process_chan.clone());
|
||||
spawn_named("WebGLTask".to_owned(), move || {
|
||||
let mut painter = match WebGLPaintTask::new(size, attrs) {
|
||||
Ok(task) => {
|
||||
spawn_named("WebGLThread".to_owned(), move || {
|
||||
let mut painter = match WebGLPaintThread::new(size, attrs) {
|
||||
Ok(thread) => {
|
||||
result_chan.send(Ok(())).unwrap();
|
||||
task
|
||||
thread
|
||||
},
|
||||
Err(e) => {
|
||||
result_chan.send(Err(e)).unwrap();
|
||||
|
@ -225,7 +225,7 @@ impl WebGLPaintTask {
|
|||
painter.send_native_surface(chan),
|
||||
}
|
||||
}
|
||||
CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLTask"),
|
||||
CanvasMsg::Canvas2d(_) => panic!("Wrong message sent to WebGLThread"),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -279,7 +279,7 @@ impl WebGLPaintTask {
|
|||
}
|
||||
|
||||
fn create_texture(&self, chan: IpcSender<Option<NonZero<u32>>>) {
|
||||
let texture = gl::gen_textures(1)[0];
|
||||
let texture = gl::gen_framebuffers(1)[0];
|
||||
let texture = if texture == 0 {
|
||||
None
|
||||
} else {
|
Loading…
Add table
Add a link
Reference in a new issue