Implement snapshot_data

This commit is contained in:
Bastien Orivel 2019-08-08 16:30:11 +02:00
parent c39af71aeb
commit 559b28ce7b

View file

@ -310,8 +310,15 @@ impl GenericDrawTarget for raqote::DrawTarget {
) {
unimplemented!();
}
fn snapshot_data(&self, _f: &dyn Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
unimplemented!();
#[allow(unsafe_code)]
fn snapshot_data(&self, f: &dyn Fn(&[u8]) -> Vec<u8>) -> Vec<u8> {
let v = self.get_data();
f(unsafe {
std::slice::from_raw_parts(
v.as_ptr() as *const u8,
v.len() * std::mem::size_of::<u32>(),
)
})
}
fn snapshot_data_owned(&self) -> Vec<u8> {
unimplemented!();