Commit graph

177 commits

Author SHA1 Message Date
bors-servo
94eefc4001 Auto merge of #14075 - MortimerGoro:webgl-resize, r=MortimerGoro
Implement WebGLContext resize

<!-- Please describe your changes on the following line: -->

Related PR: https://github.com/servo/webrender/pull/519

Implement WebGLContext resize (canvas.width & canvas.height). I have tested:

- Fixes WebGL apps that initialize canvas size after calling canvas.getContext("webgl")
- Support WebGL apps that change the canvas size & viewport on window.onresize

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [x] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->

---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14075)
<!-- Reviewable:end -->
2016-12-01 03:04:49 -08:00
Imanol Fernandez
8ba75c0545 Implement WebGLContext resize, r=emilio 2016-12-01 00:56:59 +01:00
Anthony Ramine
8af2327e95 Expose WebGL-related interfaces only in Window 2016-11-30 23:23:39 +01:00
Gregory
fb98acbc4d update deps
switch to using webrender_traits::ImageData

update use of webrender_traits::StackingContext in layout

use webrender_traits::channel::msg_channel in webgl ipc

fix use of resource_override_path in components/servo/lib
2016-11-22 07:46:42 +10:00
Abelardo E. Mendoza
b372e7c98f script creates methods taking '*mut JSContext' unsafe
rebase + marked the necessary new code as unsafe
2016-11-14 11:06:17 +01:00
Eric Anholt
5e5eb18b0b webgl: Fix out-of-bounds readpixels handling.
This fixes the crash in read-pixels-pack-alignment (which was trying
to read out of bounds).

Fixes #13901
2016-11-05 11:49:30 -07:00
Eric Anholt
9a10666941 webgl: Throw an error on readPixels(width < 0 || height < 0)
Otherwise gleam will try to allocate a negative size area for the
result, and we'll panic with oom.
2016-11-05 11:49:30 -07:00
Eric Anholt
d77373654a webgl: Update FBO status when textures or RBs are reallocated.
FBO status is supposed to depend on the size of the attachments all
matching, so we need to re-check when it changes.  We don't ensure
matching yet, but this will prevent regressions when we do.
2016-11-05 10:43:12 -07:00
Eric Anholt
dba7d5eb51 webgl: Detach RBs and textures from the bound FBO on deletion.
This is part of general GL behavior: when an object is deleted, look
through the currently bound objects and detach the deleted object from
them.  Detaching an object from an FBO causes it to need to be
re-checked for its status.
2016-10-25 22:19:26 -07:00
Eric Anholt
6c10d5ca75 webgl: Add support for FBO attachments.
This allows many FBO tests to start running as their framebuffers
start coming back as framebuffer complete.
2016-10-25 22:18:29 -07:00
Eric Anholt
989c936e67 webgl: Add support for renderbufferStorage().
This is not a complete implementation yet: It doesn't clear the
contents of the renderbuffer on creation.  However, Gecko's plan to
only clear renderbuffers when the first FBO using them is the
simplest.
2016-10-25 22:18:28 -07:00
Eric Anholt
8a0ca2efba webgl: Add support for checkFramebufferStatus().
For now it's returning the default UNSUPPORTED on user FBOs.

object-deletion-behaviour.html starts running a bunch more subtets.
2016-10-25 22:18:27 -07:00
Eric Anholt
cc0955f12d webgl: Unbind deleted objects from the GL side, not just our side.
Once FBOs are allowed, we were running into testcases that deleted the
active FBO, and expected the following ReadPixels to come from the
default framebuffer.
2016-10-25 22:18:20 -07:00
Eric Anholt
5fda437e88 webgl: Throw an error when binding a deleted framebuffer.
The spec was recently changed to clarify that this should throw an
error.
2016-10-24 20:42:17 -07:00
Eric Anholt
2f68297051 webgl: Allow TexImage data argument to be larger than necessary.
texture-size-limit.html is using a large array for all of its calls at
various sizes, and we were throwing errors on the calls that should
have passed.
2016-10-23 17:45:56 -07:00
Anthony Ramine
0b3ab875f4 Remove intrinsic Root::r() 2016-10-11 19:44:32 +02:00
Eric Anholt
61debe5c01 webgl: Implement uniformMatrix*fv.
These new functions are derived from the existing uniform*fv
functions.  They get used in a lot of demo code, so it should greatly
improve our compatibility.

This regresses uniformMatrixBadArgs.html, which gets at an existing
problem in our uniform matrix support (failure to validate that the
uniform is a matrix before calling down) but previously just failed
because it only called the 'fv' variants and never the existing 'f'
variants.
2016-10-09 15:49:59 -07:00
Emilio Cobos Álvarez
d7e2b40484
webgl: Honor ArrayBuffer or ArrayBufferView in bufferData and bufferSubData. 2016-10-09 13:23:39 +02:00
Emilio Cobos Álvarez
f985a73cae
webgl: Handle both sequences and typed arrays, managing the type error ourselves.
This is a step with multiple intentions:

 * Be correct.
 * Unlock tests that are blocking @anholt.
 * Ease the transition to typed arrays once the changes by @Ms2ger start rolling
   in, since I expect the amount of test expectations to update to be
   non-trivial.
2016-10-09 12:41:13 +02:00
Emilio Cobos Álvarez
602246a14c
script: Mark as unsafe multiple array_buffer_view_to_xxx functions that take a raw JSObject pointer. 2016-10-09 12:32:37 +02:00
Emilio Cobos Álvarez
ea8f115b8c
webgl: A few fixes regarding the nullability of WebGL parameters. 2016-10-09 12:32:37 +02:00
Anthony Ramine
d8e92bb271 Rename Reflectable::global_scope to global 2016-10-06 21:36:41 +02:00
Anthony Ramine
22252605af Make WebGLRenderingContext::new take a &GlobalScope 2016-10-06 21:35:41 +02:00
Anthony Ramine
ae6af5172b Introduce Reflectable::global_scope 2016-10-06 21:35:38 +02:00
Anthony Ramine
f789e73fd2 Introduce GlobalScope::constellation_chan 2016-10-06 20:59:12 +02:00
Anthony Ramine
fcb59d3057 Make reflect_dom_object take a &GlobalScope 2016-10-06 20:59:09 +02:00
Imanol Fernandez
a07d6b37cc Fix WebGL tests & Implement WebGLRenderingContext::{validateProgram, getProgramInfoLog, disableVertexAttribArray}, r=emilio 2016-10-03 16:17:19 +02:00
Ofek
ee149cdac7 implement WebGLRenderingContext::isEnabled 2016-09-22 13:44:35 +03:00
Eric Anholt
87c9333abd webgl: Do validation that the framebuffer is complete for FBO operations.
Given that we can't make a complete FBO yet, just return false from
the status check.
2016-09-21 08:05:45 +10:00
Eric Anholt
b2c169274a webgl: Don't forget update WebGL's texture binding on unbind.
This doesn't appear to fix any testcases, but I noticed it when fixing
renderbuffers.
2016-09-21 08:05:45 +10:00
Eric Anholt
2d66840145 webgl: Don't forget to update the WebGL context's RB binding.
We need to track the RB in the DOM context for
getParameter(gl.RENDERBUFFER_BINDING), among others.
2016-09-21 08:05:45 +10:00
Eric Anholt
cc294fffcc webgl: Update the match for WebGLError's new InvalidFramebufferOperation. 2016-09-21 08:05:45 +10:00
UK992
93a103ba73 Reorder use statements 2016-09-09 04:55:19 +02:00
Anthony Ramine
6e1523f4ae Compile WebIDL return type "object" to NonZero<*mut JSObject> 2016-08-30 19:07:13 +02:00
Anthony Ramine
2400b91d05 Don't bother with the global in ImageData::get_image_data 2016-08-30 19:06:41 +02:00
bors-servo
d37d4d697a Auto merge of #13102 - anholt:webgl-is-program, r=emilio
webgl: Add isProgram() support.

<!-- Please describe your changes on the following line: -->
webgl: Add isProgram() support.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

There's one failure still, where a deleted program should still be
considered to be a program until it's unbound.  However, I recently
made it so that we unbind at delete time, and we may need to partially
back that change out.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13102)
<!-- Reviewable:end -->
2016-08-28 21:23:59 -05:00
bors-servo
11e8e42fd8 Auto merge of #13060 - anholt:webgl-invalid-passed-params, r=emilio
webgl: Do validation of glScissor/glViewport(width, height) on the DOM side

<!-- Please describe your changes on the following line: -->
webgl: Do validation of glScissor/glViewport(width, height) on the DOM side

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Avoids testcase CRASHes due to unexpected GL errors.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13060)
<!-- Reviewable:end -->
2016-08-28 20:10:47 -05:00
Eric Anholt
847ab63de6 webgl: Add isProgram() support.
There's one failure still, where a deleted program should still be
considered to be a program until it's unbound.  However, I recently
made it so that we unbind at delete time, and we may need to partially
back that change out.
2016-08-28 17:18:09 -07:00
Eric Anholt
e8b5f70429 webgl: Add getters for other GL_*_BINDING enums.
Fixes many subcases of object-deletion-behaviour.html.
2016-08-26 14:04:21 -07:00
Eric Anholt
db9fe23903 webgl: Remove objects from binding points on object deletion.
We keep bindings that shadow what's mapped in the GL state currently,
and so we need to remove the objects from our binding points when they
get implicitly removed from the GL binding points during object deletion.
2016-08-26 14:04:20 -07:00
Eric Anholt
6ec2c41df8 webgl: Protect against GL error on glBindRenderbuffer(deleted rbo).
On a GLES or compatibility underlying GL context, we were fine because
an underlying renderbuffer object would just get re-created, and
nothing too bad happened because we aren't tracking the currently
bound renderbuffer at the DOM level.  However, on a desktop GL core
context, binding non-genned or deleted names is an error.

Fixes a crash in object-deletion-behavior.html.
2016-08-26 14:04:19 -07:00
Eric Anholt
b8b74e4b37 webgl: Do validation of glScissor/glViewport(width, height) on the DOM side.
Avoids testcase CRASHes due to unexpected GL errors.
2016-08-26 12:58:51 -07:00
Eric Anholt
15fa1a5a7d webgl: Fix validation of drawElements()'s type argument.
Fixes crash due to unexpected GL errors in gl-drawelements.html.
2016-08-26 01:37:39 -07:00
Eric Anholt
6651db8b56 webgl: Add support for getParameter(GL_FRAMEBUFFER_BINDING).
To do this, we need to keep a map of GL names (encapsulated as
WebGLFramebufferId) to WebGLFramebuffer objects so that we can return
the right type.

Fixes #12852
2016-08-14 00:49:41 -07:00
Eric Anholt
a21bbb78c4 webgl: Fix a typo in VertexAttrib1fv handling.
The VertexAttrib[234]fv compare to the same size as in their function
name.  This wasn't noticed becacuse this function isn't connected from
the .webidl yet.
2016-08-13 17:25:32 -07:00
Eric Anholt
12a96caaf1 webgl: Validate that depthRange near <= far.
Fixes a subtest of webgl-specific.html.
2016-08-10 00:05:02 -07:00
bors-servo
3b0dadda52 Auto merge of #12224 - nox:die-util-die, r=Ms2ger
Remove some stuff from util

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12224)
<!-- Reviewable:end -->
2016-07-04 12:57:00 -07:00
Eduard Burtescu
0db1faf876 Switch to using the new rooted!/RootedGuard API for rooting. 2016-07-04 20:59:01 +03:00
Anthony Ramine
e77efb93c1 Move util::vec::byte_swap to canvas_traits 2016-07-04 16:48:15 +02:00
Anthony Ramine
89a0b55c61 Use wrappers for GL IDs
See https://github.com/servo/webrender_traits/pull/62.
2016-06-28 20:11:55 +02:00