mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
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 -->
This commit is contained in:
commit
0de09b936e
16 changed files with 254 additions and 80 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue