aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2018-09-12 16:36:08 -0400
committerGitHub <noreply@github.com>2018-09-12 16:36:08 -0400
commit26745b27419f687dec1e23434a5be827d4342768 (patch)
tree5ee5e5f2b9f49a506cc64037ccc5706aa7736c7c /components/script/dom/webglrenderingcontext.rs
parent910cc23a6e85cced43905f7615065b23bdb54b42 (diff)
parent4edb7b194c99a1d394dddaeac2f5064ed8e93f62 (diff)
downloadservo-26745b27419f687dec1e23434a5be827d4342768.tar.gz
servo-26745b27419f687dec1e23434a5be827d4342768.zip
Auto merge of #21461 - jdm:webgltmp2, r=nox
Various webgl fixes for framebuffer attachment test These changes resolve all panics on macOS when running framebuffer-object-attachment.html in headless and headful testing. --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] There are tests for these changes OR - [x] Fixes #13710. Fixes #20570. <!-- 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/21461) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs63
1 files changed, 31 insertions, 32 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index ab7178ffa16..ea45fd69ce5 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -39,7 +39,7 @@ use dom::webgl_validations::types::{TexDataType, TexFormat, TexImageTarget};
use dom::webglactiveinfo::WebGLActiveInfo;
use dom::webglbuffer::WebGLBuffer;
use dom::webglcontextevent::WebGLContextEvent;
-use dom::webglframebuffer::{WebGLFramebuffer, WebGLFramebufferAttachmentRoot};
+use dom::webglframebuffer::{WebGLFramebuffer, WebGLFramebufferAttachmentRoot, CompleteForRendering};
use dom::webglobject::WebGLObject;
use dom::webglprogram::WebGLProgram;
use dom::webglrenderbuffer::WebGLRenderbuffer;
@@ -339,10 +339,14 @@ impl WebGLRenderingContext {
// this: clear() and getParameter(IMPLEMENTATION_COLOR_READ_*).
fn validate_framebuffer(&self) -> WebGLResult<()> {
match self.bound_framebuffer.get() {
- Some(ref fb) if fb.check_status() != constants::FRAMEBUFFER_COMPLETE => {
- Err(InvalidFramebufferOperation)
+ Some(fb) => match fb.check_status_for_rendering() {
+ CompleteForRendering::Complete => Ok(()),
+ CompleteForRendering::Incomplete =>
+ Err(InvalidFramebufferOperation),
+ CompleteForRendering::MissingColorAttachment =>
+ Err(InvalidOperation),
},
- _ => Ok(()),
+ None => Ok(()),
}
}
@@ -1057,6 +1061,21 @@ impl WebGLRenderingContext {
_ => Err(InvalidEnum),
}
}
+
+ pub fn initialize_framebuffer(&self, clear_bits: u32) {
+ if clear_bits == 0 {
+ return;
+ }
+ self.send_command(WebGLCommand::InitializeFramebuffer {
+ color: clear_bits & constants::COLOR_BUFFER_BIT != 0,
+ depth: clear_bits & constants::DEPTH_BUFFER_BIT != 0,
+ stencil: clear_bits & constants::STENCIL_BUFFER_BIT != 0,
+ });
+ }
+
+ pub fn bound_framebuffer(&self) -> Option<DomRoot<WebGLFramebuffer>> {
+ self.bound_framebuffer.get()
+ }
}
impl Drop for WebGLRenderingContext {
@@ -1572,6 +1591,10 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
renderbuffer.bind(target);
}
_ => {
+ if renderbuffer.is_some() {
+ self.webgl_error(InvalidOperation);
+ }
+
self.bound_renderbuffer.set(None);
// Unbind the currently bound renderbuffer
self.send_command(WebGLCommand::BindRenderbuffer(target, None));
@@ -1971,20 +1994,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
handle_potential_webgl_error!(self, self.validate_ownership(renderbuffer), return);
handle_object_deletion!(self, self.bound_renderbuffer, renderbuffer,
Some(WebGLCommand::BindRenderbuffer(constants::RENDERBUFFER, None)));
- // From the GLES 2.0.25 spec, page 113:
- //
- // "If a renderbuffer object is deleted while its
- // image is attached to the currently bound
- // framebuffer, then it is as if
- // FramebufferRenderbuffer had been called, with a
- // renderbuffer of 0, for each attachment point to
- // which this image was attached in the currently
- // bound framebuffer."
- //
- if let Some(fb) = self.bound_framebuffer.get() {
- fb.detach_renderbuffer(renderbuffer);
- }
-
renderbuffer.delete()
}
}
@@ -2020,18 +2029,6 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
));
}
- // From the GLES 2.0.25 spec, page 113:
- //
- // "If a texture object is deleted while its image is
- // attached to the currently bound framebuffer, then
- // it is as if FramebufferTexture2D had been called,
- // with a texture of 0, for each attachment point to
- // which this image was attached in the currently
- // bound framebuffer."
- if let Some(fb) = self.bound_framebuffer.get() {
- fb.detach_texture(texture);
- }
-
texture.delete()
}
}
@@ -2723,10 +2720,12 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn StencilMaskSeparate(&self, face: u32, mask: u32) {
match face {
- constants::FRONT | constants::BACK | constants::FRONT_AND_BACK =>
+ constants::FRONT |
+ constants::BACK |
+ constants::FRONT_AND_BACK =>
self.send_command(WebGLCommand::StencilMaskSeparate(face, mask)),
_ => return self.webgl_error(InvalidEnum),
- }
+ };
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3