mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Use a bytes channel in BufferData
This means we don't need to copy the input ArrayBuffer at all on the DOM side.
This commit is contained in:
parent
e37856a855
commit
9f924013bc
4 changed files with 37 additions and 22 deletions
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue