aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-09-10 17:29:50 -0700
committerEric Anholt <eric@anholt.net>2016-10-25 22:18:28 -0700
commit989c936e67b54105b7d9162553070e4fbfcd5853 (patch)
tree2ccdba9326b3b664f148267793bc8aa2d9c0bce5 /components/script/dom/webglrenderingcontext.rs
parent8a0ca2efba71446a7e49d8bd832de2117fa44a7d (diff)
downloadservo-989c936e67b54105b7d9162553070e4fbfcd5853.tar.gz
servo-989c936e67b54105b7d9162553070e4fbfcd5853.zip
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.
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index c93e80d805e..a40de7da9c8 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -2569,6 +2569,39 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
None => return constants::FRAMEBUFFER_COMPLETE,
}
}
+
+ fn RenderbufferStorage(&self, target: u32, internal_format: u32,
+ width: i32, height: i32) {
+ // From the GLES 2.0.25 spec:
+ //
+ // "target must be RENDERBUFFER."
+ if target != constants::RENDERBUFFER {
+ return self.webgl_error(InvalidOperation)
+ }
+
+ // From the GLES 2.0.25 spec:
+ //
+ // "If either width or height is greater than the value of
+ // MAX_RENDERBUFFER_SIZE , the error INVALID_VALUE is
+ // generated."
+ //
+ // and we have to throw out negative-size values as well just
+ // like for TexImage.
+ //
+ // FIXME: Handle max_renderbuffer_size, which doesn't seem to
+ // be in limits.
+ if width < 0 || height < 0 {
+ return self.webgl_error(InvalidValue);
+ }
+
+ match self.bound_renderbuffer.get() {
+ Some(rb) => handle_potential_webgl_error!(self, rb.storage(internal_format, width, height)),
+ None => self.webgl_error(InvalidOperation),
+ };
+
+ // FIXME: We need to clear the renderbuffer before it can be
+ // accessed. See https://github.com/servo/servo/issues/13710
+ }
}
pub trait LayoutCanvasWebGLRenderingContextHelpers {