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
use crate::prelude::*; use crate::{FilterQuality, Image, ImageFilter, Rect}; use skia_bindings as sb; use skia_bindings::{SkImage, SkImageFilter}; impl RCHandle<SkImageFilter> { pub fn from_image(image: Image) -> Option<Self> { from_image(image) } pub fn from_image_rect( image: Image, src_rect: impl AsRef<Rect>, dst_rect: impl AsRef<Rect>, filter_quality: FilterQuality, ) -> Option<Self> { from_image_rect(image, src_rect, dst_rect, filter_quality) } } impl RCHandle<SkImage> { pub fn as_filter(&self) -> Option<ImageFilter> { self.clone().into_filter() } pub fn into_filter(self) -> Option<ImageFilter> { from_image(self) } pub fn as_filter_rect( &self, src_rect: impl AsRef<Rect>, dst_rect: impl AsRef<Rect>, filter_quality: FilterQuality, ) -> Option<ImageFilter> { self.clone() .into_filter_rect(src_rect, dst_rect, filter_quality) } pub fn into_filter_rect( self, src_rect: impl AsRef<Rect>, dst_rect: impl AsRef<Rect>, filter_quality: FilterQuality, ) -> Option<ImageFilter> { from_image_rect(self, src_rect, dst_rect, filter_quality) } } pub fn from_image(image: Image) -> Option<ImageFilter> { ImageFilter::from_ptr(unsafe { sb::C_SkImageSource_Make(image.into_ptr()) }) } pub fn from_image_rect( image: Image, src_rect: impl AsRef<Rect>, dst_rect: impl AsRef<Rect>, filter_quality: FilterQuality, ) -> Option<ImageFilter> { ImageFilter::from_ptr(unsafe { sb::C_SkImageSource_Make2( image.into_ptr(), src_rect.as_ref().native(), dst_rect.as_ref().native(), filter_quality.into_native(), ) }) }