Auto merge of #5652 - dmarcos:webgl, r=jdm

@jdm @ecoal95 I'm working on making VR happen in the Browser and I want to bring to Servo the [webVR APIs](https://github.com/MozVR/webvr-spec/blob/master/webvr.idl) we already have in Gecko. Before anything happens we need a working implementation of WebGL (and also the [fullscreen API](https://fullscreen.spec.whatwg.org/)). My implementation is very basic and probably naive (I just recently started to contribute to Servo). My patch is just a starting point: 

- It only implements ```clearColor``` and ```clear``` methods of the [WebGL spec](https://www.khronos.org/registry/webgl/specs/latest/).
- It uses the readback strategy that ```canvasRenderingContext2D``` is using (The webgl task paints stuff independently on it's own buffer and the compositor task request the pixels back to the webgl task when it needs them) I'm sure there are much better ways to handle this. Latency and FPS are critical in VR so we have to figure out the fastest way to push pixels to the screen. I've read something about layerizing the canvas but I'm still not sure what that even means :)
- There's an included test you can try ```./mach run tests/ref/webgl-context/clearcolor.html``` 

@ecoal95 I know you'll be working on this for the next three months. With a foundation in place we will be able to make quick progress in parallel. This is exciting!

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/5652)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-04-20 19:29:02 -05:00
commit e4b620ea54
23 changed files with 1326 additions and 165 deletions

View file

@ -329,6 +329,9 @@ resolution=600x800 == viewport_percentage_vmin_vmax.html viewport_percentage_vmi
resolution=800x600 == viewport_percentage_vw_vh.html viewport_percentage_vw_vh_a.html
resolution=600x800 == viewport_percentage_vw_vh.html viewport_percentage_vw_vh_b.html
== visibility_hidden.html visibility_hidden_ref.html
flaky_cpu == webgl-context/clearcolor.html webgl-context/clearcolor_ref.html
== whitespace_nowrap_a.html whitespace_nowrap_ref.html
== whitespace_pre.html whitespace_pre_ref.html
== width_nonreplaced_block_simple_a.html width_nonreplaced_block_simple_b.html

View file

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>WebGL ClearColor Test</title>
</head>
<style>
html, body {
margin: 0;
}
</style>
<body>
<canvas id="canvas" width="640" height="480"></canvas>
<script type="text/javascript">
var gl = document.getElementById("canvas").getContext("webgl");
gl.clearColor(1.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT);
</script>
</body>
</html>

View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>WebGL ClearColor Test</title>
</head>
<style>
html, body {
margin: 0;
}
#canvas {
width: 640px;
height: 480px;
background-color: red;
}
</style>
<body>
<div id="canvas"></canvas>
</body>
</html>

View file

@ -175,6 +175,7 @@ var interfaceNamesInGlobalScope = [
"UIEvent",
"URLSearchParams",
"ValidityState",
"WebGLRenderingContext",
"WebSocket",
"Window",
"Worker",