diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-10-27 21:39:15 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-27 21:39:15 -0500 |
commit | fbec79e920c0b0ddeaeeb6c0cc97b20ad85729e0 (patch) | |
tree | c3721f70f05a9d6fa9d86292d9b532b0d5c9856f /components/script/dom/webglrenderbuffer.rs | |
parent | b4a882f81ab9d8128166a49f0514a398ad7a3b7d (diff) | |
parent | 71d266052b09c031707139466163a7087f0acc19 (diff) | |
download | servo-fbec79e920c0b0ddeaeeb6c0cc97b20ad85729e0.tar.gz servo-fbec79e920c0b0ddeaeeb6c0cc97b20ad85729e0.zip |
Auto merge of #13872 - anholt:webgl-fbo, r=emilio
webgl: Add basic support for framebuffer attachments
This is by no means a complete implementation, but I've slowed down on working on it, so I think we should look at what it takes to merge the current code. There are some major features missing, like initializing renderbuffers to 0 (uninitialized memory leak), tracking the attachments' attributes (width/height/format) for parameter requests, and lots of missing glCheckFramebufferStatus() validation. On the other hand, this is enough to run some demos using FBOs.
---
<!-- 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
- [X] These changes fix #13639 (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/13872)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/webglrenderbuffer.rs')
-rw-r--r-- | components/script/dom/webglrenderbuffer.rs | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs index de4eaa2d2c8..9e3c516cfbd 100644 --- a/components/script/dom/webglrenderbuffer.rs +++ b/components/script/dom/webglrenderbuffer.rs @@ -5,13 +5,14 @@ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use canvas_traits::CanvasMsg; use dom::bindings::codegen::Bindings::WebGLRenderbufferBinding; +use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants; use dom::bindings::js::Root; use dom::bindings::reflector::reflect_dom_object; use dom::globalscope::GlobalScope; use dom::webglobject::WebGLObject; use ipc_channel::ipc::{self, IpcSender}; use std::cell::Cell; -use webrender_traits::{WebGLCommand, WebGLRenderbufferId}; +use webrender_traits::{WebGLCommand, WebGLRenderbufferId, WebGLResult, WebGLError}; #[dom_struct] pub struct WebGLRenderbuffer { @@ -19,6 +20,7 @@ pub struct WebGLRenderbuffer { id: WebGLRenderbufferId, ever_bound: Cell<bool>, is_deleted: Cell<bool>, + internal_format: Cell<Option<u32>>, #[ignore_heap_size_of = "Defined in ipc-channel"] renderer: IpcSender<CanvasMsg>, } @@ -33,6 +35,7 @@ impl WebGLRenderbuffer { ever_bound: Cell::new(false), is_deleted: Cell::new(false), renderer: renderer, + internal_format: Cell::new(None), } } @@ -81,4 +84,28 @@ impl WebGLRenderbuffer { pub fn ever_bound(&self) -> bool { self.ever_bound.get() } + + pub fn storage(&self, internal_format: u32, width: i32, height: i32) -> WebGLResult<()> { + // Validate the internal_format, and save it for completeness + // validation. + match internal_format { + constants::RGBA4 | + constants::DEPTH_STENCIL | + constants::DEPTH_COMPONENT16 | + constants::STENCIL_INDEX8 => + self.internal_format.set(Some(internal_format)), + + _ => return Err(WebGLError::InvalidEnum), + }; + + // FIXME: Check that w/h are < MAX_RENDERBUFFER_SIZE + + // FIXME: Invalidate completeness after the call + + let msg = CanvasMsg::WebGL(WebGLCommand::RenderbufferStorage(constants::RENDERBUFFER, + internal_format, width, height)); + self.renderer.send(msg).unwrap(); + + Ok(()) + } } |