aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglbuffer.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2018-09-07 11:10:44 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2018-09-07 11:28:59 +0200
commit9f924013bcbb840914bb6323d69d6b17addc9777 (patch)
tree0bfa75cf325a11c9868121c8333c1d205a12d77a /components/script/dom/webglbuffer.rs
parente37856a855185c496013bdb0009fb0a807396d25 (diff)
downloadservo-9f924013bcbb840914bb6323d69d6b17addc9777.tar.gz
servo-9f924013bcbb840914bb6323d69d6b17addc9777.zip
Use a bytes channel in BufferData
This means we don't need to copy the input ArrayBuffer at all on the DOM side.
Diffstat (limited to 'components/script/dom/webglbuffer.rs')
-rw-r--r--components/script/dom/webglbuffer.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/components/script/dom/webglbuffer.rs b/components/script/dom/webglbuffer.rs
index 138c34130a3..c49a3852709 100644
--- a/components/script/dom/webglbuffer.rs
+++ b/components/script/dom/webglbuffer.rs
@@ -13,6 +13,7 @@ use dom::bindings::root::DomRoot;
use dom::webglobject::WebGLObject;
use dom::webglrenderingcontext::WebGLRenderingContext;
use dom_struct::dom_struct;
+use ipc_channel::ipc;
use std::cell::Cell;
#[dom_struct]
@@ -62,7 +63,7 @@ impl WebGLBuffer {
self.id
}
- pub fn buffer_data(&self, data: Vec<u8>, usage: u32) -> WebGLResult<()> {
+ pub fn buffer_data(&self, data: &[u8], usage: u32) -> WebGLResult<()> {
match usage {
WebGLRenderingContextConstants::STREAM_DRAW |
WebGLRenderingContextConstants::STATIC_DRAW |
@@ -72,9 +73,11 @@ impl WebGLBuffer {
self.capacity.set(data.len());
self.usage.set(usage);
+ let (sender, receiver) = ipc::bytes_channel().unwrap();
self.upcast::<WebGLObject>()
.context()
- .send_command(WebGLCommand::BufferData(self.target.get().unwrap(), data.into(), usage));
+ .send_command(WebGLCommand::BufferData(self.target.get().unwrap(), receiver, usage));
+ sender.send(data).unwrap();
Ok(())
}