aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas/webgl_paint_task.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-06-01 08:37:48 -0500
committerbors-servo <metajack+bors@gmail.com>2015-06-01 08:37:48 -0500
commit0de09b936e5e37c15b7865157a98ad78b1077659 (patch)
treedff9058ec210d968aae1031632dede080456db88 /components/canvas/webgl_paint_task.rs
parent2a8d5952892e050a3d604741dd1007e3bd563315 (diff)
parentb3ac3467494377569997126103005382793d8081 (diff)
downloadservo-0de09b936e5e37c15b7865157a98ad78b1077659.tar.gz
servo-0de09b936e5e37c15b7865157a98ad78b1077659.zip
Auto merge of #6183 - ecoal95:webglcontextattributes, r=nox
r? @jdm I couldn't add the `getContextAttributes` method since `CodegenRust` doesn't know how to return a dictionary value, I'll take a look at it ASAP. I think the helper functions can return directly the renderer, since they're used just for that, but I wanted to hear your opinions about this. By the way I'm interested in adding more serious tests for WebGL, and I think the [khronos conformance suit](https://github.com/KhronosGroup/WebGL/tree/master/conformance-suites/1.0.3) should be the best option. Should I try to integrate it in wpt, or making a `tests/webgl` directory (or similar) inside the servo tree? (Maybe this question should be for @Ms2ger) <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6183) <!-- Reviewable:end -->
Diffstat (limited to 'components/canvas/webgl_paint_task.rs')
-rw-r--r--components/canvas/webgl_paint_task.rs14
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);
}