aboutsummaryrefslogtreecommitdiffstats
path: root/components/canvas/webgl_thread.rs
diff options
context:
space:
mode:
authorMátyás Mustoha <matyas.mustoha@h-lab.eu>2019-10-17 11:34:06 +0200
committerMátyás Mustoha <matyas.mustoha@h-lab.eu>2019-11-05 11:33:13 +0100
commit4050b7f9eca4c581d100fed778fa09f21d7e09dd (patch)
tree440fb6327f713e010ebaf75ba7e8178946db686a /components/canvas/webgl_thread.rs
parentf626355b67fc007d5961c446d5a4ddbcc3785698 (diff)
downloadservo-4050b7f9eca4c581d100fed778fa09f21d7e09dd.tar.gz
servo-4050b7f9eca4c581d100fed778fa09f21d7e09dd.zip
Implement the basic WebGL2 buffer data operations
Adds support for `bufferData`, `bufferSubData`, `copyBufferSubData` and `getBufferSubData`. Reference: https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.3
Diffstat (limited to 'components/canvas/webgl_thread.rs')
-rw-r--r--components/canvas/webgl_thread.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/components/canvas/webgl_thread.rs b/components/canvas/webgl_thread.rs
index 00e38dfc56f..b36df1c1b13 100644
--- a/components/canvas/webgl_thread.rs
+++ b/components/canvas/webgl_thread.rs
@@ -55,6 +55,7 @@ use sparkle::gl::Gl;
use std::borrow::Cow;
use std::cell::{Cell, RefCell};
use std::rc::Rc;
+use std::slice;
use std::sync::{Arc, Mutex};
use std::thread;
use surfman;
@@ -1013,6 +1014,26 @@ impl WebGLImpl {
WebGLCommand::BufferSubData(buffer_type, offset, ref receiver) => {
gl::buffer_sub_data(gl, buffer_type, offset, &receiver.recv().unwrap())
},
+ WebGLCommand::CopyBufferSubData(src, dst, src_offset, dst_offset, size) => {
+ gl.copy_buffer_sub_data(
+ src,
+ dst,
+ src_offset as isize,
+ dst_offset as isize,
+ size as isize,
+ );
+ },
+ WebGLCommand::GetBufferSubData(buffer_type, offset, length, ref sender) => {
+ let ptr = gl.map_buffer_range(
+ buffer_type,
+ offset as isize,
+ length as isize,
+ gl::MAP_READ_BIT,
+ );
+ let data: &[u8] = unsafe { slice::from_raw_parts(ptr as _, length) };
+ sender.send(data).unwrap();
+ gl.unmap_buffer(buffer_type);
+ },
WebGLCommand::Clear(mask) => {
gl.clear(mask);
},