aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderingcontext.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2018-09-07 16:46:18 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2018-09-08 13:42:06 +0200
commit4e9281dcbf5f704ff1fb656b58a9ec8cf398c06c (patch)
treed5724845331436276137423cf6e18b27685392d4 /components/script/dom/webglrenderingcontext.rs
parentf7630dad87da33449ce05b5e7a9ef6f747e9531d (diff)
downloadservo-4e9281dcbf5f704ff1fb656b58a9ec8cf398c06c.tar.gz
servo-4e9281dcbf5f704ff1fb656b58a9ec8cf398c06c.zip
Simplify WebGLRenderingContext::get_image_data
Diffstat (limited to 'components/script/dom/webglrenderingcontext.rs')
-rw-r--r--components/script/dom/webglrenderingcontext.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs
index 6c151486f59..b17d5a6c781 100644
--- a/components/script/dom/webglrenderingcontext.rs
+++ b/components/script/dom/webglrenderingcontext.rs
@@ -1191,16 +1191,16 @@ impl WebGLRenderingContext {
// can fail and that it is UB what happens in that case.
//
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#2.2
- pub fn get_image_data(&self, mut width: u32, mut height: u32) -> Option<Vec<u8>> {
+ pub fn get_image_data(&self, width: u32, height: u32) -> Option<Vec<u8>> {
handle_potential_webgl_error!(self, self.validate_framebuffer(), return None);
- if let Some((fb_width, fb_height)) = self.get_current_framebuffer_size() {
- width = cmp::min(width, fb_width as u32);
- height = cmp::min(height, fb_height as u32);
- } else {
- self.webgl_error(InvalidOperation);
- return None;
- }
+ let (fb_width, fb_height) = handle_potential_webgl_error!(
+ self,
+ self.get_current_framebuffer_size().ok_or(InvalidOperation),
+ return None
+ );
+ let width = cmp::min(width, fb_width as u32);
+ let height = cmp::min(height, fb_height as u32);
let (sender, receiver) = webgl_channel().unwrap();
self.send_command(WebGLCommand::ReadPixels(