diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2018-09-07 16:46:18 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2018-09-08 13:42:06 +0200 |
commit | 4e9281dcbf5f704ff1fb656b58a9ec8cf398c06c (patch) | |
tree | d5724845331436276137423cf6e18b27685392d4 /components/script/dom/webglrenderingcontext.rs | |
parent | f7630dad87da33449ce05b5e7a9ef6f747e9531d (diff) | |
download | servo-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.rs | 16 |
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( |