aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas/webgl_thread.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2018-10-08 13:49:58 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2018-10-09 14:57:02 +0200
commit6c469b90b1ae34bddcb7da19eacfa6ad4467cf35 (patch)
tree1746b4cef5b9710368c7c86b360906a417e0a78f /components/canvas/webgl_thread.rs
parent05ef233097e17c3cdd0000f434d1592e8e26ff54 (diff)
downloadservo-6c469b90b1ae34bddcb7da19eacfa6ad4467cf35.tar.gz
servo-6c469b90b1ae34bddcb7da19eacfa6ad4467cf35.zip
Share some code between 2D canvas and WebGL
Diffstat (limited to 'components/canvas/webgl_thread.rs')
-rw-r--r--components/canvas/webgl_thread.rs27
1 files changed, 10 insertions, 17 deletions
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index cd8dbde18d2..d00ae02871b 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -6,7 +6,6 @@ use canvas_traits::webgl::*;
use euclid::Size2D;
use fnv::FnvHashMap;
use gleam::gl;
-use ipc_channel::ipc::IpcBytesSender;
use offscreen_gl_context::{GLContext, GLContextAttributes, GLLimits, NativeGLContextMethods};
use pixels;
use std::thread;
@@ -791,8 +790,16 @@ impl WebGLImpl {
ctx.gl().pixel_store_i(name, val),
WebGLCommand::PolygonOffset(factor, units) =>
ctx.gl().polygon_offset(factor, units),
- WebGLCommand::ReadPixels(x, y, width, height, format, pixel_type, ref chan) => {
- Self::read_pixels(ctx.gl(), x, y, width, height, format, pixel_type, chan)
+ WebGLCommand::ReadPixels(rect, format, pixel_type, ref sender) => {
+ let pixels = ctx.gl().read_pixels(
+ rect.origin.x as i32,
+ rect.origin.y as i32,
+ rect.size.width as i32,
+ rect.size.height as i32,
+ format,
+ pixel_type,
+ );
+ sender.send(&pixels).unwrap();
}
WebGLCommand::RenderbufferStorage(target, format, width, height) =>
ctx.gl().renderbuffer_storage(target, format, width, height),
@@ -1335,20 +1342,6 @@ impl WebGLImpl {
}
}
- fn read_pixels(
- gl: &gl::Gl,
- x: i32,
- y: i32,
- width: i32,
- height: i32,
- format: u32,
- pixel_type: u32,
- chan: &IpcBytesSender,
- ) {
- let result = gl.read_pixels(x, y, width, height, format, pixel_type);
- chan.send(&result).unwrap()
- }
-
fn finish(gl: &gl::Gl, chan: &WebGLSender<()>) {
gl.finish();
chan.send(()).unwrap();