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
use crate::prelude::*; use crate::{image_filter::CropRect, ImageFilter, Paint}; use skia_bindings as sb; use skia_bindings::{SkImageFilter, SkPaint}; impl RCHandle<SkImageFilter> { pub fn from_paint<'a>( paint: &Paint, crop_rect: impl Into<Option<&'a CropRect>>, ) -> Option<Self> { from_paint(paint, crop_rect) } } impl Handle<SkPaint> { pub fn as_image_filter<'a>( &self, crop_rect: impl Into<Option<&'a CropRect>>, ) -> Option<ImageFilter> { from_paint(self, crop_rect) } } pub fn from_paint<'a>( paint: &Paint, crop_rect: impl Into<Option<&'a CropRect>>, ) -> Option<ImageFilter> { ImageFilter::from_ptr(unsafe { sb::C_SkPaintImageFilter_Make(paint.native(), crop_rect.into().native_ptr_or_null()) }) }