webgl: Implement multiple calls and improve error detection

This commit implements WebGL's:
 * cullFace
 * frontFace
 * enable
 * disable
 * depthMask
 * colorMask
 * clearDepth
 * clearStencil
 * depthFunc
 * depthRange
 * hint
 * lineWidth
 * pixelStorei
 * polygonOffset
 * texParameteri
 * texParameterf
 * texImage2D (partially)

It inlines a lot of OpenGL calls to keep the file
`components/canvas/webgl_paint_task.rs` as small as possible while
keeping readability.

It also improves error detection on previous calls, and sets node damage
on the canvas in the drawing calls.

It adds a `TexImage2D` reftest, even though it's not enabled because:
 * WebGL paints the image when it loads (asynchronously), so the reftest doesn't wait for it and it finishes early
 * If we change the source for the base64 src of the image it works as expected in non-headless mode, but the test harness locks
This commit is contained in:
ecoal95 2015-07-25 21:01:44 +02:00
parent af3310f149
commit 6341c77700
12 changed files with 763 additions and 226 deletions

View file

@ -159,6 +159,7 @@ pub trait HTMLCanvasElementHelpers {
fn get_or_init_webgl_context(self,
cx: *mut JSContext,
attrs: Option<HandleValue>) -> Option<Root<WebGLRenderingContext>>;
fn is_valid(self) -> bool;
}
@ -325,3 +326,18 @@ impl<'a> From<&'a WebGLContextAttributes> for GLContextAttributes {
}
}
pub mod utils {
use dom::window::Window;
use ipc_channel::ipc;
use net_traits::image_cache_task::{ImageCacheChan, ImageResponse};
use url::Url;
pub fn request_image_from_cache(window: &Window, url: Url) -> ImageResponse {
let image_cache = window.image_cache_task();
let (response_chan, response_port) = ipc::channel().unwrap();
image_cache.request_image(url, ImageCacheChan(response_chan), None);
let result = response_port.recv().unwrap();
result.image_response
}
}