1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
use crate::prelude::*; use crate::{Canvas, Matrix, Paint, Picture}; use skia_bindings as sb; use skia_bindings::SkMultiPictureDraw; pub type MultiPictureDraw = Handle<SkMultiPictureDraw>; impl NativeDrop for SkMultiPictureDraw { fn drop(&mut self) { unsafe { sb::C_SkMultiPictureDraw_destruct(self) } } } impl Handle<SkMultiPictureDraw> { pub fn new(reserve: impl Into<Option<usize>>) -> Self { Handle::from_native(unsafe { SkMultiPictureDraw::new(reserve.into().unwrap_or_default().try_into().unwrap()) }) } pub fn add<'b>( mut self, canvas: &'b mut Canvas, picture: &'b Picture, matrix: Option<&'b Matrix>, paint: Option<&'b Paint>, ) -> Borrows<'b, MultiPictureDraw> { unsafe { self.native_mut().add( canvas.native_mut(), picture.native(), matrix.native_ptr_or_null(), paint.native_ptr_or_null(), ) } self.borrows(canvas) } } impl<'a> Borrows<'a, MultiPictureDraw> { pub fn add<'b>( mut self, canvas: &'b mut Canvas, picture: &'b Picture, matrix: Option<&'b Matrix>, paint: Option<&'b Paint>, ) -> Borrows<'b, MultiPictureDraw> where 'a: 'b, { unsafe { self.native_mut().add( canvas.native_mut(), picture.native(), matrix.native_ptr_or_null(), paint.native_ptr_or_null(), ); self } } pub fn draw(mut self, flush: impl Into<Option<bool>>) -> MultiPictureDraw { unsafe { self.native_mut().draw(flush.into().unwrap_or(false)); self.release() } } pub fn reset(mut self) -> MultiPictureDraw { unsafe { self.native_mut().reset(); self.release() } } }