diff options
author | ecoal95 <ecoal95@gmail.com> | 2015-05-25 14:47:23 +0200 |
---|---|---|
committer | ecoal95 <ecoal95@gmail.com> | 2015-06-01 15:29:38 +0200 |
commit | b3ac3467494377569997126103005382793d8081 (patch) | |
tree | eb0117a3dd980e6ff8b8657ecbab176faf229cb5 /components/canvas/webgl_paint_task.rs | |
parent | b1a773a15bd2e022aa45c3672e51467e994badfe (diff) | |
download | servo-b3ac3467494377569997126103005382793d8081.tar.gz servo-b3ac3467494377569997126103005382793d8081.zip |
Add WebGLContextAttributes support
This commit also:
* Allows to return non-rootable dictionaries from
Codegen.
* Merges the two context types in an enum type.
Diffstat (limited to 'components/canvas/webgl_paint_task.rs')
-rw-r--r-- | components/canvas/webgl_paint_task.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/components/canvas/webgl_paint_task.rs b/components/canvas/webgl_paint_task.rs index 99fd350ff32..4873cbccfa1 100644 --- a/components/canvas/webgl_paint_task.rs +++ b/components/canvas/webgl_paint_task.rs @@ -28,11 +28,10 @@ pub struct WebGLPaintTask { unsafe impl Send for WebGLPaintTask {} impl WebGLPaintTask { - fn new(size: Size2D<i32>) -> Result<WebGLPaintTask, &'static str> { - // TODO(ecoal95): Get the GLContextAttributes from the `GetContext` call + fn new(size: Size2D<i32>, attrs: GLContextAttributes) -> Result<WebGLPaintTask, &'static str> { let context = try!( GLContext::create_offscreen_with_color_attachment( - size, GLContextAttributes::default(), ColorAttachmentType::TextureWithSurface)); + size, attrs, ColorAttachmentType::TextureWithSurface)); Ok(WebGLPaintTask { size: size, original_context_size: size, @@ -42,6 +41,7 @@ impl WebGLPaintTask { pub fn handle_webgl_message(&self, message: CanvasWebGLMsg) { match message { + CanvasWebGLMsg::GetContextAttributes(sender) => self.get_context_attributes(sender), CanvasWebGLMsg::AttachShader(program_id, shader_id) => self.attach_shader(program_id, shader_id), CanvasWebGLMsg::BindBuffer(buffer_type, buffer_id) => self.bind_buffer(buffer_type, buffer_id), CanvasWebGLMsg::BufferData(buffer_type, data, usage) => self.buffer_data(buffer_type, data, usage), @@ -71,9 +71,9 @@ impl WebGLPaintTask { } } - pub fn start(size: Size2D<i32>) -> Result<Sender<CanvasMsg>, &'static str> { + pub fn start(size: Size2D<i32>, attrs: GLContextAttributes) -> Result<Sender<CanvasMsg>, &'static str> { let (chan, port) = channel::<CanvasMsg>(); - let mut painter = try!(WebGLPaintTask::new(size)); + let mut painter = try!(WebGLPaintTask::new(size, attrs)); spawn_named("WebGLTask".to_owned(), move || { painter.init(); loop { @@ -98,6 +98,10 @@ impl WebGLPaintTask { Ok(chan) } + fn get_context_attributes(&self, sender: Sender<GLContextAttributes>) { + sender.send(*self.gl_context.borrow_attributes()).unwrap() + } + fn attach_shader(&self, program_id: u32, shader_id: u32) { gl::attach_shader(program_id, shader_id); } |