add two missing SkPicture functions
@@ -5,12 +5,14 @@ use crate::skia::{
Rect
};
use rust_skia::{
+ C_SkPicture_approximateOpCount,
C_SkPicture_playback,
SkPicture,
C_SkPicture_MakeFromData,
C_SkPicture_cullRect,
C_SkPicture_MakePlaceholder,
- C_SkPicture_serialize
+ C_SkPicture_serialize,
+ C_SkPicture_approximateBytesUsed
};
pub type Picture = RCHandle<SkPicture>;
@@ -25,19 +27,13 @@ impl NativeRefCounted for SkPicture {
}
}
-impl Picture {
+impl RCHandle<SkPicture> {
pub fn from_data(data: &Data) -> Picture {
Picture::from_ptr(unsafe {
C_SkPicture_MakeFromData(data.native())
}).unwrap()
}
- pub fn new_placeholder(cull: &Rect) -> Picture {
- Picture::from_ptr(unsafe {
- C_SkPicture_MakePlaceholder(&cull.into_native())
- }).unwrap()
- }
-
pub fn playback(&self, canvas: &mut Canvas) {
unsafe { C_SkPicture_playback(self.native(), canvas.native_mut()) }
}
@@ -57,4 +53,22 @@ impl Picture {
C_SkPicture_serialize(self.native())
}).unwrap()
}
+
+ pub fn new_placeholder(cull: &Rect) -> Picture {
+ Picture::from_ptr(unsafe {
+ C_SkPicture_MakePlaceholder(&cull.into_native())
+ }).unwrap()
+ }
+
+ pub fn approximate_op_count(&self) -> usize {
+ unsafe {
+ C_SkPicture_approximateOpCount(self.native()).try_into().unwrap()
+ }
+ }
+
+ pub fn approximate_bytes_used(&self) -> usize {
+ unsafe {
+ C_SkPicture_approximateBytesUsed(self.native())
+ }
+ }
}
\ No newline at end of file
