pub struct Handle<N: NativeDrop>(/* private fields */);Expand description
Wraps a native type that can be represented in Rust memory.
This type requires an implementation of the NativeDrop trait.
Implementations§
Source§impl Handle<SkBitmap>
impl Handle<SkBitmap>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty Bitmap without pixels, with ColorType::Unknown, AlphaType::Unknown,
and with a width and height of zero. PixelRef origin is set to (0, 0).
Use Self::set_info() to associate ColorType, AlphaType, width, and height after
Bitmap has been created.
Sourcepub fn width(&self) -> i32
pub fn width(&self) -> i32
Returns pixel count in each row. Should be equal or less than row_bytes() /
info().bytes_per_pixel().
May be less than pixel_ref().width(). Will not exceed pixel_ref().width() less
pixel_ref_origin().x.
Sourcepub fn height(&self) -> i32
pub fn height(&self) -> i32
Returns pixel row count.
Maybe be less than pixel_ref().height(). Will not exceed pixel_ref().height() less
pixel_ref_origin().y.
pub fn color_type(&self) -> ColorType
pub fn alpha_type(&self) -> AlphaType
Sourcepub fn color_space(&self) -> Option<ColorSpace>
pub fn color_space(&self) -> Option<ColorSpace>
Returns ColorSpace, the range of colors, associated with ImageInfo. The returned
ColorSpace is immutable.
Sourcepub fn bytes_per_pixel(&self) -> usize
pub fn bytes_per_pixel(&self) -> usize
Returns number of bytes per pixel required by ColorType.
Returns zero if color_type() is ColorType::Unknown.
Sourcepub fn row_bytes_as_pixels(&self) -> usize
pub fn row_bytes_as_pixels(&self) -> usize
Returns number of pixels that fit on row. Should be greater than or equal to width().
Sourcepub fn shift_per_pixel(&self) -> usize
pub fn shift_per_pixel(&self) -> usize
Returns bit shift converting row bytes to row pixels.
Returns zero for ColorType::Unknown.
Sourcepub fn draws_nothing(&self) -> bool
pub fn draws_nothing(&self) -> bool
Sourcepub fn row_bytes(&self) -> usize
pub fn row_bytes(&self) -> usize
Returns row bytes, the interval from one pixel row to the next. Row bytes is at least as
large as: width() * info().bytes_per_pixel().
Returns zero if color_type() is ColorType::Unknown, or if row bytes supplied to
set_info() is not large enough to hold a row of pixels.
Sourcepub fn set_alpha_type(&mut self, alpha_type: AlphaType) -> bool
pub fn set_alpha_type(&mut self, alpha_type: AlphaType) -> bool
Sets AlphaType, if alpha_type is compatible with ColorType. Returns true unless
alpha_type is AlphaType::Unknown and current AlphaType is not AlphaType::Unknown.
Returns true if ColorType is ColorType::Unknown. alpha_type is ignored, and
AlphaType remains AlphaType::Unknown.
Returns true if ColorType is ColorType::RGB565 or ColorType::Gray8.
alpha_type is ignored, and AlphaType remains AlphaType::Opaque.
If ColorType is ColorType::ARGB4444, ColorType::RGBA8888,
ColorType::BGRA8888, or ColorType::RGBAF16: returns true unless alpha_type is
AlphaType::Unknown and AlphaType is not AlphaType::Unknown. If AlphaType is
AlphaType::Unknown, alpha_type is ignored.
If ColorType is ColorType::Alpha8, returns true unless alpha_type is
AlphaType::Unknown and AlphaType is not AlphaType::Unknown. If AlphaType is
kUnknown_SkAlphaType, alpha_type is ignored. If alpha_type is AlphaType::Unpremul,
it is treated as AlphaType::Premul.
This changes AlphaType in PixelRef; all bitmaps sharing PixelRef are affected.
Sourcepub fn set_color_space(&mut self, color_space: impl Into<Option<ColorSpace>>)
pub fn set_color_space(&mut self, color_space: impl Into<Option<ColorSpace>>)
Sets the ColorSpace associated with this Bitmap.
The raw pixel data is not altered by this call; no conversion is performed.
This changes ColorSpace in PixelRef; all bitmaps sharing PixelRef
are affected.
Sourcepub fn pixels(&mut self) -> *mut c_void
pub fn pixels(&mut self) -> *mut c_void
Returns pixel address, the base address corresponding to the pixel origin.
Sourcepub fn compute_byte_size(&self) -> usize
pub fn compute_byte_size(&self) -> usize
Returns minimum memory required for pixel storage.
Does not include unused memory on last row when row_bytes_as_pixels() exceeds width().
Returns usize::MAX if result does not fit in usize.
Returns zero if height() or width() is 0.
Returns height() times row_bytes() if color_type() is ColorType::Unknown.
Sourcepub fn is_immutable(&self) -> bool
pub fn is_immutable(&self) -> bool
Returns true if pixels can not change.
Most immutable Bitmap checks trigger an assert only on debug builds.
Sourcepub fn set_immutable(&mut self)
pub fn set_immutable(&mut self)
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Resets to its initial state; all fields are set to zero, as if Bitmap had
been initialized by Bitmap::new().
Sets width, height, row bytes to zero; pixel address to None; ColorType to
ColorType::Unknown; and AlphaType to AlphaType::Unknown.
If PixelRef is allocated, its reference count is decreased by one, releasing its memory
if Bitmap is the sole owner.
Sourcepub fn compute_is_opaque(bm: &Self) -> bool
pub fn compute_is_opaque(bm: &Self) -> bool
Returns true if all pixels are opaque. ColorType determines how pixels are encoded, and
whether pixel describes alpha. Returns true for ColorType without alpha in each pixel;
for other ColorType, returns true if all pixels have alpha values equivalent to 1.0 or
greater.
Returns false for ColorType::Unknown.
Sourcepub fn dimensions(&self) -> ISize
pub fn dimensions(&self) -> ISize
Returns ISize { width(), height() }.
Sourcepub fn get_subset(&self) -> IRect
pub fn get_subset(&self) -> IRect
Returns the bounds of this bitmap, offset by its PixelRef origin.
Sourcepub fn set_info(
&mut self,
image_info: &ImageInfo,
row_bytes: impl Into<Option<usize>>,
) -> bool
pub fn set_info( &mut self, image_info: &ImageInfo, row_bytes: impl Into<Option<usize>>, ) -> bool
Sets width, height, AlphaType, ColorType, ColorSpace, and optional row_bytes.
Frees pixels, and returns true if successful.
row_bytes must equal or exceed image_info.min_row_bytes(). If image_info.color_space()
is ColorType::Unknown, row_bytes is ignored and treated as zero; for all other
ColorSpace values, row_bytes of zero is treated as image_info.min_row_bytes().
Calls reset() and returns false if:
- rowBytes exceeds 31 bits
image_info.width()is negativeimage_info.height()is negativerow_bytesis positive and less thanimage_info.width()timesimage_info.bytes_per_pixel()
Sourcepub fn try_alloc_pixels_flags(&mut self, image_info: &ImageInfo) -> bool
pub fn try_alloc_pixels_flags(&mut self, image_info: &ImageInfo) -> bool
Sets ImageInfo to info following the rules in set_info() and allocates pixel memory.
Memory is zeroed.
Returns false and calls reset() if ImageInfo could not be set, or memory could not
be allocated, or memory could not optionally be zeroed.
On most platforms, allocating pixel memory may succeed even though there is not sufficient
memory to hold pixels; allocation does not take place until the pixels are written to. The
actual behavior depends on the platform implementation of calloc().
Sourcepub fn alloc_pixels_flags(&mut self, image_info: &ImageInfo)
pub fn alloc_pixels_flags(&mut self, image_info: &ImageInfo)
Sets ImageInfo to info following the rules in set_info() and allocates pixel memory.
Memory is zeroed.
Returns false and calls reset() if ImageInfo could not be set, or memory could not be
allocated, or memory could not optionally be zeroed.
On most platforms, allocating pixel memory may succeed even though there is not sufficient
memory to hold pixels; allocation does not take place until the pixels are written to. The
actual behavior depends on the platform implementation of calloc().
Sourcepub fn try_alloc_pixels_info(
&mut self,
image_info: &ImageInfo,
row_bytes: impl Into<Option<usize>>,
) -> bool
pub fn try_alloc_pixels_info( &mut self, image_info: &ImageInfo, row_bytes: impl Into<Option<usize>>, ) -> bool
Sets ImageInfo to info following the rules in set_info() and allocates pixel memory.
row_bytes must equal or exceed info.width() times info.bytes_per_pixel(), or equal
None. Pass in None for row_bytes to compute the minimum valid value.
Returns false and calls reset() if ImageInfo could not be set, or memory could not be
allocated.
On most platforms, allocating pixel memory may succeed even though there is not sufficient
memory to hold pixels; allocation does not take place until the pixels are written to. The
actual behavior depends on the platform implementation of malloc().
Sourcepub fn alloc_pixels_info(
&mut self,
image_info: &ImageInfo,
row_bytes: impl Into<Option<usize>>,
)
pub fn alloc_pixels_info( &mut self, image_info: &ImageInfo, row_bytes: impl Into<Option<usize>>, )
Sets ImageInfo to info following the rules in set_info() and allocates pixel memory.
row_bytes must equal or exceed info.width() times info.bytes_per_pixel(), or equal
None. Pass in None for row_bytes to compute the minimum valid value.
Aborts execution if SkImageInfo could not be set, or memory could be allocated.
On most platforms, allocating pixel memory may succeed even though there is not sufficient
memory to hold pixels; allocation does not take place until the pixels are written to. The
actual behavior depends on the platform implementation of malloc().
Sourcepub fn try_alloc_n32_pixels(
&mut self,
(width, height): (i32, i32),
is_opaque: impl Into<Option<bool>>,
) -> bool
pub fn try_alloc_n32_pixels( &mut self, (width, height): (i32, i32), is_opaque: impl Into<Option<bool>>, ) -> bool
Sets ImageInfo to width, height, and native color type; and allocates pixel memory. If
is_opaque is true, sets ImageInfo to AlphaType::Opaque; otherwise, sets to
AlphaType::Premul.
Calls reset() and returns false if width exceeds 29 bits or is negative, or height is
negative.
Returns false if allocation fails.
Use to create Bitmap that matches crate::PMColor, the native pixel arrangement on
the platform. Bitmap drawn to output device skips converting its pixel format.
Sourcepub fn alloc_n32_pixels(
&mut self,
(width, height): (i32, i32),
is_opaque: impl Into<Option<bool>>,
)
pub fn alloc_n32_pixels( &mut self, (width, height): (i32, i32), is_opaque: impl Into<Option<bool>>, )
Sets ImageInfo to width, height, and native color type; and allocates pixel memory. If
is_opaque is true, sets ImageInfo to AlphaType::Opaque; otherwise, sets to
AlphaType::Premul.
Aborts if width exceeds 29 bits or is negative, or height is negative, or allocation fails.
Use to create Bitmap that matches crate::PMColor, the native pixel arrangement on
the platform. Bitmap drawn to output device skips converting its pixel format.
Sourcepub unsafe fn install_pixels(
&mut self,
info: &ImageInfo,
pixels: *mut c_void,
row_bytes: usize,
) -> bool
pub unsafe fn install_pixels( &mut self, info: &ImageInfo, pixels: *mut c_void, row_bytes: usize, ) -> bool
Sets ImageInfo to info following the rules in set_info(), and creates PixelRef
containing pixels and row_bytes.
If ImageInfo could not be set, or row_bytes is less than info.min_row_bytes(): calls reset(), and returns false`.
Otherwise, if pixels equals ptr::null_mut(): sets ImageInfo, returns true.
Caller must ensure that pixels are valid for the lifetime of Bitmap and PixelRef.
Sourcepub fn try_alloc_pixels(&mut self) -> bool
pub fn try_alloc_pixels(&mut self) -> bool
Allocates pixel memory with HeapAllocator, and replaces existing PixelRef. The
allocation size is determined by ImageInfo width, height, and ColorType.
Returns false if info().color_type() is ColorType::Unknown, or allocation fails.
Sourcepub fn alloc_pixels(&mut self)
pub fn alloc_pixels(&mut self)
Allocates pixel memory with HeapAllocator, and replaces existing PixelRef. The
allocation size is determined by ImageInfo width, height, and ColorType.
Aborts if info().color_type() is ColorType::Unknown, or allocation fails.
Sourcepub fn pixel_ref_origin(&self) -> IPoint
pub fn pixel_ref_origin(&self) -> IPoint
Returns origin of pixels within PixelRef. Bitmap bounds is always contained
by PixelRef bounds, which may be the same size or larger. Multiple Bitmap
can share the same PixelRef, where each Bitmap has different bounds.
The returned origin added to Bitmap dimensions equals or is smaller than the
PixelRef dimensions.
Returns (0, 0) if PixelRef is None.
Sourcepub fn set_pixel_ref(
&mut self,
pixel_ref: impl Into<Option<PixelRef>>,
offset: impl Into<IPoint>,
)
pub fn set_pixel_ref( &mut self, pixel_ref: impl Into<Option<PixelRef>>, offset: impl Into<IPoint>, )
Replaces pixel_ref and origin in Bitmap. offset specifies the offset within the
PixelRef pixels for the top-left corner of the bitmap.
Asserts in debug builds if offset is out of range. Pins offset to legal range in release builds.
The caller is responsible for ensuring that the pixels match the ColorType and
AlphaType in ImageInfo.
Sourcepub fn is_ready_to_draw(&self) -> bool
pub fn is_ready_to_draw(&self) -> bool
Returns true if Bitmap can be drawn.
Sourcepub fn generation_id(&self) -> u32
pub fn generation_id(&self) -> u32
Sourcepub fn notify_pixels_changed(&self)
pub fn notify_pixels_changed(&self)
Marks that pixels in PixelRef have changed. Subsequent calls to generation_id() return
a different value.
Sourcepub fn erase_color(&self, c: impl Into<Color>)
pub fn erase_color(&self, c: impl Into<Color>)
Replaces pixel values with c, interpreted as being in the sRGB ColorSpace. All pixels
contained by Self::bounds() are affected. If the Self::color_type() is
ColorType::Gray8 or ColorType::RGB565, then alpha is ignored; RGB is treated as
opaque. If Self::color_type() is ColorType::Alpha8, then RGB is ignored.
Input color is ultimately converted to an Color4f, so Self::erase_color_4f will have
higher color resolution.
Sourcepub fn erase_color_4f(&self, c: impl AsRef<Color4f>)
pub fn erase_color_4f(&self, c: impl AsRef<Color4f>)
Replaces pixel values with c, interpreted as being in the sRGB ColorSpace. All pixels
contained by Self::bounds() are affected. If the Self::color_type() is
ColorType::Gray8 or ColorType::RGB565, then alpha is ignored; RGB is treated as
opaque. If Self::color_type() is ColorType::Alpha8, then RGB is ignored.
Sourcepub fn erase_argb(&self, a: u8, r: u8, g: u8, b: u8)
pub fn erase_argb(&self, a: u8, r: u8, g: u8, b: u8)
Replaces pixel values with unpremultiplied color built from a, r, g, and b,
interpreted as being in the sRGB ColorSpace. All pixels contained by Self::bounds()
are affected. If the Self::color_type() is ColorType::Gray8 or ColorType::RGB565,
then a is ignored; r, g, and b are treated as opaque. If Self::color_type() is
ColorType::Alpha8, then r, g, and b are ignored.
Sourcepub fn erase(&self, c: impl Into<Color>, area: impl AsRef<IRect>)
pub fn erase(&self, c: impl Into<Color>, area: impl AsRef<IRect>)
Replaces pixel values inside area with c. interpreted as being in the sRGB ColorSpace.
If area does not intersect bounds(), call has no effect.
If the color_type() is ColorType::Gray8 ColorType::RGB565, then alpha is ignored;
RGB is treated as opaque. If color_type() is ColorType::Alpha8, then RGB is ignored.
Input color is ultimately converted to an Color4f, so Self::erase_4f will have
higher color resolution.
Sourcepub fn erase_4f(&self, c: impl AsRef<Color4f>, area: impl AsRef<IRect>)
pub fn erase_4f(&self, c: impl AsRef<Color4f>, area: impl AsRef<IRect>)
Replaces pixel values inside area with c. interpreted as being in the sRGB ColorSpace.
If area does not intersect bounds(), call has no effect.
If the color_type() is ColorType::Gray8 ColorType::RGB565, then alpha is ignored;
RGB is treated as opaque. If color_type() is ColorType::Alpha8, then RGB is ignored.
Sourcepub fn get_color(&self, p: impl Into<IPoint>) -> Color
pub fn get_color(&self, p: impl Into<IPoint>) -> Color
Returns pixel at (x, y) as unpremultiplied color.
Returns black with alpha if ColorType is ColorType::Alpha8
Input is not validated: out of bounds values of x or y trigger an assert().
Fails if ColorType is ColorType::Unknown or pixel address is nullptr.
ColorSpace in ImageInfo is ignored. Some color precision may be lost in the
conversion to unpremultiplied color; original pixel data may have additional precision.
Sourcepub fn get_color_4f(&self, p: impl Into<IPoint>) -> Color4f
pub fn get_color_4f(&self, p: impl Into<IPoint>) -> Color4f
Returns pixel at (x, y) as unpremultiplied color.
Returns black with alpha if ColorType is ColorType::Alpha8
Input is not validated: out of bounds values of x or y trigger an assert().
Fails if ColorType is ColorType::Unknown or pixel address is None.
ColorSpace in ImageInfo is ignored. Some color precision may be lost in the
conversion to unpremultiplied color.
Sourcepub fn get_alpha_f(&self, p: impl Into<IPoint>) -> f32
pub fn get_alpha_f(&self, p: impl Into<IPoint>) -> f32
Look up the pixel at (x,y) and return its alpha component, normalized to [0..1]. This is
roughly equivalent to get_color().a(), but can be more efficient (and more precise if the
pixels store more than 8 bits per component).
Sourcepub fn get_addr(&self, p: impl Into<IPoint>) -> *const c_void
pub fn get_addr(&self, p: impl Into<IPoint>) -> *const c_void
Returns pixel address at (x, y).
Input is not validated: out of bounds values of x or y, or ColorType::Unknown,
trigger an assert(). Returns nullptr if ColorType is ColorType::Unknown, or
PixelRef is nullptr.
Performs a lookup of pixel size; for better performance, call one of: get_addr8(),
get_addr16(), or get_addr32().
Sourcepub fn extract_subset(&self, dst: &mut Self, subset: impl AsRef<IRect>) -> bool
pub fn extract_subset(&self, dst: &mut Self, subset: impl AsRef<IRect>) -> bool
Shares PixelRef with dst. Pixels are not copied; Bitmap and dst point to the same
pixels; dst Self::bounds() are set to the intersection of subset and the original
Self::bounds().
Subset may be larger than Self::bounds(). Any area outside of Self::bounds() is
ignored.
Any contents of dst are discarded.
Return false if:
- dst is
nullptr PixelRefisnullptr- subset does not intersect
Self::bounds()
Sourcepub unsafe fn read_pixels(
&self,
dst_info: &ImageInfo,
dst_pixels: *mut c_void,
dst_row_bytes: usize,
src_x: i32,
src_y: i32,
) -> bool
pub unsafe fn read_pixels( &self, dst_info: &ImageInfo, dst_pixels: *mut c_void, dst_row_bytes: usize, src_x: i32, src_y: i32, ) -> bool
Copies a crate::Rect of pixels from Bitmap to dst_pixels. Copy starts at (src_x, src_y), and does not exceed Bitmap (width(), height()).
dst_info specifies width, height, ColorType, AlphaType, and ColorSpace of
destination.
dst_row_bytes specifics the gap from one destination row to the next. Returns true if
pixels are copied. Returns false if:
dst_infohas no addressdst_row_bytesis less thandst_info.min_row_bytes()PixelRefisnullptr
Pixels are copied only if pixel conversion is possible. If Self::color_type() is
ColorType::Gray8, or ColorType::Alpha8; dst_info.color_type() must match. If
Self::color_type() is ColorType::Gray8, dst_info.color_space() must match. If
Self::alpha_type() is AlphaType::Opaque, dst_info.alpha_type() must match. If
Self::color_space() is nullptr, dst_info.color_space() must match. Returns false
if pixel conversion is not possible.
src_x and src_y may be negative to copy only top or left of source. Returns false if
Self::width() or Self::height() is zero or negative. Returns false if abs(src_x)
>= Self::width(), or if abs(src_y) >= Self::height().
Sourcepub fn extract_alpha(
&self,
dst: &mut Self,
paint: Option<&Paint>,
) -> Option<IPoint>
pub fn extract_alpha( &self, dst: &mut Self, paint: Option<&Paint>, ) -> Option<IPoint>
Sets dst to alpha described by pixels. Returns false if dst cannot be written to or
dst pixels cannot be allocated.
If paint is not None and contains crate::MaskFilter, crate::MaskFilter generates
mask alpha from Bitmap. Uses HeapAllocator to reserve memory for dst PixelRef.
Returns offset to top-left position for dst for alignment with Bitmap; (0, 0) unless
crate::MaskFilter generates mask.
Sourcepub fn peek_pixels(&self) -> Option<Pixmap<'_>>
pub fn peek_pixels(&self) -> Option<Pixmap<'_>>
Source§impl Handle<SkContourMeasureIter>
impl Handle<SkContourMeasureIter>
pub fn new( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self
pub fn from_path( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self
pub fn reset( &mut self, path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> &mut Self
Source§impl Handle<SkFont>
impl Handle<SkFont>
pub fn new( typeface: impl Into<Typeface>, size: impl Into<Option<scalar>>, ) -> Self
pub fn from_typeface( typeface: impl Into<Typeface>, size: impl Into<Option<scalar>>, ) -> Self
pub fn from_typeface_with_params( typeface: impl Into<Typeface>, size: scalar, scale: scalar, skew: scalar, ) -> Self
pub fn is_force_auto_hinting(&self) -> bool
pub fn is_embedded_bitmaps(&self) -> bool
pub fn is_subpixel(&self) -> bool
pub fn is_linear_metrics(&self) -> bool
pub fn is_embolden(&self) -> bool
pub fn is_baseline_snap(&self) -> bool
pub fn set_force_auto_hinting(&mut self, force_auto_hinting: bool) -> &mut Self
pub fn set_embedded_bitmaps(&mut self, embedded_bitmaps: bool) -> &mut Self
pub fn set_subpixel(&mut self, subpixel: bool) -> &mut Self
pub fn set_linear_metrics(&mut self, linear_metrics: bool) -> &mut Self
pub fn set_embolden(&mut self, embolden: bool) -> &mut Self
pub fn set_baseline_snap(&mut self, baseline_snap: bool) -> &mut Self
pub fn edging(&self) -> Edging
pub fn set_edging(&mut self, edging: Edging) -> &mut Self
pub fn set_hinting(&mut self, hinting: FontHinting) -> &mut Self
pub fn hinting(&self) -> FontHinting
pub fn with_size(&self, size: scalar) -> Option<Self>
pub fn typeface(&self) -> Typeface
pub fn size(&self) -> scalar
pub fn scale_x(&self) -> scalar
pub fn skew_x(&self) -> scalar
pub fn set_typeface(&mut self, tf: impl Into<Typeface>) -> &mut Self
pub fn set_size(&mut self, size: scalar) -> &mut Self
pub fn set_scale_x(&mut self, scale_x: scalar) -> &mut Self
pub fn set_skew_x(&mut self, skew_x: scalar) -> &mut Self
pub fn str_to_glyphs( &self, str: impl AsRef<str>, glyphs: &mut [GlyphId], ) -> usize
pub fn text_to_glyphs( &self, text: impl EncodedText, glyphs: &mut [GlyphId], ) -> usize
pub fn count_str(&self, str: impl AsRef<str>) -> usize
pub fn count_text(&self, text: impl EncodedText) -> usize
pub fn str_to_glyphs_vec(&self, str: impl AsRef<str>) -> Vec<GlyphId> ⓘ
pub fn text_to_glyphs_vec(&self, text: impl EncodedText) -> Vec<GlyphId> ⓘ
pub fn measure_str( &self, str: impl AsRef<str>, paint: Option<&Paint>, ) -> (scalar, Rect)
pub fn measure_text( &self, text: impl EncodedText, paint: Option<&Paint>, ) -> (scalar, Rect)
pub fn unichar_to_glyph(&self, uni: Unichar) -> GlyphId
pub fn unichar_to_glyphs(&self, uni: &[Unichar], glyphs: &mut [GlyphId])
pub fn get_widths(&self, glyphs: &[GlyphId], widths: &mut [scalar])
pub fn get_widths_bounds( &self, glyphs: &[GlyphId], widths: Option<&mut [scalar]>, bounds: Option<&mut [Rect]>, paint: Option<&Paint>, )
pub fn get_bounds( &self, glyphs: &[GlyphId], bounds: &mut [Rect], paint: Option<&Paint>, )
pub fn get_pos( &self, glyphs: &[GlyphId], pos: &mut [Point], origin: Option<Point>, )
pub fn get_x_pos( &self, glyphs: &[GlyphId], x_pos: &mut [scalar], origin: Option<scalar>, )
pub fn get_intercepts<'a>( &self, glyphs: &[GlyphId], pos: &[Point], (top, bottom): (scalar, scalar), paint: impl Into<Option<&'a Paint>>, ) -> Vec<scalar> ⓘ
pub fn get_path(&self, glyph_id: GlyphId) -> Option<Path>
pub fn metrics(&self) -> (scalar, FontMetrics)
pub fn spacing(&self) -> scalar
Source§impl Handle<SkColorInfo>
impl Handle<SkColorInfo>
pub fn new( ct: ColorType, at: AlphaType, cs: impl Into<Option<ColorSpace>>, ) -> Self
pub fn color_space(&self) -> Option<ColorSpace>
pub fn color_type(&self) -> ColorType
pub fn alpha_type(&self) -> AlphaType
pub fn is_opaque(&self) -> bool
pub fn is_gamma_close_to_srgb(&self) -> bool
pub fn with_alpha_type(&self, new_alpha_type: AlphaType) -> Self
pub fn with_color_type(&self, new_color_type: ColorType) -> Self
pub fn with_color_space(&self, cs: impl Into<Option<ColorSpace>>) -> Self
pub fn bytes_per_pixel(&self) -> usize
pub fn shift_per_pixel(&self) -> usize
Source§impl Handle<SkImageInfo>
impl Handle<SkImageInfo>
pub fn new( dimensions: impl Into<ISize>, ct: ColorType, at: AlphaType, cs: impl Into<Option<ColorSpace>>, ) -> Self
pub fn from_color_info( dimensions: impl Into<ISize>, color_info: ColorInfo, ) -> Self
pub fn new_n32( dimensions: impl Into<ISize>, at: AlphaType, cs: impl Into<Option<ColorSpace>>, ) -> ImageInfo
pub fn new_s32(dimensions: impl Into<ISize>, at: AlphaType) -> ImageInfo
pub fn new_n32_premul( dimensions: impl Into<ISize>, cs: impl Into<Option<ColorSpace>>, ) -> ImageInfo
pub fn new_a8(dimensions: impl Into<ISize>) -> ImageInfo
pub fn new_unknown(dimensions: Option<ISize>) -> ImageInfo
pub fn width(&self) -> i32
pub fn height(&self) -> i32
pub fn color_type(&self) -> ColorType
pub fn alpha_type(&self) -> AlphaType
pub fn color_space(&self) -> Option<ColorSpace>
pub fn is_empty(&self) -> bool
pub fn color_info(&self) -> &ColorInfo
pub fn is_opaque(&self) -> bool
pub fn dimensions(&self) -> ISize
pub fn bounds(&self) -> IRect
pub fn is_gamma_close_to_srgb(&self) -> bool
pub fn with_dimensions(&self, new_dimensions: impl Into<ISize>) -> Self
pub fn with_alpha_type(&self, new_alpha_type: AlphaType) -> Self
pub fn with_color_type(&self, new_color_type: ColorType) -> Self
pub fn with_color_space( &self, new_color_space: impl Into<Option<ColorSpace>>, ) -> Self
pub fn bytes_per_pixel(&self) -> usize
pub fn shift_per_pixel(&self) -> usize
pub fn min_row_bytes(&self) -> usize
pub fn compute_offset( &self, point: impl Into<IPoint>, row_bytes: usize, ) -> usize
pub fn compute_byte_size(&self, row_bytes: usize) -> usize
pub fn compute_min_byte_size(&self) -> usize
pub fn valid_row_bytes(&self, row_bytes: usize) -> bool
pub fn reset(&mut self) -> &mut Self
Source§impl Handle<SkPaint>
impl Handle<SkPaint>
pub fn new<'a>( color: impl AsRef<Color4f>, color_space: impl Into<Option<&'a ColorSpace>>, ) -> Paint
pub fn reset(&mut self) -> &mut Self
pub fn is_anti_alias(&self) -> bool
pub fn set_anti_alias(&mut self, anti_alias: bool) -> &mut Self
pub fn is_dither(&self) -> bool
pub fn set_dither(&mut self, dither: bool) -> &mut Self
pub fn style(&self) -> Style
pub fn set_style(&mut self, style: Style) -> &mut Self
pub fn set_stroke(&mut self, stroke: bool) -> &mut Self
pub fn color(&self) -> Color
pub fn color4f(&self) -> Color4f
pub fn set_color(&mut self, color: impl Into<Color>) -> &mut Self
pub fn set_color4f<'a>( &mut self, color: impl AsRef<Color4f>, color_space: impl Into<Option<&'a ColorSpace>>, ) -> &mut Self
pub fn alpha_f(&self) -> f32
pub fn alpha(&self) -> u8
pub fn set_alpha_f(&mut self, alpha: f32) -> &mut Self
pub fn set_alpha(&mut self, alpha: u8) -> &mut Self
pub fn set_argb(&mut self, a: u8, r: u8, g: u8, b: u8) -> &mut Self
pub fn stroke_width(&self) -> scalar
pub fn set_stroke_width(&mut self, width: scalar) -> &mut Self
pub fn stroke_miter(&self) -> scalar
pub fn set_stroke_miter(&mut self, miter_limit: scalar) -> &mut Self
pub fn stroke_cap(&self) -> Cap
pub fn set_stroke_cap(&mut self, cap: Cap) -> &mut Self
pub fn stroke_join(&self) -> Join
pub fn set_stroke_join(&mut self, join: Join) -> &mut Self
pub fn shader(&self) -> Option<Shader>
pub fn set_shader(&mut self, shader: impl Into<Option<Shader>>) -> &mut Self
pub fn color_filter(&self) -> Option<ColorFilter>
pub fn set_color_filter( &mut self, color_filter: impl Into<Option<ColorFilter>>, ) -> &mut Self
pub fn as_blend_mode(&self) -> Option<BlendMode>
pub fn blend_mode_or(&self, default_mode: BlendMode) -> BlendMode
pub fn blend_mode(&self) -> BlendMode
pub fn is_src_over(&self) -> bool
pub fn set_blend_mode(&mut self, mode: BlendMode) -> &mut Self
pub fn blender(&self) -> Option<Blender>
pub fn set_blender(&mut self, blender: impl Into<Option<Blender>>) -> &mut Self
pub fn path_effect(&self) -> Option<PathEffect>
pub fn set_path_effect( &mut self, path_effect: impl Into<Option<PathEffect>>, ) -> &mut Self
pub fn mask_filter(&self) -> Option<MaskFilter>
pub fn set_mask_filter( &mut self, mask_filter: impl Into<Option<MaskFilter>>, ) -> &mut Self
pub fn image_filter(&self) -> Option<ImageFilter>
pub fn set_image_filter( &mut self, image_filter: impl Into<Option<ImageFilter>>, ) -> &mut Self
pub fn nothing_to_draw(&self) -> bool
Source§impl Handle<SkPath>
Path contain geometry. Path may be empty, or contain one or more verbs that
outline a figure. Path always starts with a move verb to a Cartesian coordinate,
and may be followed by additional verbs that add lines or curves.
Adding a close verb makes the geometry into a continuous loop, a closed contour.
Path may contain any number of contours, each beginning with a move verb.
impl Handle<SkPath>
Path contain geometry. Path may be empty, or contain one or more verbs that
outline a figure. Path always starts with a move verb to a Cartesian coordinate,
and may be followed by additional verbs that add lines or curves.
Adding a close verb makes the geometry into a continuous loop, a closed contour.
Path may contain any number of contours, each beginning with a move verb.
Path contours may contain only a move verb, or may also contain lines,
quadratic beziers, conics, and cubic beziers. Path contours may be open or
closed.
When used to draw a filled area, Path describes whether the fill is inside or
outside the geometry. Path also describes the winding rule used to fill
overlapping contours.
Internally, Path lazily computes metrics likes bounds and convexity. Call
Path::update_bounds_cache to make Path thread safe.
Sourcepub fn raw(
points: &[Point],
verbs: &[PathVerb],
conic_weights: &[scalar],
fill_type: PathFillType,
is_volatile: impl Into<Option<bool>>,
) -> Self
pub fn raw( points: &[Point], verbs: &[PathVerb], conic_weights: &[scalar], fill_type: PathFillType, is_volatile: impl Into<Option<bool>>, ) -> Self
Create a new path with the specified spans.
The points and weights arrays are read in order, based on the sequence of verbs.
Move 1 point Line 1 point Quad 2 points Conic 2 points and 1 weight Cubic 3 points Close 0 points
If an illegal sequence of verbs is encountered, or the specified number of points or weights is not sufficient given the verbs, an empty Path is returned.
A legal sequence of verbs consists of any number of Contours. A contour always begins with a Move verb, followed by 0 or more segments: Line, Quad, Conic, Cubic, followed by an optional Close.
Sourcepub fn new_from(
points: &[Point],
verbs: &[u8],
conic_weights: &[scalar],
fill_type: PathFillType,
is_volatile: impl Into<Option<bool>>,
) -> Self
👎Deprecated since 0.88.0: use raw()
pub fn new_from( points: &[Point], verbs: &[u8], conic_weights: &[scalar], fill_type: PathFillType, is_volatile: impl Into<Option<bool>>, ) -> Self
Create a new path with the specified spans.
The points and weights arrays are read in order, based on the sequence of verbs.
Move 1 point Line 1 point Quad 2 points Conic 2 points and 1 weight Cubic 3 points Close 0 points
If an illegal sequence of verbs is encountered, or the specified number of points or weights is not sufficient given the verbs, an empty Path is returned.
A legal sequence of verbs consists of any number of Contours. A contour always begins with a Move verb, followed by 0 or more segments: Line, Quad, Conic, Cubic, followed by an optional Close.
pub fn rect_with_fill_type( rect: impl AsRef<Rect>, fill_type: PathFillType, dir: impl Into<Option<PathDirection>>, ) -> Self
pub fn rect( rect: impl AsRef<Rect>, dir: impl Into<Option<PathDirection>>, ) -> Self
pub fn oval( oval: impl AsRef<Rect>, dir: impl Into<Option<PathDirection>>, ) -> Self
pub fn oval_with_start_index( oval: impl AsRef<Rect>, dir: PathDirection, start_index: usize, ) -> Self
pub fn circle( center: impl Into<Point>, radius: scalar, dir: impl Into<Option<PathDirection>>, ) -> Self
pub fn rrect( rect: impl AsRef<RRect>, dir: impl Into<Option<PathDirection>>, ) -> Self
pub fn rrect_with_start_index( rect: impl AsRef<RRect>, dir: PathDirection, start_index: usize, ) -> Self
pub fn polygon( pts: &[Point], is_closed: bool, fill_type: impl Into<Option<PathFillType>>, is_volatile: impl Into<Option<bool>>, ) -> Self
pub fn line(a: impl Into<Point>, b: impl Into<Point>) -> Self
Sourcepub fn new_with_fill_type(fill_type: PathFillType) -> Self
pub fn new_with_fill_type(fill_type: PathFillType) -> Self
pub fn new() -> Self
Sourcepub fn is_interpolatable(&self, compare: &Path) -> bool
pub fn is_interpolatable(&self, compare: &Path) -> bool
Returns true if Path contain equal verbs and equal weights.
If Path contain one or more conics, the weights must match.
conic_to() may add different verbs depending on conic weight, so it is not
trivial to interpolate a pair of Path containing conics with different
conic weight values.
compare-Pathto compare
Returns: true if Path verb array and weights are equivalent
Sourcepub fn interpolate(&self, ending: &Path, weight: scalar) -> Option<Self>
pub fn interpolate(&self, ending: &Path, weight: scalar) -> Option<Self>
Interpolates between Path with Point array of equal size.
Copy verb array and weights to out, and set out Point array to a weighted
average of this Point array and ending Point array, using the formula:
(Path Point * weight) + ending Point * (1 - weight).
weight is most useful when between zero (ending Point array) and
one (this Point_Array); will work with values outside of this
range.
interpolate() returns an empty Path if Point array is not the same size
as ending Point array. Call is_interpolatable() to check Path compatibility
prior to calling make_interpolate().
ending-Pointarray averaged with thisPointarrayweight- contribution of thisPointarray, and one minus contribution of endingPointarray
Returns: Path replaced by interpolated averages
Sourcepub fn interpolate_inplace(
&self,
ending: &Path,
weight: scalar,
out: &mut Path,
) -> bool
pub fn interpolate_inplace( &self, ending: &Path, weight: scalar, out: &mut Path, ) -> bool
Interpolates between Path with Point array of equal size.
Copy verb array and weights to out, and set out Point array to a weighted
average of this Point array and ending Point array, using the formula:
(Path Point * weight) + ending Point * (1 - weight).
weight is most useful when between zero (ending Point array) and
one (this Point_Array); will work with values outside of this
range.
interpolate_inplace() returns false and leaves out unchanged if Point array is not
the same size as ending Point array. Call is_interpolatable() to check Path
compatibility prior to calling interpolate_inplace().
ending-Pointarray averaged with thisPointarrayweight- contribution of thisPointarray, and one minus contribution of endingPointarrayout-Pathreplaced by interpolated averages
Sourcepub fn fill_type(&self) -> PathFillType
pub fn fill_type(&self) -> PathFillType
Returns PathFillType, the rule used to fill Path.
Returns: current PathFillType setting
pub fn with_fill_type(&self, new_fill_type: PathFillType) -> Path
Sourcepub fn is_inverse_fill_type(&self) -> bool
pub fn is_inverse_fill_type(&self) -> bool
Returns if FillType describes area outside Path geometry. The inverse fill area
extends indefinitely.
Returns: true if FillType is InverseWinding or InverseEvenOdd
Sourcepub fn with_toggle_inverse_fill_type(&self) -> Self
pub fn with_toggle_inverse_fill_type(&self) -> Self
Creates an Path with the same properties and data, and with PathFillType replaced
with its inverse. The inverse of PathFillType describes the area unmodified by the
original FillType.
Sourcepub fn is_convex(&self) -> bool
pub fn is_convex(&self) -> bool
Returns true if the path is convex. If necessary, it will first compute the convexity.
Sourcepub fn is_oval(&self) -> Option<Rect>
pub fn is_oval(&self) -> Option<Rect>
Sourcepub fn is_last_contour_closed(&self) -> bool
pub fn is_last_contour_closed(&self) -> bool
Returns if contour is closed.
Contour is closed if Path Verb array was last modified by close(). When stroked,
closed contour draws crate::paint::Join instead of crate::paint::Cap at first and last Point.
Returns: true if the last contour ends with a [Verb::Close]
example: https://fiddle.skia.org/c/@Path_isLastContourClosed
Sourcepub fn is_volatile(&self) -> bool
pub fn is_volatile(&self) -> bool
Returns true if the path is volatile; it will not be altered or discarded
by the caller after it is drawn. Path by default have volatile set false, allowing
crate::Surface to attach a cache of data which speeds repeated drawing. If true, crate::Surface
may not speed repeated drawing.
Returns: true if caller will alter Path after drawing
Sourcepub fn with_is_volatile(&self, is_volatile: bool) -> Self
pub fn with_is_volatile(&self, is_volatile: bool) -> Self
Return a copy of Path with is_volatile indicating whether it will be altered
or discarded by the caller after it is drawn. Path by default have volatile
set false, allowing Skia to attach a cache of data which speeds repeated drawing.
Mark temporary paths, discarded or modified after use, as volatile to inform Skia that the path need not be cached.
Mark animating Path volatile to improve performance.
Mark unchanging Path non-volatile to improve repeated rendering.
raster surface Path draws are affected by volatile for some shadows.
GPU surface Path draws are affected by volatile for some shadows and concave geometries.
is_volatile-trueif caller will alterPathafter drawing
Returns: Path
Sourcepub fn is_line_degenerate(
p1: impl Into<Point>,
p2: impl Into<Point>,
exact: bool,
) -> bool
pub fn is_line_degenerate( p1: impl Into<Point>, p2: impl Into<Point>, exact: bool, ) -> bool
Tests if line between Point pair is degenerate.
Line with no length or that moves a very short distance is degenerate; it is
treated as a point.
exact changes the equality test. If true, returns true only if p1 equals p2.
If false, returns true if p1 equals or nearly equals p2.
p1- line start pointp2- line end pointexact- iffalse, allow nearly equals
Returns: true if line is degenerate; its length is effectively zero
Sourcepub fn is_quad_degenerate(
p1: impl Into<Point>,
p2: impl Into<Point>,
p3: impl Into<Point>,
exact: bool,
) -> bool
pub fn is_quad_degenerate( p1: impl Into<Point>, p2: impl Into<Point>, p3: impl Into<Point>, exact: bool, ) -> bool
Tests if quad is degenerate. Quad with no length or that moves a very short distance is degenerate; it is treated as a point.
p1- quad start pointp2- quad control pointp3- quad end pointexact- iftrue, returnstrueonly if p1, p2, and p3 are equal; iffalse, returnstrueif p1, p2, and p3 are equal or nearly equal
Returns: true if quad is degenerate; its length is effectively zero
Sourcepub fn is_cubic_degenerate(
p1: impl Into<Point>,
p2: impl Into<Point>,
p3: impl Into<Point>,
p4: impl Into<Point>,
exact: bool,
) -> bool
pub fn is_cubic_degenerate( p1: impl Into<Point>, p2: impl Into<Point>, p3: impl Into<Point>, p4: impl Into<Point>, exact: bool, ) -> bool
Tests if cubic is degenerate. Cubic with no length or that moves a very short distance is degenerate; it is treated as a point.
p1- cubic start pointp2- cubic control point 1p3- cubic control point 2p4- cubic end pointexact- iftrue, returnstrueonly if p1, p2, p3, and p4 are equal; iffalse, returnstrueif p1, p2, p3, and p4 are equal or nearly equal
Returns: true if cubic is degenerate; its length is effectively zero
Sourcepub fn is_line(&self) -> Option<(Point, Point)>
pub fn is_line(&self) -> Option<(Point, Point)>
Returns true if Path contains only one line;
Verb array has two entries: [Verb::Move], [Verb::Line].
If Path contains one line and line is not None, line is set to
line start point and line end point.
Returns false if Path is not one line; line is unaltered.
line- storage for line. May beNone
Returns: true if Path contains exactly one line
Sourcepub fn conic_weights(&self) -> &[scalar] ⓘ
pub fn conic_weights(&self) -> &[scalar] ⓘ
Return a read-only view into the path’s conic-weights.
pub fn count_points(&self) -> usize
pub fn count_verbs(&self) -> usize
Source§impl Handle<SkPath>
impl Handle<SkPath>
Sourcepub fn get_point(&self, index: usize) -> Option<Point>
👎Deprecated since 0.91.0: use points()
pub fn get_point(&self, index: usize) -> Option<Point>
Sourcepub fn get_points(&self, points: &mut [Point]) -> usize
👎Deprecated since 0.91.0
pub fn get_points(&self, points: &mut [Point]) -> usize
Returns number of points in Path.
Copies N points from the path into the span, where N = min(#points, span capacity)
DEPRECATED
points- span to receive the points. may be empty
Returns: the number of points in the path
Source§impl Handle<SkPath>
impl Handle<SkPath>
Sourcepub fn approximate_bytes_used(&self) -> usize
pub fn approximate_bytes_used(&self) -> usize
Returns the approximate byte size of the Path in memory.
Returns: approximate size
Sourcepub fn bounds(&self) -> &Rect
pub fn bounds(&self) -> &Rect
Returns minimum and maximum axes values of Point array.
Returns (0, 0, 0, 0) if Path contains no points. Returned bounds width and height may
be larger or smaller than area affected when Path is drawn.
Rect returned includes all Point added to Path, including Point associated with
[Verb::Move] that define empty contours.
Sourcepub fn update_bounds_cache(&mut self) -> &mut Self
pub fn update_bounds_cache(&mut self) -> &mut Self
Updates internal bounds so that subsequent calls to bounds() are instantaneous.
Unaltered copies of Path may also access cached bounds through bounds().
For now, identical to calling bounds() and ignoring the returned value.
Call to prepare Path subsequently drawn from multiple threads,
to avoid a race condition where each draw separately computes the bounds.
Sourcepub fn compute_tight_bounds(&self) -> Rect
pub fn compute_tight_bounds(&self) -> Rect
Returns minimum and maximum axes values of the lines and curves in Path.
Returns (0, 0, 0, 0) if Path contains no points.
Returned bounds width and height may be larger or smaller than area affected
when Path is drawn.
Includes Point associated with [Verb::Move] that define empty
contours.
Behaves identically to bounds() when Path contains
only lines. If Path contains curves, computed bounds includes
the maximum extent of the quad, conic, or cubic; is slower than bounds();
and unlike bounds(), does not cache the result.
Returns: tight bounds of curves in Path
Sourcepub fn conservatively_contains_rect(&self, rect: impl AsRef<Rect>) -> bool
pub fn conservatively_contains_rect(&self, rect: impl AsRef<Rect>) -> bool
Returns true if rect is contained by Path.
May return false when rect is contained by Path.
For now, only returns true if Path has one contour and is convex.
rect may share points and edges with Path and be contained.
Returns true if rect is empty, that is, it has zero width or height; and
the Point or line described by rect is contained by Path.
Returns: true if rect is contained
example: https://fiddle.skia.org/c/@Path_conservativelyContainsRect
Source§impl Handle<SkPath>
impl Handle<SkPath>
Sourcepub fn convert_conic_to_quads(
p0: impl Into<Point>,
p1: impl Into<Point>,
p2: impl Into<Point>,
w: scalar,
pts: &mut [Point],
pow2: usize,
) -> Option<usize>
pub fn convert_conic_to_quads( p0: impl Into<Point>, p1: impl Into<Point>, p2: impl Into<Point>, w: scalar, pts: &mut [Point], pow2: usize, ) -> Option<usize>
Approximates conic with quad array. Conic is constructed from start Point p0,
control Point p1, end Point p2, and weight w.
Quad array is stored in pts; this storage is supplied by caller.
Maximum quad count is 2 to the pow2.
Every third point in array shares last Point of previous quad and first Point of
next quad. Maximum pts storage size is given by:
(1 + 2 * (1 << pow2)) * sizeof(Point).
Returns quad count used the approximation, which may be smaller than the number requested.
conic weight determines the amount of influence conic control point has on the curve. w less than one represents an elliptical section. w greater than one represents a hyperbolic section. w equal to one represents a parabolic section.
Two quad curves are sufficient to approximate an elliptical conic with a sweep of up to 90 degrees; in this case, set pow2 to one.
p0- conic startPointp1- conic controlPointp2- conic endPointw- conic weightpts- storage for quad arraypow2- quad count, as power of two, normally 0 to 5 (1 to 32 quad curves)
Returns: number of quad curves written to pts
Sourcepub fn is_rect(&self) -> Option<(Rect, bool, PathDirection)>
pub fn is_rect(&self) -> Option<(Rect, bool, PathDirection)>
Returns Some(Rect, bool, PathDirection) if Path is equivalent to Rect when filled.
If false: rect, is_closed, and direction are unchanged.
If true: rect, is_closed, and direction are written to.
rect may be smaller than the Path bounds. Path bounds may include [Verb::Move] points
that do not alter the area drawn by the returned rect.
Returns: Some(rect, is_closed, direction) if Path contains Rect
Source§impl Handle<SkPath>
impl Handle<SkPath>
Sourcepub fn try_make_transform(&self, matrix: &Matrix) -> Option<Path>
pub fn try_make_transform(&self, matrix: &Matrix) -> Option<Path>
pub fn try_make_offset(&self, d: impl Into<Vector>) -> Option<Path>
pub fn try_make_scale(&self, (sx, sy): (scalar, scalar)) -> Option<Path>
Sourcepub fn with_transform(&self, matrix: &Matrix) -> Path
pub fn with_transform(&self, matrix: &Matrix) -> Path
Return a copy of Path with verb array, Point array, and weight transformed
by matrix. with_transform may change verbs and increase their number.
If the resulting path has any non-finite values, this will still return a path
but that path will return true for is_finite().
The newer pattern is to call try_make_transform which will only return a
path if the result is finite.
Returns: Path
pub fn make_transform(&self, m: &Matrix) -> Path
Sourcepub fn with_offset(&self, d: impl Into<Vector>) -> Path
pub fn with_offset(&self, d: impl Into<Vector>) -> Path
pub fn make_offset(&self, d: impl Into<Vector>) -> Path
pub fn make_scale(&self, (sx, sy): (scalar, scalar)) -> Path
Source§impl Handle<SkPath>
impl Handle<SkPath>
Sourcepub fn segment_masks(&self) -> SegmentMask
pub fn segment_masks(&self) -> SegmentMask
Returns a mask, where each set bit corresponds to a SegmentMask constant
if Path contains one or more verbs of that type.
Returns zero if Path contains no lines, or curves: quads, conics, or cubics.
segment_masks() returns a cached result; it is very fast.
Returns: SegmentMask bits or zero
Source§impl Handle<SkPath>
impl Handle<SkPath>
Sourcepub fn set_is_volatile(&mut self, is_volatile: bool) -> &mut Self
pub fn set_is_volatile(&mut self, is_volatile: bool) -> &mut Self
Specifies whether Path is volatile; whether it will be altered or discarded
by the caller after it is drawn. Path by default have volatile set false, allowing
Device to attach a cache of data which speeds repeated drawing.
Mark temporary paths, discarded or modified after use, as volatile
to inform Device that the path need not be cached.
Mark animating Path volatile to improve performance.
Mark unchanging Path non-volatile to improve repeated rendering.
raster surface Path draws are affected by volatile for some shadows.
GPU surface Path draws are affected by volatile for some shadows and concave geometries.
is_volatile-trueif caller will alterPathafter drawing
Returns: reference to Path
Sourcepub fn swap(&mut self, other: &mut Path) -> &mut Self
pub fn swap(&mut self, other: &mut Path) -> &mut Self
Exchanges the verb array, Point array, weights, and PathFillType with other.
Cached state is also exchanged. swap() internally exchanges pointers, so
it is lightweight and does not allocate memory.
swap() usage has largely been replaced by PartialEq.
Path do not copy their content on assignment until they are written to,
making assignment as efficient as swap().
other-Pathexchanged by value
example: https://fiddle.skia.org/c/@Path_swap
Sourcepub fn set_fill_type(&mut self, ft: PathFillType) -> &mut Self
pub fn set_fill_type(&mut self, ft: PathFillType) -> &mut Self
Sets FillType, the rule used to fill Path. While there is no check
that ft is legal, values outside of FillType are not supported.
Sourcepub fn toggle_inverse_fill_type(&mut self) -> &mut Self
pub fn toggle_inverse_fill_type(&mut self) -> &mut Self
Replaces FillType with its inverse. The inverse of FillType describes the area unmodified by the original FillType.
Source§impl Handle<SkPath>
impl Handle<SkPath>
Sourcepub fn contains(&self, point: impl Into<Point>) -> bool
pub fn contains(&self, point: impl Into<Point>) -> bool
Returns true if the point is contained by Path, taking into
account PathFillType.
point- the point to test
Sourcepub fn dump_as_data(&self, dump_as_hex: bool) -> Data
pub fn dump_as_data(&self, dump_as_hex: bool) -> Data
Writes text representation of Path to Data.
Set dump_as_hex true to generate exact binary representations
of floating point numbers used in Point array and conic weights.
dump_as_hex-trueif scalar values are written as hexadecimal
example: https://fiddle.skia.org/c/@Path_dump
Sourcepub fn serialize(&self) -> Data
pub fn serialize(&self) -> Data
Writes Path to buffer, returning the buffer written to, wrapped in Data.
serialize() writes PathFillType, verb array, Point array, conic weight, and
additionally writes computed information like convexity and bounds.
serialize() should only be used in concert with read_from_memory().
The format used for Path in memory is not guaranteed.
pub fn deserialize(data: &Data) -> Option<Path>
Sourcepub fn generation_id(&self) -> u32
pub fn generation_id(&self) -> u32
(See skbug.com/40032862)
Returns a non-zero, globally unique value. A different value is returned
if verb array, Point array, or conic weight changes.
Setting PathFillType does not change generation identifier.
Each time the path is modified, a different generation identifier will be returned.
PathFillType does affect generation identifier on Android framework.
Returns: non-zero, globally unique value
Source§impl Handle<SkPathMeasure>
Warning: Even if you pass in a PathMeasure with multiple contours, most of this struct’s functions, including length only return the value for the first contour on the path (which is why they aren’t const). You must exhaust PathMeasure::next_contour.
impl Handle<SkPathMeasure>
Warning: Even if you pass in a PathMeasure with multiple contours, most of this struct’s functions, including length only return the value for the first contour on the path (which is why they aren’t const). You must exhaust PathMeasure::next_contour.
use skia_safe::{PathMeasure, Point, Path};
use std::f64::consts::PI;
let mut path = Path::circle((0., 0.), 10.0, None);
path.add_path(&Path::circle((100., 100.), 27.0, None), Point::default(), None);
let mut measure = PathMeasure::new(&path, false, None);
let mut lengths = vec![measure.length()];
while measure.next_contour() {
lengths.push(measure.length());
}
assert_eq!(*lengths.first().unwrap() as i64, (2. * PI * 10.0) as i64);
assert_eq!(*lengths.get(1).unwrap() as i64, (2. * PI * 27.0) as i64);
eprintln!("Circle lengths: {:?}", &lengths);pub fn new( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self
pub fn from_path( path: &Path, force_closed: bool, res_scale: impl Into<Option<scalar>>, ) -> Self
pub fn set_path(&mut self, path: &Path, force_closed: bool) -> &mut Self
pub fn length(&mut self) -> scalar
pub fn pos_tan(&mut self, distance: scalar) -> Option<(Point, Vector)>
pub fn matrix( &mut self, distance: scalar, flags: impl Into<Option<MatrixFlags>>, ) -> Option<Matrix>
pub fn get_matrix( &mut self, distance: scalar, matrix: &mut Matrix, flags: impl Into<Option<MatrixFlags>>, ) -> bool
pub fn segment( &mut self, start_d: scalar, stop_d: scalar, start_with_move_to: bool, ) -> Option<Path>
pub fn get_segment( &mut self, start_d: scalar, stop_d: scalar, dst: &mut PathBuilder, start_with_move_to: bool, ) -> bool
pub fn is_closed(&mut self) -> bool
pub fn next_contour(&mut self) -> bool
pub fn current_measure(&self) -> &Option<ContourMeasure>
Source§impl Handle<SkPictureRecorder>
impl Handle<SkPictureRecorder>
pub fn new() -> Self
pub fn begin_recording( &mut self, bounds: impl AsRef<Rect>, use_bbh: bool, ) -> &Canvas
pub fn recording_canvas(&mut self) -> Option<&Canvas>
pub fn finish_recording_as_picture( &mut self, cull_rect: Option<&Rect>, ) -> Option<Picture>
pub fn finish_recording_as_drawable(&mut self) -> Option<Drawable>
Source§impl Handle<SkRegion>
impl Handle<SkRegion>
pub fn new() -> Region
pub fn from_rect(rect: impl AsRef<IRect>) -> Region
pub fn set(&mut self, src: &Region) -> bool
pub fn swap(&mut self, other: &mut Region)
pub fn is_empty(&self) -> bool
pub fn is_rect(&self) -> bool
pub fn is_complex(&self) -> bool
pub fn bounds(&self) -> &IRect
pub fn compute_region_complexity(&self) -> usize
pub fn add_boundary_path(&self, path: &mut PathBuilder) -> bool
pub fn get_boundary_path(&self, path: &mut Path) -> bool
pub fn boundary_path(&self) -> Option<Path>
pub fn set_empty(&mut self) -> bool
pub fn set_rect(&mut self, rect: impl AsRef<IRect>) -> bool
pub fn set_rects(&mut self, rects: &[IRect]) -> bool
pub fn set_region(&mut self, region: &Region) -> bool
pub fn set_path(&mut self, path: &Path, clip: &Region) -> bool
pub fn intersects_rect(&self, rect: impl AsRef<IRect>) -> bool
pub fn intersects_region(&self, other: &Region) -> bool
pub fn contains_point(&self, point: IPoint) -> bool
pub fn contains_rect(&self, rect: impl AsRef<IRect>) -> bool
pub fn contains_region(&self, other: &Region) -> bool
pub fn quick_contains(&self, r: impl AsRef<IRect>) -> bool
pub fn quick_reject_rect(&self, rect: impl AsRef<IRect>) -> bool
pub fn quick_reject_region(&self, rgn: &Region) -> bool
pub fn translate(&mut self, d: impl Into<IVector>)
pub fn translated(&self, d: impl Into<IVector>) -> Self
pub fn op_rect(&mut self, rect: impl AsRef<IRect>, op: RegionOp) -> bool
pub fn op_region(&mut self, region: &Region, op: RegionOp) -> bool
pub fn op_rect_region( &mut self, rect: impl AsRef<IRect>, region: &Region, op: RegionOp, ) -> bool
pub fn op_region_rect( &mut self, region: &Region, rect: impl AsRef<IRect>, op: RegionOp, ) -> bool
pub fn write_to_memory(&self, buf: &mut Vec<u8>)
pub fn read_from_memory(&mut self, buf: &[u8]) -> usize
Source§impl Handle<SkStrokeRec>
impl Handle<SkStrokeRec>
pub fn new(init_style: InitStyle) -> Self
pub fn new_hairline() -> Self
pub fn new_fill() -> Self
pub fn from_paint( paint: &Paint, style: impl Into<Option<Style>>, res_scale: impl Into<Option<scalar>>, ) -> Self
pub fn style(&self) -> Style
pub fn width(&self) -> scalar
pub fn miter(&self) -> scalar
pub fn cap(&self) -> Cap
pub fn join(&self) -> Join
pub fn is_hairline_style(&self) -> bool
pub fn is_fill_style(&self) -> bool
pub fn set_fill_style(&mut self) -> &mut Self
pub fn set_hairline_style(&mut self) -> &mut Self
pub fn set_stroke_style( &mut self, width: scalar, stroke_and_fill: impl Into<Option<bool>>, ) -> &mut Self
pub fn set_stroke_params( &mut self, cap: Cap, join: Join, miter_limit: scalar, ) -> &mut Self
pub fn res_scale(&self) -> scalar
pub fn set_res_scale(&mut self, rs: scalar)
pub fn need_to_apply(&self) -> bool
pub fn apply_to_path(&self, dst: &mut PathBuilder, src: &Path) -> bool
pub fn apply_to_path_inplace(&self, path: &mut Path) -> bool
pub fn apply_to_paint(&self, paint: &mut Paint)
pub fn inflation_radius(&self) -> scalar
pub fn inflation_radius_from_paint_and_style( paint: &Paint, style: Style, ) -> scalar
pub fn inflation_radius_from_params( join: Join, miter_limit: scalar, cap: Cap, stroke_width: scalar, ) -> scalar
pub fn has_equal_effect(&self, other: &StrokeRec) -> bool
Source§impl Handle<SkTextBlobBuilder>
impl Handle<SkTextBlobBuilder>
pub fn new() -> Self
pub fn make(&mut self) -> Option<TextBlob>
pub fn alloc_run( &mut self, font: &Font, count: usize, offset: impl Into<Point>, bounds: Option<&Rect>, ) -> &mut [GlyphId] ⓘ
pub fn alloc_run_pos_h( &mut self, font: &Font, count: usize, y: scalar, bounds: Option<&Rect>, ) -> (&mut [GlyphId], &mut [scalar])
pub fn alloc_run_pos( &mut self, font: &Font, count: usize, bounds: Option<&Rect>, ) -> (&mut [GlyphId], &mut [Point])
pub fn alloc_run_rsxform( &mut self, font: &Font, count: usize, ) -> (&mut [GlyphId], &mut [RSXform])
pub fn alloc_run_text( &mut self, font: &Font, count: usize, offset: impl Into<Point>, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [GlyphId], &mut [u8], &mut [u32])
pub fn alloc_run_text_pos_h( &mut self, font: &Font, count: usize, y: scalar, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [GlyphId], &mut [scalar], &mut [u8], &mut [u32])
pub fn alloc_run_text_pos( &mut self, font: &Font, count: usize, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [GlyphId], &mut [Point], &mut [u8], &mut [u32])
pub fn alloc_run_text_rsxform( &mut self, font: &Font, count: usize, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [GlyphId], &mut [RSXform], &mut [u8], &mut [u32])
Source§impl Handle<SkVertices_Builder>
impl Handle<SkVertices_Builder>
pub fn new( mode: VertexMode, vertex_count: usize, index_count: usize, flags: BuilderFlags, ) -> Builder
pub fn positions(&mut self) -> &mut [Point]
pub fn indices(&mut self) -> Option<&mut [u16]>
pub fn tex_coords(&mut self) -> Option<&mut [Point]>
pub fn colors(&mut self) -> Option<&mut [Color]>
pub fn is_volatile(&self) -> bool
pub fn bone_indices(&mut self) -> Option<&mut [BoneIndices]>
pub fn bone_weights(&mut self) -> Option<&mut [BoneWeights]>
pub fn detach(self) -> Vertices
Source§impl Handle<SkYUVAInfo>
impl Handle<SkYUVAInfo>
pub const MAX_PLANES: usize = 4usize
Sourcepub fn new(
dimensions: impl Into<ISize>,
config: PlaneConfig,
subsampling: Subsampling,
color_space: YUVColorSpace,
origin: impl Into<Option<EncodedOrigin>>,
siting_xy: impl Into<Option<(Siting, Siting)>>,
) -> Option<Self>
pub fn new( dimensions: impl Into<ISize>, config: PlaneConfig, subsampling: Subsampling, color_space: YUVColorSpace, origin: impl Into<Option<EncodedOrigin>>, siting_xy: impl Into<Option<(Siting, Siting)>>, ) -> Option<Self>
dimensions should specify the size of the full resolution image (after planes have been
oriented to how the image is displayed as indicated by origin).
pub fn plane_config(&self) -> PlaneConfig
pub fn subsampling(&self) -> Subsampling
pub fn plane_subsampling_factors(&self, plane_index: usize) -> (i32, i32)
Sourcepub fn dimensions(&self) -> ISize
pub fn dimensions(&self) -> ISize
Dimensions of the full resolution image (after planes have been oriented to how the image is displayed as indicated by fOrigin).
pub fn width(&self) -> i32
pub fn height(&self) -> i32
pub fn yuv_color_space(&self) -> YUVColorSpace
pub fn siting_xy(&self) -> (Siting, Siting)
pub fn origin(&self) -> EncodedOrigin
pub fn origin_matrix(&self) -> Matrix
pub fn has_alpha(&self) -> bool
Sourcepub fn plane_dimensions(&self) -> Vec<ISize>
pub fn plane_dimensions(&self) -> Vec<ISize>
Returns the dimensions for each plane. Dimensions are as stored in memory, before transformation to image display space as indicated by [origin(&self)].
Sourcepub fn compute_total_bytes(
&self,
row_bytes: &[usize; 4],
plane_sizes: Option<&mut [usize; 4]>,
) -> usize
pub fn compute_total_bytes( &self, row_bytes: &[usize; 4], plane_sizes: Option<&mut [usize; 4]>, ) -> usize
Given a per-plane row bytes, determine size to allocate for all planes. Optionally retrieves
the per-plane byte sizes in planeSizes if not None. If total size overflows will return
SIZE_MAX and set all planeSizes to SIZE_MAX.
pub fn num_planes(&self) -> usize
pub fn num_channels_in_plane(&self, i: usize) -> Option<usize>
Sourcepub fn with_subsampling(&self, subsampling: Subsampling) -> Option<Self>
pub fn with_subsampling(&self, subsampling: Subsampling) -> Option<Self>
Returns a YUVAInfo that is identical to this one but with the passed Subsampling. If the
passed Subsampling is not Subsampling::S444 and this info’s PlaneConfig is not
compatible with chroma subsampling (because Y is in the same plane as UV) then the result
will be None.
Source§impl Handle<SkYUVAPixmapInfo_SupportedDataTypes>
impl Handle<SkYUVAPixmapInfo_SupportedDataTypes>
Sourcepub fn all() -> Self
pub fn all() -> Self
All legal combinations of PlaneConfig and DataType are supported.
Sourcepub fn supported(&self, pc: PlaneConfig, dt: DataType) -> bool
pub fn supported(&self, pc: PlaneConfig, dt: DataType) -> bool
Checks whether there is a supported combination of color types for planes structured as indicated by PlaneConfig with channel data types as indicated by DataType.
Sourcepub fn enable_data_type(&mut self, dt: DataType, num_channels: usize)
pub fn enable_data_type(&mut self, dt: DataType, num_channels: usize)
Update to add support for pixmaps with num_channels channels where each channel is
represented as DataType.
Source§impl Handle<SkYUVAPixmapInfo>
impl Handle<SkYUVAPixmapInfo>
pub const MAX_PLANES: usize = 4usize
pub const DATA_TYPE_CNT: usize = 3usize
Sourcepub fn new(
info: &YUVAInfo,
color_types: &[ColorType],
row_bytes: Option<&[usize]>,
) -> Option<Self>
pub fn new( info: &YUVAInfo, color_types: &[ColorType], row_bytes: Option<&[usize]>, ) -> Option<Self>
Initializes the YUVAPixmapInfo from a YUVAInfo with per-plane color types and row bytes. This will return None if the colorTypes aren’t compatible with the YUVAInfo or if a rowBytes entry is not valid for the plane dimensions and color type. Color type and row byte values beyond the number of planes in YUVAInfo are ignored. All ColorTypes must have the same DataType or this will return None.
If rowBytes is None then bpp*width is assumed for each plane.
Sourcepub fn from_data_type(
info: &YUVAInfo,
data_type: DataType,
row_bytes: Option<&[usize]>,
) -> Option<Self>
pub fn from_data_type( info: &YUVAInfo, data_type: DataType, row_bytes: Option<&[usize]>, ) -> Option<Self>
Like above but uses yuva_pixmap_info::default_color_type_for_data_type to determine each plane’s ColorType. If
rowBytes is None then bpp*width is assumed for each plane.
pub fn yuva_info(&self) -> &YUVAInfo
pub fn yuv_color_space(&self) -> YUVColorSpace
Sourcepub fn num_planes(&self) -> usize
pub fn num_planes(&self) -> usize
The number of Pixmap planes.
Sourcepub fn row_bytes(&self, i: usize) -> Option<usize>
pub fn row_bytes(&self, i: usize) -> Option<usize>
Row bytes for the ith plane. Returns None if i >= Self::num_planes() or this
YUVAPixmapInfo is invalid.
Sourcepub fn row_bytes_iter(&self) -> impl Iterator<Item = usize> + use<'_>
pub fn row_bytes_iter(&self) -> impl Iterator<Item = usize> + use<'_>
Row bytes for all planes.
Sourcepub fn plane_info(&self, i: usize) -> Option<&ImageInfo>
pub fn plane_info(&self, i: usize) -> Option<&ImageInfo>
Image info for the ith plane, or None if i >= Self::num_planes()
Sourcepub fn plane_infos(&self) -> impl Iterator<Item = &ImageInfo>
pub fn plane_infos(&self) -> impl Iterator<Item = &ImageInfo>
An iterator of all planes’ image infos.
Sourcepub fn compute_total_bytes(&self, plane_sizes: Option<&mut [usize; 4]>) -> usize
pub fn compute_total_bytes(&self, plane_sizes: Option<&mut [usize; 4]>) -> usize
Determine size to allocate for all planes. Optionally retrieves the per-plane sizes in
planeSizes if not None. If total size overflows will return SIZE_MAX and set all
plane_sizes to SIZE_MAX.
Sourcepub unsafe fn init_pixmaps_from_single_allocation(
&self,
memory: *mut c_void,
) -> Option<[Pixmap<'_>; 4]>
pub unsafe fn init_pixmaps_from_single_allocation( &self, memory: *mut c_void, ) -> Option<[Pixmap<'_>; 4]>
Takes an allocation that is assumed to be at least [compute_total_bytes(&self)] in size and configures the first [numPlanes(&self)] entries in pixmaps array to point into that memory. The remaining entries of pixmaps are default initialized. Returns None if this YUVAPixmapInfo not valid.
Sourcepub fn is_supported(&self, data_types: &SupportedDataTypes) -> bool
pub fn is_supported(&self, data_types: &SupportedDataTypes) -> bool
Is this valid and does it use color types allowed by the passed SupportedDataTypes?
Source§impl Handle<SkYUVAPixmaps>
impl Handle<SkYUVAPixmaps>
pub const MAX_PLANES: usize = 4usize
pub fn recommended_rgba_color_type(dt: DataType) -> ColorType
Sourcepub fn allocate(info: &YUVAPixmapInfo) -> Option<Self>
pub fn allocate(info: &YUVAPixmapInfo) -> Option<Self>
Allocate space for pixmaps’ pixels in the YUVAPixmaps.
Sourcepub fn from_data(info: &YUVAPixmapInfo, data: impl Into<Data>) -> Option<Self>
pub fn from_data(info: &YUVAPixmapInfo, data: impl Into<Data>) -> Option<Self>
Use storage in Data as backing store for pixmaps’ pixels. Data is retained by the YUVAPixmaps.
Sourcepub unsafe fn from_external_memory(
info: &YUVAPixmapInfo,
memory: *mut c_void,
) -> Option<Self>
pub unsafe fn from_external_memory( info: &YUVAPixmapInfo, memory: *mut c_void, ) -> Option<Self>
Use passed in memory as backing store for pixmaps’ pixels. Caller must ensure memory remains allocated while pixmaps are in use. There must be at least [YUVAPixmapInfo::computeTotalBytes(&self)] allocated starting at memory.
Sourcepub unsafe fn from_external_pixmaps(
info: &YUVAInfo,
pixmaps: &[Pixmap<'_>; 4],
) -> Option<Self>
pub unsafe fn from_external_pixmaps( info: &YUVAInfo, pixmaps: &[Pixmap<'_>; 4], ) -> Option<Self>
Wraps existing Pixmaps. The YUVAPixmaps will have no ownership of the Pixmaps’ pixel
memory so the caller must ensure it remains valid. Will return None if
the YUVAInfo isn’t compatible with the Pixmap array (number of planes, plane dimensions,
sufficient color channels in planes, …).
pub fn yuva_info(&self) -> &YUVAInfo
pub fn data_type(&self) -> DataType
pub fn pixmaps_info(&self) -> YUVAPixmapInfo
Sourcepub fn num_planes(&self) -> usize
pub fn num_planes(&self) -> usize
Number of pixmap planes.
Source§impl Handle<SkPDF_AttributeList>
Attributes for nodes in the PDF tree.
impl Handle<SkPDF_AttributeList>
Attributes for nodes in the PDF tree.
Each attribute must have an owner (e.g. “Layout”, “List”, “Table”, etc) and an attribute name (e.g. “BBox”, “RowSpan”, etc.) from PDF32000_2008 14.8.5, and then a value of the proper type according to the spec.
pub fn append_int( &mut self, owner: impl AsRef<str>, name: impl AsRef<str>, value: i32, ) -> &mut Self
pub fn append_float( &mut self, owner: impl AsRef<str>, name: impl AsRef<str>, value: f32, ) -> &mut Self
pub fn append_float_array( &mut self, owner: impl AsRef<str>, name: impl AsRef<str>, value: &[f32], ) -> &mut Self
Source§impl Handle<SkColorMatrix>
impl Handle<SkColorMatrix>
pub fn new( m00: f32, m01: f32, m02: f32, m03: f32, m04: f32, m10: f32, m11: f32, m12: f32, m13: f32, m14: f32, m20: f32, m21: f32, m22: f32, m23: f32, m24: f32, m30: f32, m31: f32, m32: f32, m33: f32, m34: f32, ) -> Self
pub fn rgb_to_yuv(rgb: YUVColorSpace) -> Self
pub fn yuv_to_rgb(yuv: YUVColorSpace) -> Self
pub fn set_identity(&mut self)
pub fn set_scale( &mut self, r_scale: f32, g_scale: f32, b_scale: f32, a_scale: impl Into<Option<f32>>, )
pub fn post_translate(&mut self, dr: f32, dg: f32, db: f32, da: f32)
pub fn set_concat(&mut self, a: &ColorMatrix, b: &ColorMatrix)
pub fn pre_concat(&mut self, mat: &ColorMatrix)
pub fn post_concat(&mut self, mat: &ColorMatrix)
pub fn set_saturation(&mut self, sat: f32)
pub fn set_row_major(&mut self, src: &[f32; 20])
pub fn get_row_major(&self, dst: &mut [f32; 20])
Source§impl Handle<SkRuntimeEffectBuilder>
impl Handle<SkRuntimeEffectBuilder>
pub fn new(effect: RuntimeEffect) -> Self
pub fn make_shader(&self, local_matrix: &Matrix) -> Option<Shader>
Sourcepub fn set_uniform_float(
&mut self,
name: impl AsRef<str>,
data: &[f32],
) -> Result<(), ShaderBuilderError>
pub fn set_uniform_float( &mut self, name: impl AsRef<str>, data: &[f32], ) -> Result<(), ShaderBuilderError>
Set float uniform values by name.
Supported types are float, float2, float3, float4, float2x2, float3x3, float4x4.
The data array must have the correct length for the corresponding uniform type:
float:[f32; 1]float2:[f32; 2]float3:[f32; 3]float4:[f32; 4]float2x2:[f32; 4]float3x3:[f32; 9]float4x4:[f32; 16]
Sourcepub fn set_uniform_int(
&mut self,
name: impl AsRef<str>,
data: &[i32],
) -> Result<(), ShaderBuilderError>
pub fn set_uniform_int( &mut self, name: impl AsRef<str>, data: &[i32], ) -> Result<(), ShaderBuilderError>
Set int uniform values by name.
Supported types are int, int2, int3, int4.
The data array must have the correct length for the corresponding uniform type:
int:[i32; 1]int2:[i32; 2]int3:[i32; 3]int4:[i32; 4]
Source§impl Handle<GrBackendFormat>
impl Handle<GrBackendFormat>
pub fn new() -> Self
pub fn new_gl(format: Enum, target: Enum) -> Self
pub fn new_vulkan( format: Format, will_use_drm_format_modifiers: impl Into<Option<bool>>, ) -> Self
pub fn new_vulkan_ycbcr( conversion_info: &YcbcrConversionInfo, will_use_drm_format_modifiers: impl Into<Option<bool>>, ) -> Self
pub fn new_metal(format: PixelFormat) -> Self
pub fn backend(&self) -> BackendAPI
pub fn channel_mask(&self) -> u32
pub fn as_gl_format(&self) -> Format
pub fn as_gl_format_enum(&self) -> Enum
pub fn as_vk_format(&self) -> Option<Format>
pub fn as_mtl_format(&self) -> Option<PixelFormat>
pub fn to_texture_2d(&self) -> Self
pub fn is_valid(&self) -> bool
Source§impl Handle<GrBackendRenderTarget>
impl Handle<GrBackendRenderTarget>
pub fn new_gl( (width, height): (i32, i32), sample_count: impl Into<Option<usize>>, stencil_bits: usize, info: FramebufferInfo, ) -> Self
pub fn new_vulkan((width, height): (i32, i32), info: &ImageInfo) -> Self
pub fn new_metal((width, height): (i32, i32), mtl_info: &TextureInfo) -> Self
pub fn dimensions(&self) -> ISize
pub fn width(&self) -> i32
pub fn height(&self) -> i32
pub fn sample_count(&self) -> usize
pub fn stencil_bits(&self) -> usize
pub fn backend(&self) -> BackendAPI
pub fn is_framebuffer_only(&self) -> bool
pub fn gl_framebuffer_info(&self) -> Option<FramebufferInfo>
pub fn vulkan_image_info(&self) -> Option<ImageInfo>
pub fn set_vulkan_image_layout(&mut self, layout: ImageLayout) -> &mut Self
pub fn metal_texture_info(&self) -> Option<TextureInfo>
pub fn backend_format(&self) -> BackendFormat
pub fn set_mutable_state(&mut self, state: &MutableTextureState)
pub fn is_protected(&self) -> bool
pub fn is_valid(&self) -> bool
Source§impl Handle<GrBackendDrawableInfo>
impl Handle<GrBackendDrawableInfo>
pub fn new() -> Self
pub fn from_vk(info: &DrawableInfo) -> Self
pub fn is_valid(&self) -> bool
pub fn backend(&self) -> BackendAPI
pub fn get_vk_drawable_info(&self) -> Option<DrawableInfo>
Source§impl Handle<GrYUVABackendTextureInfo>
impl Handle<GrYUVABackendTextureInfo>
pub const MAX_PLANES: usize = 4usize
Sourcepub fn new(
info: &YUVAInfo,
formats: &[BackendFormat],
mip_mapped: Mipmapped,
origin: SurfaceOrigin,
) -> Option<Self>
pub fn new( info: &YUVAInfo, formats: &[BackendFormat], mip_mapped: Mipmapped, origin: SurfaceOrigin, ) -> Option<Self>
Initializes a YUVABackendTextureInfo to describe a set of textures that can store the planes indicated by the YUVAInfo. The texture dimensions are taken from the YUVAInfo’s plane dimensions. All the described textures share a common origin. The planar image this describes will be mip mapped if all the textures are individually mip mapped as indicated by Mipmapped. This will return None if the passed formats’ channels don’t agree with YUVAInfo.
pub fn yuva_info(&self) -> &YUVAInfo
pub fn yuv_color_space(&self) -> YUVColorSpace
pub fn mipmapped(&self) -> Mipmapped
pub fn texture_origin(&self) -> SurfaceOrigin
Sourcepub fn num_planes(&self) -> usize
pub fn num_planes(&self) -> usize
The number of crate::Pixmap planes.
Sourcepub fn plane_format(&self, i: usize) -> Option<&BackendFormat>
pub fn plane_format(&self, i: usize) -> Option<&BackendFormat>
Format of the ith plane, or None if i >= Self::num_planes()
Sourcepub fn plane_formats(&self) -> &[BackendFormat] ⓘ
pub fn plane_formats(&self) -> &[BackendFormat] ⓘ
All plane formats.
Source§impl Handle<GrYUVABackendTextures>
impl Handle<GrYUVABackendTextures>
pub fn new( info: &YUVAInfo, textures: &[BackendTexture], texture_origin: SurfaceOrigin, ) -> Option<Self>
pub fn textures(&self) -> Vec<BackendTexture> ⓘ
pub fn texture(&self, i: usize) -> Option<BackendTexture>
pub fn yuva_info(&self) -> &YUVAInfo
pub fn num_planes(&self) -> usize
pub fn texture_origin(&self) -> SurfaceOrigin
Source§impl Handle<SkDynamicMemoryWStream>
impl Handle<SkDynamicMemoryWStream>
pub fn new() -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
pub fn write(&mut self, bytes: &[u8]) -> bool
pub fn detach_as_data(&mut self) -> Data
pub fn detach_as_stream(&mut self) -> Stream<SkStreamAsset>
Source§impl Handle<skia_textlayout_Paragraph_VisitorInfo>
impl Handle<skia_textlayout_Paragraph_VisitorInfo>
pub fn font(&self) -> &Font
pub fn origin(&self) -> Point
pub fn advance_x(&self) -> scalar
pub fn count(&self) -> usize
pub fn glyphs(&self) -> &[GlyphId] ⓘ
pub fn positions(&self) -> &[Point]
pub fn utf8_starts(&self) -> &[u32]
pub fn flags(&self) -> VisitorFlags
Source§impl Handle<skia_textlayout_Paragraph_ExtendedVisitorInfo>
impl Handle<skia_textlayout_Paragraph_ExtendedVisitorInfo>
pub fn font(&self) -> &Font
pub fn origin(&self) -> Point
pub fn advance(&self) -> Size
pub fn count(&self) -> usize
pub fn glyphs(&self) -> &[GlyphId] ⓘ
pub fn positions(&self) -> &[Point]
pub fn bounds(&self) -> &[Rect]
pub fn utf8_starts(&self) -> &[u32]
pub fn flags(&self) -> VisitorFlags
Source§impl Handle<skia_textlayout_StrutStyle>
impl Handle<skia_textlayout_StrutStyle>
pub fn new() -> Self
pub fn font_families(&self) -> FontFamilies<'_>
pub fn set_font_families(&mut self, families: &[impl AsRef<str>]) -> &mut Self
pub fn font_style(&self) -> FontStyle
pub fn set_font_style(&mut self, font_style: FontStyle) -> &mut Self
pub fn font_size(&self) -> scalar
pub fn set_font_size(&mut self, font_size: scalar) -> &mut Self
pub fn set_height(&mut self, height: scalar) -> &mut Self
pub fn height(&self) -> scalar
pub fn set_leading(&mut self, leading: scalar) -> &mut Self
pub fn leading(&self) -> scalar
pub fn strut_enabled(&self) -> bool
pub fn set_strut_enabled(&mut self, enabled: bool) -> &mut Self
pub fn force_strut_height(&self) -> bool
pub fn set_force_strut_height(&mut self, force_height: bool) -> &mut Self
pub fn height_override(&self) -> bool
pub fn set_height_override(&mut self, height_override: bool) -> &mut Self
pub fn half_leading(&self) -> bool
pub fn set_half_leading(&mut self, half_leading: bool) -> &mut Self
Source§impl Handle<skia_textlayout_TextStyle>
impl Handle<skia_textlayout_TextStyle>
pub fn new() -> Self
pub fn to_placeholder(&self) -> Self
pub fn clone_for_placeholder(&self) -> Self
pub fn equals(&self, other: &TextStyle) -> bool
pub fn equals_by_fonts(&self, that: &TextStyle) -> bool
pub fn match_one_attribute( &self, style_type: StyleType, other: &TextStyle, ) -> bool
pub fn color(&self) -> Color
pub fn set_color(&mut self, color: impl Into<Color>) -> &mut Self
pub fn has_foreground(&self) -> bool
pub fn foreground(&self) -> Paint
pub fn set_foreground_paint(&mut self, paint: &Paint) -> &mut Self
pub fn set_foreground_color(&mut self, paint: &Paint) -> &mut Self
pub fn clear_foreground_color(&mut self) -> &mut Self
pub fn has_background(&self) -> bool
pub fn background(&self) -> Paint
pub fn set_background_paint(&mut self, paint: &Paint) -> &mut Self
pub fn set_background_color(&mut self, paint: &Paint) -> &mut Self
pub fn clear_background_color(&mut self) -> &mut Self
pub fn decoration(&self) -> &Decoration
pub fn decoration_type(&self) -> TextDecoration
pub fn decoration_mode(&self) -> TextDecorationMode
pub fn decoration_color(&self) -> Color
pub fn decoration_style(&self) -> TextDecorationStyle
pub fn decoration_thickness_multiplier(&self) -> scalar
pub fn set_decoration(&mut self, decoration: &Decoration)
pub fn set_decoration_type(&mut self, decoration: TextDecoration)
pub fn set_decoration_mode(&mut self, mode: TextDecorationMode)
pub fn set_decoration_style(&mut self, style: TextDecorationStyle)
pub fn set_decoration_color(&mut self, color: impl Into<Color>)
pub fn set_decoration_thickness_multiplier(&mut self, multiplier: scalar)
pub fn decoration_mut(&mut self) -> &mut Decoration
pub fn font_style(&self) -> FontStyle
pub fn set_font_style(&mut self, font_style: FontStyle) -> &mut Self
pub fn shadows(&self) -> &[TextShadow]
pub fn add_shadow(&mut self, shadow: TextShadow) -> &mut Self
pub fn reset_shadows(&mut self) -> &mut Self
pub fn font_features(&self) -> &[FontFeature] ⓘ
pub fn add_font_feature(&mut self, font_feature: impl AsRef<str>, value: i32)
pub fn reset_font_features(&mut self)
pub fn font_arguments(&self) -> Option<&FontArguments>
Sourcepub fn set_font_arguments<'fa>(
&mut self,
arguments: impl Into<Option<&'fa FontArguments<'fa, 'fa>>>,
)
pub fn set_font_arguments<'fa>( &mut self, arguments: impl Into<Option<&'fa FontArguments<'fa, 'fa>>>, )
The contents of the crate::FontArguments will be copied into the TextStyle.
pub fn font_size(&self) -> scalar
pub fn set_font_size(&mut self, size: scalar) -> &mut Self
pub fn font_families(&self) -> FontFamilies<'_>
pub fn set_font_families(&mut self, families: &[impl AsRef<str>]) -> &mut Self
pub fn baseline_shift(&self) -> scalar
pub fn set_baseline_shift(&mut self, baseline_shift: scalar) -> &mut Self
pub fn set_height(&mut self, height: scalar) -> &mut Self
pub fn height(&self) -> scalar
pub fn set_height_override(&mut self, height_override: bool) -> &mut Self
pub fn height_override(&self) -> bool
pub fn set_half_leading(&mut self, half_leading: bool) -> &mut Self
pub fn half_leading(&self) -> bool
pub fn set_letter_spacing(&mut self, letter_spacing: scalar) -> &mut Self
pub fn letter_spacing(&self) -> scalar
pub fn set_word_spacing(&mut self, word_spacing: scalar) -> &mut Self
pub fn word_spacing(&self) -> scalar
pub fn typeface(&self) -> Option<Typeface>
pub fn set_typeface( &mut self, typeface: impl Into<Option<Typeface>>, ) -> &mut Self
pub fn locale(&self) -> &str
pub fn set_locale(&mut self, locale: impl AsRef<str>) -> &mut Self
pub fn text_baseline(&self) -> TextBaseline
pub fn set_text_baseline(&mut self, baseline: TextBaseline) -> &mut Self
pub fn font_metrics(&self) -> FontMetrics
pub fn is_placeholder(&self) -> bool
pub fn set_placeholder(&mut self) -> &mut Self
pub fn set_font_edging(&mut self, edging: Edging) -> &mut Self
pub fn font_edging(&self) -> Edging
pub fn set_subpixel(&mut self, subpixel: bool) -> &mut Self
pub fn subpixel(&self) -> bool
pub fn set_font_hinting(&mut self, hinting: FontHinting) -> &mut Self
pub fn font_hinting(&self) -> FontHinting
Source§impl Handle<SkPath>
impl Handle<SkPath>
pub fn op(&self, path: &Path, path_op: PathOp) -> Option<Self>
pub fn simplify(&self) -> Option<Self>
pub fn tight_bounds(&self) -> Option<Rect>
pub fn as_winding(&self) -> Option<Path>
Source§impl Handle<SkCustomTypefaceBuilder>
impl Handle<SkCustomTypefaceBuilder>
pub const FACTORY_ID: FactoryId
pub fn new() -> Self
pub fn set_glyph<'a>( &mut self, glyph_id: GlyphId, advance: f32, typeface_glyph: impl Into<TypefaceGlyph<'a>>, ) -> &mut Self
pub fn set_metrics( &mut self, font_metrics: &FontMetrics, scale: impl Into<Option<f32>>, ) -> &mut Self
pub fn set_font_style(&mut self, font_style: FontStyle) -> &mut Self
pub fn detach(&mut self) -> Option<Typeface>
pub fn from_data( data: impl Into<Data>, font_arguments: &FontArguments<'_, '_>, ) -> Option<Typeface>
Trait Implementations§
Source§impl Combine<Handle<SkRegion>, Handle<SkRegion>> for Handle<SkRegion>
impl Combine<Handle<SkRegion>, Handle<SkRegion>> for Handle<SkRegion>
fn combine(a: &Region, op: RegionOp, b: &Region) -> Self
fn difference(a: &A, b: &B) -> Self
fn intersect(a: &A, b: &B) -> Self
fn xor(a: &A, b: &B) -> Self
fn union(a: &A, b: &B) -> Self
fn reverse_difference(a: &A, b: &B) -> Self
fn replace(a: &A, b: &B) -> Self
Source§impl Combine<Handle<SkRegion>, IRect> for Handle<SkRegion>
impl Combine<Handle<SkRegion>, IRect> for Handle<SkRegion>
fn combine(region: &Region, op: RegionOp, rect: &IRect) -> Self
fn difference(a: &A, b: &B) -> Self
fn intersect(a: &A, b: &B) -> Self
fn xor(a: &A, b: &B) -> Self
fn union(a: &A, b: &B) -> Self
fn reverse_difference(a: &A, b: &B) -> Self
fn replace(a: &A, b: &B) -> Self
Source§impl Combine<IRect, Handle<SkRegion>> for Handle<SkRegion>
impl Combine<IRect, Handle<SkRegion>> for Handle<SkRegion>
fn combine(rect: &IRect, op: RegionOp, region: &Region) -> Self
fn difference(a: &A, b: &B) -> Self
fn intersect(a: &A, b: &B) -> Self
fn xor(a: &A, b: &B) -> Self
fn union(a: &A, b: &B) -> Self
fn reverse_difference(a: &A, b: &B) -> Self
fn replace(a: &A, b: &B) -> Self
Source§impl<'a> From<&'a Handle<SkPath>> for TypefaceGlyph<'a>
impl<'a> From<&'a Handle<SkPath>> for TypefaceGlyph<'a>
Source§impl Intersects<Handle<SkRegion>> for Region
impl Intersects<Handle<SkRegion>> for Region
fn intersects(&self, other: &Region) -> bool
Source§impl QuickReject<Handle<SkPath>> for Canvas
impl QuickReject<Handle<SkPath>> for Canvas
Source§fn quick_reject(&self, path: &Path) -> bool
fn quick_reject(&self, path: &Path) -> bool
Returns true if path, transformed by Matrix, can be quickly determined to be
outside of clip. May return false even though path is outside of clip.
Use to check if an area to be drawn is clipped out, to skip subsequent draw calls.
pathPathto compare with clip
Returns true if path, transformed by Matrix, does not intersect clip