pub struct Handle<N>(/* private fields */)
where
N: NativeDrop;Expand description
Wraps a native type that can be represented in Rust memory.
This type requires an implementation of the NativeDrop trait.
Implementations§
§impl Handle<SkCodecs_Decoder>
impl Handle<SkCodecs_Decoder>
pub fn from_stream<'a>(
&self,
stream: &'a mut impl Read,
) -> Result<Codec<'a>, SkCodec_Result>
pub fn from_stream<'a>( &self, stream: &'a mut impl Read, ) -> Result<Codec<'a>, SkCodec_Result>
§impl Handle<SkBitmap>
impl Handle<SkBitmap>
pub fn new() -> Handle<SkBitmap>
pub fn new() -> Handle<SkBitmap>
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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_empty_constructor
pub fn swap(&mut self, other: &mut Handle<SkBitmap>)
pub fn swap(&mut self, other: &mut Handle<SkBitmap>)
Swaps the fields of the two bitmaps.
Example (C++): https://fiddle.skia.org/c/@Bitmap_swap
pub fn info(&self) -> &Handle<SkImageInfo>
pub fn info(&self) -> &Handle<SkImageInfo>
Returns width, height, AlphaType, ColorType, and ColorSpace.
pub 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.
pub 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) -> SkAlphaType
pub fn color_space(&self) -> Option<RCHandle<SkColorSpace>>
pub fn color_space(&self) -> Option<RCHandle<SkColorSpace>>
Returns ColorSpace, the range of colors, associated with ImageInfo. The returned
ColorSpace is immutable.
pub 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.
pub 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().
pub 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.
pub fn draws_nothing(&self) -> bool
pub fn draws_nothing(&self) -> bool
pub 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.
pub fn set_alpha_type(&mut self, alpha_type: SkAlphaType) -> bool
pub fn set_alpha_type(&mut self, alpha_type: SkAlphaType) -> 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_setAlphaType
pub fn set_color_space(
&mut self,
color_space: impl Into<Option<RCHandle<SkColorSpace>>>,
)
pub fn set_color_space( &mut self, color_space: impl Into<Option<RCHandle<SkColorSpace>>>, )
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.
pub 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.
pub 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.
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_isImmutable
pub fn set_immutable(&mut self)
pub fn set_immutable(&mut self)
Sets internal flag to mark Bitmap as immutable. Once set, pixels can not change. Any
other bitmap sharing the same PixelRef are also marked as immutable.
Once PixelRef is marked immutable, the setting cannot be cleared.
Writing to immutable Bitmap pixels triggers an assert on debug builds.
Example (C++): https://fiddle.skia.org/c/@Bitmap_setImmutable
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_reset
pub fn compute_is_opaque(bm: &Handle<SkBitmap>) -> bool
pub fn compute_is_opaque(bm: &Handle<SkBitmap>) -> 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.
pub fn bounds(&self) -> IRect
pub fn bounds(&self) -> IRect
Returns IRect { 0, 0, width(), height() }.
Example (C++): https://fiddle.skia.org/c/@Bitmap_getBounds Example (C++): https://fiddle.skia.org/c/@Bitmap_getBounds_2
pub fn dimensions(&self) -> ISize
pub fn dimensions(&self) -> ISize
Returns ISize { width(), height() }.
pub fn get_subset(&self) -> IRect
pub fn get_subset(&self) -> IRect
Returns the bounds of this bitmap, offset by its PixelRef origin.
pub fn set_info(
&mut self,
image_info: &Handle<SkImageInfo>,
row_bytes: impl Into<Option<usize>>,
) -> bool
pub fn set_info( &mut self, image_info: &Handle<SkImageInfo>, 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()
Example (C++): https://fiddle.skia.org/c/@Bitmap_setInfo
pub fn try_alloc_pixels_flags(
&mut self,
image_info: &Handle<SkImageInfo>,
) -> bool
pub fn try_alloc_pixels_flags( &mut self, image_info: &Handle<SkImageInfo>, ) -> 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().
pub fn alloc_pixels_flags(&mut self, image_info: &Handle<SkImageInfo>)
pub fn alloc_pixels_flags(&mut self, image_info: &Handle<SkImageInfo>)
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().
Example (C++): https://fiddle.skia.org/c/@Bitmap_allocPixelsFlags
pub fn try_alloc_pixels_info(
&mut self,
image_info: &Handle<SkImageInfo>,
row_bytes: impl Into<Option<usize>>,
) -> bool
pub fn try_alloc_pixels_info( &mut self, image_info: &Handle<SkImageInfo>, 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().
pub fn alloc_pixels_info(
&mut self,
image_info: &Handle<SkImageInfo>,
row_bytes: impl Into<Option<usize>>,
)
pub fn alloc_pixels_info( &mut self, image_info: &Handle<SkImageInfo>, 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 ImageInfo 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().
Example (C++): https://fiddle.skia.org/c/@Bitmap_allocPixels Example (C++): https://fiddle.skia.org/c/@Bitmap_allocPixels_2
pub fn try_alloc_n32_pixels(
&mut self,
_: (i32, i32),
is_opaque: impl Into<Option<bool>>,
) -> bool
pub fn try_alloc_n32_pixels( &mut self, _: (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.
pub fn alloc_n32_pixels(
&mut self,
_: (i32, i32),
is_opaque: impl Into<Option<bool>>,
)
pub fn alloc_n32_pixels( &mut self, _: (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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_allocN32Pixels
pub unsafe fn install_pixels(
&mut self,
info: &Handle<SkImageInfo>,
pixels: *mut c_void,
row_bytes: usize,
) -> bool
pub unsafe fn install_pixels( &mut self, info: &Handle<SkImageInfo>, 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_installPixels_3
pub 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.
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_allocPixels_3
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_pixelRefOrigin
pub fn set_pixel_ref(
&mut self,
pixel_ref: impl Into<Option<RCHandle<SkPixelRef>>>,
offset: impl Into<IPoint>,
)
pub fn set_pixel_ref( &mut self, pixel_ref: impl Into<Option<RCHandle<SkPixelRef>>>, 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_setPixelRef
pub fn is_ready_to_draw(&self) -> bool
pub fn is_ready_to_draw(&self) -> bool
Returns true if Bitmap can be drawn.
pub fn generation_id(&self) -> u32
pub fn generation_id(&self) -> u32
Returns a unique value corresponding to the pixels in PixelRef.
Returns a different value after notify_pixels_changed() has been called.
Returns zero if PixelRef is None.
Determines if pixels have changed since last examined.
Example (C++): https://fiddle.skia.org/c/@Bitmap_getGenerationID
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_notifyPixelsChanged
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_eraseColor
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_eraseColor
pub 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.
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_erase
pub 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.
Example (C++): https://fiddle.skia.org/c/@Bitmap_erase
pub 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 None.
ColorSpace in ImageInfo is ignored. Some color precision may be lost in the
conversion to unpremultiplied color; original pixel data may have additional precision.
pub 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.
pub 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).
pub 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 None if ColorType is ColorType::Unknown, or
PixelRef is None.
Performs a lookup of pixel size; for better performance, call one of: get_addr8(),
get_addr16(), or get_addr32().
Example (C++): https://fiddle.skia.org/c/@Bitmap_getAddr
pub fn extract_subset(
&self,
dst: &mut Handle<SkBitmap>,
subset: impl AsRef<IRect>,
) -> bool
pub fn extract_subset( &self, dst: &mut Handle<SkBitmap>, 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
None PixelRefisNone- subset does not intersect
Self::bounds()
Example (C++): https://fiddle.skia.org/c/@Bitmap_extractSubset
pub unsafe fn read_pixels(
&self,
dst_info: &Handle<SkImageInfo>,
dst_pixels: *mut c_void,
dst_row_bytes: usize,
src_x: i32,
src_y: i32,
) -> bool
pub unsafe fn read_pixels( &self, dst_info: &Handle<SkImageInfo>, 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()PixelRefisNone
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 None, 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().
Example (C++): https://fiddle.skia.org/c/@Bitmap_readPixels_2
pub fn extract_alpha(
&self,
dst: &mut Handle<SkBitmap>,
paint: Option<&Handle<SkPaint>>,
) -> Option<IPoint>
pub fn extract_alpha( &self, dst: &mut Handle<SkBitmap>, paint: Option<&Handle<SkPaint>>, ) -> 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.
pub fn peek_pixels(&self) -> Option<Pixmap<'_>>
pub fn peek_pixels(&self) -> Option<Pixmap<'_>>
Copies Bitmap pixel address, row bytes, and ImageInfo to pixmap, if address is
available, and returns Some(Pixmap). If pixel address is not available, return None
and leave pixmap unchanged.
Example (C++): https://fiddle.skia.org/c/@Bitmap_peekPixels
pub fn to_shader<'a>(
&self,
tile_modes: impl Into<Option<(SkTileMode, SkTileMode)>>,
sampling: impl Into<SamplingOptions>,
local_matrix: impl Into<Option<&'a Matrix>>,
) -> Option<RCHandle<SkShader>>
pub fn to_shader<'a>( &self, tile_modes: impl Into<Option<(SkTileMode, SkTileMode)>>, sampling: impl Into<SamplingOptions>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<RCHandle<SkShader>>
Make a shader with the specified tiling, matrix and sampling.
Defaults to clamp in both X and Y.
§impl Handle<SkContextOptions>
impl Handle<SkContextOptions>
pub fn typeface_cache_count_limit(&self) -> i32
pub fn typeface_cache_count_limit(&self) -> i32
Maximum number of entries in the typeface cache. Each entry corresponds to a cached
Typeface. (1024 is the historical default value.)
pub fn resource_cache_total_byte_limit(&self) -> usize
pub fn resource_cache_total_byte_limit(&self) -> usize
Maximum total memory (in bytes) for the CPU resource cache, used for temporary bitmaps, scaled images, and other decoded resources. Entries are purged from the cache when memory usage exceeds this limit.
pub fn resource_cache_single_allocation_byte_limit(&self) -> usize
pub fn resource_cache_single_allocation_byte_limit(&self) -> usize
Maximum size (in bytes) for a single allocation in the CPU resource cache. When a cacheable entry is very large (e.g. a large scaled bitmap), adding it to the cache can cause most or all existing entries to be purged. If an entry’s size exceeds this limit, it is not cached at all.
0 means no separate single-allocation cap beyond
resource_cache_total_byte_limit().
pub fn font_cache_count_limit(&self) -> i32
pub fn font_cache_count_limit(&self) -> i32
Maximum number of entries (strikes) in the font cache. A cache entry is associated with each unique combination of typeface, point size, and matrix.
pub fn font_cache_limit(&self) -> usize
pub fn font_cache_limit(&self) -> usize
Maximum total memory (in bytes) used by the font/strike cache for glyph metrics, masks, and paths. If the cache needs to allocate more, it will purge previous entries.
When true, shared caches (such as the strike cache, the resource cache, and the typeface
cache) are guarded by internal mutexes so they can safely be accessed concurrently across
threads. (true is the default value.)
pub fn set_typeface_cache_count_limit(
&mut self,
limit: i32,
) -> &mut Handle<SkContextOptions>
pub fn set_typeface_cache_count_limit( &mut self, limit: i32, ) -> &mut Handle<SkContextOptions>
Sets the maximum number of entries in the typeface cache.
pub fn set_resource_cache_total_byte_limit(
&mut self,
limit: usize,
) -> &mut Handle<SkContextOptions>
pub fn set_resource_cache_total_byte_limit( &mut self, limit: usize, ) -> &mut Handle<SkContextOptions>
Sets the maximum total memory (in bytes) for the CPU resource cache.
pub fn set_resource_cache_single_allocation_byte_limit(
&mut self,
limit: usize,
) -> &mut Handle<SkContextOptions>
pub fn set_resource_cache_single_allocation_byte_limit( &mut self, limit: usize, ) -> &mut Handle<SkContextOptions>
Sets the maximum size (in bytes) for a single allocation in the CPU resource cache.
0 disables the separate single-allocation cap.
pub fn set_font_cache_count_limit(
&mut self,
limit: i32,
) -> &mut Handle<SkContextOptions>
pub fn set_font_cache_count_limit( &mut self, limit: i32, ) -> &mut Handle<SkContextOptions>
Sets the maximum number of entries (strikes) in the font cache.
pub fn set_font_cache_limit(
&mut self,
limit: usize,
) -> &mut Handle<SkContextOptions>
pub fn set_font_cache_limit( &mut self, limit: usize, ) -> &mut Handle<SkContextOptions>
Sets the maximum total memory (in bytes) used by the font/strike cache.
§impl Handle<SkContourMeasureIter>
impl Handle<SkContourMeasureIter>
pub fn new(
path: &Handle<SkPath>,
force_closed: bool,
res_scale: impl Into<Option<f32>>,
) -> Handle<SkContourMeasureIter> ⓘ
pub fn new( path: &Handle<SkPath>, force_closed: bool, res_scale: impl Into<Option<f32>>, ) -> Handle<SkContourMeasureIter> ⓘ
Initializes the iterator with a path.
The parts of the path that are needed are copied, so the caller is free to modify or delete the path after this call.
res_scale controls the precision of the measure. Values greater than
1 increase precision (and may slow down the computation).
pathsource path to iterate.force_closedwhether open contours are treated as closed.res_scaleoptional precision scale (defaults to1.0).
pub fn from_path(
path: &Handle<SkPath>,
force_closed: bool,
res_scale: impl Into<Option<f32>>,
) -> Handle<SkContourMeasureIter> ⓘ
pub fn from_path( path: &Handle<SkPath>, force_closed: bool, res_scale: impl Into<Option<f32>>, ) -> Handle<SkContourMeasureIter> ⓘ
Initializes the iterator with a path.
The parts of the path that are needed are copied, so the caller is free to modify or delete the path after this call.
res_scale controls the precision of the measure. Values greater than
1 increase precision (and may slow down the computation).
pathsource path to iterate.force_closedwhether open contours are treated as closed.res_scaleoptional precision scale (defaults to1.0).
pub fn reset(
&mut self,
path: &Handle<SkPath>,
force_closed: bool,
res_scale: impl Into<Option<f32>>,
) -> &mut Handle<SkContourMeasureIter> ⓘ
pub fn reset( &mut self, path: &Handle<SkPath>, force_closed: bool, res_scale: impl Into<Option<f32>>, ) -> &mut Handle<SkContourMeasureIter> ⓘ
Resets the iterator with a path.
The parts of the path that are needed are copied, so the caller is free to modify or delete the path after this call.
pathsource path to iterate.force_closedwhether open contours are treated as closed.res_scaleoptional precision scale (defaults to1.0).
§impl Handle<SkFont>
impl Handle<SkFont>
pub fn new(
typeface: impl Into<RCHandle<SkTypeface>>,
size: impl Into<Option<f32>>,
) -> Handle<SkFont>
pub fn new( typeface: impl Into<RCHandle<SkTypeface>>, size: impl Into<Option<f32>>, ) -> Handle<SkFont>
Constructs a font with default values with Typeface and size.
typefacefont and style used to draw and measure textsizeEM size in local coordinate units
pub fn from_typeface(
typeface: impl Into<RCHandle<SkTypeface>>,
size: impl Into<Option<f32>>,
) -> Handle<SkFont>
pub fn from_typeface( typeface: impl Into<RCHandle<SkTypeface>>, size: impl Into<Option<f32>>, ) -> Handle<SkFont>
Constructs a font with default values with Typeface and size.
typefacefont and style used to draw and measure textsizeEM size in local coordinate units
pub fn from_typeface_with_params(
typeface: impl Into<RCHandle<SkTypeface>>,
size: f32,
scale: f32,
skew: f32,
) -> Handle<SkFont>
pub fn from_typeface_with_params( typeface: impl Into<RCHandle<SkTypeface>>, size: f32, scale: f32, skew: f32, ) -> Handle<SkFont>
Constructs a font with default values with Typeface and size in points,
horizontal scale, and horizontal skew. Horizontal scale emulates condensed
and expanded fonts. Horizontal skew emulates oblique fonts.
typefacefont and style used to draw and measure textsizeEM size in local coordinate unitsscaletext horizontal scaleskewadditional shear on x-axis relative to y-axis
pub fn is_force_auto_hinting(&self) -> bool
pub fn is_force_auto_hinting(&self) -> bool
If true, instructs the font manager to always hint glyphs.
Returned value is only meaningful if platform uses FreeType as the font manager.
Returns true if all glyphs are hinted.
pub fn is_embedded_bitmaps(&self) -> bool
pub fn is_embedded_bitmaps(&self) -> bool
Returns true if font engine may return glyphs from font bitmaps instead of from outlines.
Returns true if glyphs may be font bitmaps.
pub fn is_subpixel(&self) -> bool
pub fn is_subpixel(&self) -> bool
Returns true if glyphs may be drawn at sub-pixel offsets.
Returns true if glyphs may be drawn at sub-pixel offsets.
pub fn is_linear_metrics(&self) -> bool
pub fn is_linear_metrics(&self) -> bool
Returns true if font and glyph metrics are requested to be linearly scalable.
Returns true if font and glyph metrics are requested to be linearly scalable.
pub fn is_embolden(&self) -> bool
pub fn is_embolden(&self) -> bool
Returns true if bold is approximated by increasing the stroke width when creating glyph bitmaps from outlines.
Returns true if bold is approximated through stroke width.
pub fn is_baseline_snap(&self) -> bool
pub fn is_baseline_snap(&self) -> bool
Returns true if baselines will be snapped to pixel positions when the current transformation matrix is axis aligned.
Returns true if baselines may be snapped to pixels.
pub fn set_force_auto_hinting(
&mut self,
force_auto_hinting: bool,
) -> &mut Handle<SkFont>
pub fn set_force_auto_hinting( &mut self, force_auto_hinting: bool, ) -> &mut Handle<SkFont>
Sets whether to always hint glyphs.
If force_auto_hinting is set, instructs the font manager to always hint glyphs.
Only affects platforms that use FreeType as the font manager.
force_auto_hintingsetting to always hint glyphs
pub fn set_embedded_bitmaps(
&mut self,
embedded_bitmaps: bool,
) -> &mut Handle<SkFont>
pub fn set_embedded_bitmaps( &mut self, embedded_bitmaps: bool, ) -> &mut Handle<SkFont>
Requests, but does not require, to use bitmaps in fonts instead of outlines.
embedded_bitmapssetting to use bitmaps in fonts
pub fn set_subpixel(&mut self, subpixel: bool) -> &mut Handle<SkFont>
pub fn set_subpixel(&mut self, subpixel: bool) -> &mut Handle<SkFont>
Requests, but does not require, that glyphs respect sub-pixel positioning.
subpixelsetting for sub-pixel positioning
pub fn set_linear_metrics(
&mut self,
linear_metrics: bool,
) -> &mut Handle<SkFont>
pub fn set_linear_metrics( &mut self, linear_metrics: bool, ) -> &mut Handle<SkFont>
Requests, but does not require, linearly scalable font and glyph metrics.
For outline fonts true means font and glyph metrics should ignore hinting and rounding.
Note that some bitmap formats may not be able to scale linearly and will ignore this flag.
linear_metricssetting for linearly scalable font and glyph metrics.
pub fn set_embolden(&mut self, embolden: bool) -> &mut Handle<SkFont>
pub fn set_embolden(&mut self, embolden: bool) -> &mut Handle<SkFont>
Increases stroke width when creating glyph bitmaps to approximate a bold typeface.
emboldensetting for bold approximation
pub fn set_baseline_snap(&mut self, baseline_snap: bool) -> &mut Handle<SkFont>
pub fn set_baseline_snap(&mut self, baseline_snap: bool) -> &mut Handle<SkFont>
Requests that baselines be snapped to pixels when the current transformation matrix is axis aligned.
baseline_snapsetting for baseline snapping to pixels
pub fn edging(&self) -> SkFont_Edging
pub fn edging(&self) -> SkFont_Edging
Whether edge pixels draw opaque or with partial transparency.
pub fn set_edging(&mut self, edging: SkFont_Edging) -> &mut Handle<SkFont>
pub fn set_edging(&mut self, edging: SkFont_Edging) -> &mut Handle<SkFont>
Requests, but does not require, that edge pixels draw opaque or with partial transparency.
pub fn set_hinting(&mut self, hinting: SkFontHinting) -> &mut Handle<SkFont>
pub fn set_hinting(&mut self, hinting: SkFontHinting) -> &mut Handle<SkFont>
Sets level of glyph outline adjustment.
Does not check for valid values of hinting.
pub fn hinting(&self) -> SkFontHinting
pub fn hinting(&self) -> SkFontHinting
Returns level of glyph outline adjustment.
pub fn with_size(&self, size: f32) -> Option<Handle<SkFont>>
pub fn with_size(&self, size: f32) -> Option<Handle<SkFont>>
Returns a font with the same attributes of this font, but with the specified size.
Returns None if size is less than zero, infinite, or NaN.
sizeEM size in local coordinate units
pub fn size(&self) -> f32
pub fn size(&self) -> f32
Return EM size in local coordinate units. See https://skia.org/docs/user/coordinates/#local-coordinates .
Returns EM size in local coordinate units.
pub fn scale_x(&self) -> f32
pub fn scale_x(&self) -> f32
Returns text scale on x-axis. Default value is 1.
Returns text horizontal scale.
pub fn skew_x(&self) -> f32
pub fn skew_x(&self) -> f32
Returns text skew on x-axis. Default value is zero.
Returns additional shear on x-axis relative to y-axis.
pub fn set_typeface(
&mut self,
tf: impl Into<RCHandle<SkTypeface>>,
) -> &mut Handle<SkFont>
pub fn set_typeface( &mut self, tf: impl Into<RCHandle<SkTypeface>>, ) -> &mut Handle<SkFont>
pub fn set_size(&mut self, size: f32) -> &mut Handle<SkFont>
pub fn set_size(&mut self, size: f32) -> &mut Handle<SkFont>
Sets the EM size in local coordinate units.
See https://skia.org/docs/user/coordinates/#local-coordinates .
Has no effect if size is not greater than or equal to zero.
sizeEM size in local coordinate units
pub fn set_scale_x(&mut self, scale_x: f32) -> &mut Handle<SkFont>
pub fn set_scale_x(&mut self, scale_x: f32) -> &mut Handle<SkFont>
Sets text scale on x-axis. Default value is 1.
scale_xtext horizontal scale
pub fn set_skew_x(&mut self, skew_x: f32) -> &mut Handle<SkFont>
pub fn set_skew_x(&mut self, skew_x: f32) -> &mut Handle<SkFont>
Sets text skew on x-axis. Default value is zero.
skew_xadditional shear on x-axis relative to y-axis
pub fn str_to_glyphs(&self, str: impl AsRef<str>, glyphs: &mut [u16]) -> usize
pub fn str_to_glyphs(&self, str: impl AsRef<str>, glyphs: &mut [u16]) -> usize
Converts str into glyph indices.
Returns the number of glyph indices represented by str.
See Self::text_to_glyphs() for details.
pub fn text_to_glyphs(
&self,
text: impl EncodedText,
glyphs: &mut [u16],
) -> usize
pub fn text_to_glyphs( &self, text: impl EncodedText, glyphs: &mut [u16], ) -> usize
Converts text into glyph indices.
Returns the number of glyph indices represented by text.
crate::TextEncoding specifies how text represents characters or glyphs.
glyphs may be empty, to compute the glyph count.
Does not check text for valid character codes or valid glyph indices.
If the text length is zero, returns zero. If the text includes a partial character, the partial character is ignored.
If the encoding is UTF-8 and text contains an invalid UTF-8 sequence,
zero is returned.
When the encoding is UTF-8, UTF-16, or UTF-32, then each Unicode codepoint is mapped to a
single glyph. This function uses the default character-to-glyph
mapping from the Typeface and maps characters not found in the
Typeface to zero.
If glyphs is not sufficient to store all the glyphs, no glyphs are copied.
The total glyph count is returned for subsequent buffer reallocation.
textcharacter storage encoded withcrate::TextEncodingglyphsstorage for glyph indices; may be empty
pub fn count_str(&self, str: impl AsRef<str>) -> usize
pub fn count_str(&self, str: impl AsRef<str>) -> usize
Returns number of glyphs represented by str.
See Self::count_text() for details.
pub fn count_text(&self, text: impl EncodedText) -> usize
pub fn count_text(&self, text: impl EncodedText) -> usize
Returns number of glyphs represented by text.
If the encoding is UTF-8, UTF-16, or UTF-32, then each Unicode codepoint is mapped to a single glyph.
textcharacter storage encoded withcrate::TextEncoding
pub fn str_to_glyphs_vec(&self, str: impl AsRef<str>) -> Vec<u16>
pub fn str_to_glyphs_vec(&self, str: impl AsRef<str>) -> Vec<u16>
Convenience variant of Self::str_to_glyphs() that returns the glyphs as a Vec.
pub fn text_to_glyphs_vec(&self, text: impl EncodedText) -> Vec<u16>
pub fn text_to_glyphs_vec(&self, text: impl EncodedText) -> Vec<u16>
Convenience variant of Self::text_to_glyphs() that returns the glyphs as a Vec.
pub fn measure_str(
&self,
str: impl AsRef<str>,
paint: Option<&Handle<SkPaint>>,
) -> (f32, Rect)
pub fn measure_str( &self, str: impl AsRef<str>, paint: Option<&Handle<SkPaint>>, ) -> (f32, Rect)
Returns the advance width of str and the bounding box of text.
See Self::measure_text() for details.
pub fn measure_text(
&self,
text: impl EncodedText,
paint: Option<&Handle<SkPaint>>,
) -> (f32, Rect)
pub fn measure_text( &self, text: impl EncodedText, paint: Option<&Handle<SkPaint>>, ) -> (f32, Rect)
Returns the advance width of text. The advance is the normal distance to move before drawing additional text. Returns the bounding box of text relative to (0, 0). The paint stroke settings, mask filter, or path effect may modify the bounds.
textcharacter storage encoded withcrate::TextEncodingpaintoptional; may beNone
Returns the sum of the default advance widths.
pub fn unichar_to_glyph(&self, uni: i32) -> u16
pub fn unichar_to_glyph(&self, uni: i32) -> u16
Returns glyph index for Unicode character.
If the character is not supported by the Typeface, returns 0.
uniUnicode character
pub fn unichar_to_glyphs(&self, uni: &[i32], glyphs: &mut [u16])
pub fn unichar_to_glyphs(&self, uni: &[i32], glyphs: &mut [u16])
Returns the glyph indices for each Unicode character in uni.
pub fn get_widths(&self, glyphs: &[u16], widths: &mut [f32])
pub fn get_widths(&self, glyphs: &[u16], widths: &mut [f32])
Retrieves the advance for each glyph in glyphs.
See Self::get_widths_bounds() for details.
pub fn make_strike_ref(&self) -> Handle<SkStrikeRef>
pub fn make_strike_ref(&self) -> Handle<SkStrikeRef>
Returns a strike ref for this font’s current settings.
A StrikeRef caches the resolved strike (font metrics engine), avoiding the overhead
of descriptor construction, hashing, and global cache lookup on each glyph query.
This is useful when making many glyph metric calls (e.g. Self::get_widths()) with the
same font configuration.
The returned StrikeRef is independent of this Font; subsequent changes to this
Font do not affect it. Create a new StrikeRef after changing font properties.
pub fn get_widths_bounds(
&self,
glyphs: &[u16],
widths: Option<&mut [f32]>,
bounds: Option<&mut [Rect]>,
paint: Option<&Handle<SkPaint>>,
)
pub fn get_widths_bounds( &self, glyphs: &[u16], widths: Option<&mut [f32]>, bounds: Option<&mut [Rect]>, paint: Option<&Handle<SkPaint>>, )
Retrieves the advance and bounds for each glyph in glyphs.
glyphsarray of glyph indices to be measuredwidthsreturns text advances for each glyph; may beNoneboundsreturns bounds for each glyph relative to (0, 0); may beNonepaintoptional, specifies stroking,crate::PathEffectandcrate::MaskFilter
pub fn get_bounds(
&self,
glyphs: &[u16],
bounds: &mut [Rect],
paint: Option<&Handle<SkPaint>>,
)
pub fn get_bounds( &self, glyphs: &[u16], bounds: &mut [Rect], paint: Option<&Handle<SkPaint>>, )
Retrieves the bounds for each glyph in glyphs.
If paint is not None, its stroking, crate::PathEffect, and crate::MaskFilter fields are
respected.
glyphsarray of glyph indices to be measuredboundsreturns bounds for each glyph relative to (0, 0)paintoptional, specifies stroking,crate::PathEffect, andcrate::MaskFilter
pub fn get_pos(&self, glyphs: &[u16], pos: &mut [Point], origin: Option<Point>)
pub fn get_pos(&self, glyphs: &[u16], pos: &mut [Point], origin: Option<Point>)
Retrieves the positions for each glyph, beginning at the specified origin.
glyphsarray of glyph indices to be positionedposreturns glyphs positionsoriginlocation of the first glyph. Defaults to{0, 0}.
pub fn get_x_pos(&self, glyphs: &[u16], x_pos: &mut [f32], origin: Option<f32>)
pub fn get_x_pos(&self, glyphs: &[u16], x_pos: &mut [f32], origin: Option<f32>)
Retrieves the x-positions for each glyph, beginning at the specified origin.
glyphsarray of glyph indices to be positionedx_posreturns glyphs x-positionsoriginx-position of the first glyph. Defaults to 0.
pub fn get_intercepts<'a>(
&self,
glyphs: &[u16],
pos: &[Point],
_: (f32, f32),
paint: impl Into<Option<&'a Handle<SkPaint>>>,
) -> Vec<f32>
pub fn get_intercepts<'a>( &self, glyphs: &[u16], pos: &[Point], _: (f32, f32), paint: impl Into<Option<&'a Handle<SkPaint>>>, ) -> Vec<f32>
Returns intervals [start, end] describing lines parallel to the advance that intersect
with the glyphs.
glyphsthe glyphs to intersectposthe position of each glyphtopthe top of the line intersectingbottomthe bottom of the line intersectingpaintoptional; may beNone
Returns an array of pairs of x values [start, end]. May be empty.
pub fn get_path(&self, glyph_id: u16) -> Option<Handle<SkPath>>
pub fn get_path(&self, glyph_id: u16) -> Option<Handle<SkPath>>
If the specified glyph can be represented as a path, return its path.
If it is not (e.g. it is represented with a bitmap) return None.
Note: an ‘empty’ glyph (e.g. what a space “ “ character might map to) can return a path, but that path may have zero contours.
pub fn metrics(&self) -> (f32, FontMetrics)
pub fn metrics(&self) -> (f32, FontMetrics)
Returns FontMetrics associated with Typeface.
The return value is the recommended spacing between lines: the sum of metrics
descent, ascent, and leading.
Results are scaled by text size but does not take into account
dimensions required by text scale, text skew, fake bold,
style stroke, and crate::PathEffect.
Returns the recommended spacing between lines.
pub fn spacing(&self) -> f32
pub fn spacing(&self) -> f32
Returns the recommended spacing between lines: the sum of metrics
descent, ascent, and leading.
Result is scaled by text size but does not take into account
dimensions required by stroking and crate::PathEffect.
Returns the same result as Self::metrics().
§impl Handle<SkColorInfo>
impl Handle<SkColorInfo>
pub fn new(
ct: ColorType,
at: SkAlphaType,
cs: impl Into<Option<RCHandle<SkColorSpace>>>,
) -> Handle<SkColorInfo>
pub fn new( ct: ColorType, at: SkAlphaType, cs: impl Into<Option<RCHandle<SkColorSpace>>>, ) -> Handle<SkColorInfo>
Creates ColorInfo from ColorType, AlphaType, and optionally ColorSpace.
If cs is None and ColorInfo is part of a drawing source, ColorSpace defaults to
sRGB, mapping into the surface ColorSpace. Parameters are not validated to see if their
values are legal, or that the combination is supported.
ctcolor typeatalpha typecsoptional color space
pub fn color_space(&self) -> Option<RCHandle<SkColorSpace>>
pub fn color_space(&self) -> Option<RCHandle<SkColorSpace>>
Returns the color space.
pub fn color_type(&self) -> ColorType
pub fn color_type(&self) -> ColorType
Returns the color type.
pub fn alpha_type(&self) -> SkAlphaType
pub fn alpha_type(&self) -> SkAlphaType
Returns the alpha type.
pub fn is_gamma_close_to_srgb(&self) -> bool
pub fn is_gamma_close_to_srgb(&self) -> bool
Returns true if the gamma is close to sRGB.
pub fn with_alpha_type(
&self,
new_alpha_type: SkAlphaType,
) -> Handle<SkColorInfo>
pub fn with_alpha_type( &self, new_alpha_type: SkAlphaType, ) -> Handle<SkColorInfo>
pub fn with_color_type(&self, new_color_type: ColorType) -> Handle<SkColorInfo>
pub fn with_color_type(&self, new_color_type: ColorType) -> Handle<SkColorInfo>
Creates ColorInfo with the same alpha type and color space, with the color type set to
new_color_type.
new_color_typenew color type
pub fn with_color_space(
&self,
cs: impl Into<Option<RCHandle<SkColorSpace>>>,
) -> Handle<SkColorInfo>
pub fn with_color_space( &self, cs: impl Into<Option<RCHandle<SkColorSpace>>>, ) -> Handle<SkColorInfo>
Creates ColorInfo with the same alpha type and color type, with the color space set to
cs. cs may be None.
csoptional color space
pub fn bytes_per_pixel(&self) -> usize
pub fn bytes_per_pixel(&self) -> usize
Returns the number of bytes per pixel required by the color type. Returns zero if the color
type is ColorType::Unknown.
pub fn shift_per_pixel(&self) -> usize
pub fn shift_per_pixel(&self) -> usize
Returns the bit shift converting row bytes to row pixels. Returns zero for
ColorType::Unknown. Returns one of: 0, 1, 2, 3, 4; left shift to convert pixels to bytes.
§impl Handle<SkImageInfo>
impl Handle<SkImageInfo>
pub fn new(
dimensions: impl Into<ISize>,
ct: ColorType,
at: SkAlphaType,
cs: impl Into<Option<RCHandle<SkColorSpace>>>,
) -> Handle<SkImageInfo>
pub fn new( dimensions: impl Into<ISize>, ct: ColorType, at: SkAlphaType, cs: impl Into<Option<RCHandle<SkColorSpace>>>, ) -> Handle<SkImageInfo>
Creates ImageInfo from integral dimensions, ColorType, AlphaType, and
optionally ColorSpace.
If cs is None and ImageInfo is part of a drawing source, ColorSpace defaults to
sRGB, mapping into the surface ColorSpace. Parameters are not validated to see if their
values are legal, or that the combination is supported.
dimensionspixel column and row count; must be zero or greaterctcolor typeatalpha typecsoptional color space
pub fn from_color_info(
dimensions: impl Into<ISize>,
color_info: Handle<SkColorInfo>,
) -> Handle<SkImageInfo>
pub fn from_color_info( dimensions: impl Into<ISize>, color_info: Handle<SkColorInfo>, ) -> Handle<SkImageInfo>
Creates ImageInfo from integral dimensions and ColorInfo. Parameters are not
validated to see if their values are legal, or that the combination is supported.
dimensionspixel column and row count; must be zero or greatercolor_infopixel encoding consisting ofColorType,AlphaType, andColorSpacewhich may beNone
pub fn new_n32(
dimensions: impl Into<ISize>,
at: SkAlphaType,
cs: impl Into<Option<RCHandle<SkColorSpace>>>,
) -> Handle<SkImageInfo>
pub fn new_n32( dimensions: impl Into<ISize>, at: SkAlphaType, cs: impl Into<Option<RCHandle<SkColorSpace>>>, ) -> Handle<SkImageInfo>
Creates ImageInfo from integral dimensions, an N32 color type, at, and optionally
ColorSpace. N32 will equal either BGRA 8888 or RGBA 8888, whichever is optimal.
If cs is None and ImageInfo is part of a drawing source, ColorSpace defaults to
sRGB, mapping into the surface ColorSpace. Parameters are not validated to see if their
values are legal, or that the combination is supported.
dimensionspixel column and row count; must be zero or greateratalpha typecsoptional color space
pub fn new_s32(
dimensions: impl Into<ISize>,
at: SkAlphaType,
) -> Handle<SkImageInfo>
pub fn new_s32( dimensions: impl Into<ISize>, at: SkAlphaType, ) -> Handle<SkImageInfo>
Creates ImageInfo from integral dimensions, an N32 color type, and at, with sRGB
ColorSpace. Parameters are not validated to see if their values are legal, or that the
combination is supported.
dimensionspixel column and row count; must be zero or greateratalpha type
pub fn new_n32_premul(
dimensions: impl Into<ISize>,
cs: impl Into<Option<RCHandle<SkColorSpace>>>,
) -> Handle<SkImageInfo>
pub fn new_n32_premul( dimensions: impl Into<ISize>, cs: impl Into<Option<RCHandle<SkColorSpace>>>, ) -> Handle<SkImageInfo>
Creates ImageInfo from integral dimensions, an N32 color type, premultiplied alpha,
and optional ColorSpace.
If cs is None and ImageInfo is part of a drawing source, ColorSpace defaults to
sRGB, mapping into the surface ColorSpace. Parameters are not validated to see if their
values are legal, or that the combination is supported.
dimensionspixel column and row count; must be zero or greatercsoptional color space
pub fn new_a8(dimensions: impl Into<ISize>) -> Handle<SkImageInfo>
pub fn new_a8(dimensions: impl Into<ISize>) -> Handle<SkImageInfo>
Creates ImageInfo from integral dimensions, an alpha-only color type, premultiplied
alpha, and no ColorSpace.
dimensionspixel column and row count; must be zero or greater
pub fn new_unknown(dimensions: Option<ISize>) -> Handle<SkImageInfo>
pub fn new_unknown(dimensions: Option<ISize>) -> Handle<SkImageInfo>
Creates ImageInfo from integral dimensions, an unknown color type, unknown alpha type,
and no ColorSpace. An ImageInfo used as a source does not draw, and one used as a
destination cannot be drawn to.
dimensionspixel column and row count; must be zero or greater
pub fn color_type(&self) -> ColorType
pub fn color_type(&self) -> ColorType
Returns the color type.
pub fn alpha_type(&self) -> SkAlphaType
pub fn alpha_type(&self) -> SkAlphaType
Returns the alpha type.
pub fn color_space(&self) -> Option<RCHandle<SkColorSpace>>
pub fn color_space(&self) -> Option<RCHandle<SkColorSpace>>
Returns ColorSpace, the range of colors. The returned ColorSpace is immutable.
pub fn color_info(&self) -> &Handle<SkColorInfo>
pub fn color_info(&self) -> &Handle<SkColorInfo>
pub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
Returns true if the alpha type is set to hint that all pixels are opaque; their alpha value is implicitly or explicitly 1.0. If true, and all pixels are not opaque, Skia may draw incorrectly.
This does not check if the color type allows alpha, or if any pixel value has transparency.
pub fn dimensions(&self) -> ISize
pub fn dimensions(&self) -> ISize
Returns the integral size of Self::width() and Self::height().
pub fn bounds(&self) -> IRect
pub fn bounds(&self) -> IRect
Returns the integral rectangle from the origin to Self::width() and Self::height().
pub fn is_gamma_close_to_srgb(&self) -> bool
pub fn is_gamma_close_to_srgb(&self) -> bool
Returns true if the associated ColorSpace is not None, and the ColorSpace gamma
is approximately the same as sRGB.
pub fn with_dimensions(
&self,
new_dimensions: impl Into<ISize>,
) -> Handle<SkImageInfo>
pub fn with_dimensions( &self, new_dimensions: impl Into<ISize>, ) -> Handle<SkImageInfo>
Creates ImageInfo with the same color type, color space, and alpha type, with dimensions
set to new_dimensions.
new_dimensionspixel column and row count; must be zero or greater
pub fn with_alpha_type(
&self,
new_alpha_type: SkAlphaType,
) -> Handle<SkImageInfo>
pub fn with_alpha_type( &self, new_alpha_type: SkAlphaType, ) -> Handle<SkImageInfo>
pub fn with_color_type(&self, new_color_type: ColorType) -> Handle<SkImageInfo>
pub fn with_color_type(&self, new_color_type: ColorType) -> Handle<SkImageInfo>
Creates ImageInfo with the same alpha type, color space, width, and height, with the
color type set to new_color_type.
new_color_typenew color type
pub fn with_color_space(
&self,
new_color_space: impl Into<Option<RCHandle<SkColorSpace>>>,
) -> Handle<SkImageInfo>
pub fn with_color_space( &self, new_color_space: impl Into<Option<RCHandle<SkColorSpace>>>, ) -> Handle<SkImageInfo>
Creates ImageInfo with the same alpha type, color type, width, and height, with the
color space set to new_color_space. new_color_space may be None.
new_color_spaceoptional color space
pub fn bytes_per_pixel(&self) -> usize
pub fn bytes_per_pixel(&self) -> usize
Returns the number of bytes per pixel required by the color type. Returns zero if the color
type is ColorType::Unknown.
pub fn shift_per_pixel(&self) -> usize
pub fn shift_per_pixel(&self) -> usize
Returns the bit shift converting row bytes to row pixels. Returns zero for
ColorType::Unknown. Returns one of: 0, 1, 2, 3; left shift to convert pixels to bytes.
pub fn min_row_bytes(&self) -> usize
pub fn min_row_bytes(&self) -> usize
Returns the minimum number of bytes per row, computed from the pixel width and color type, which specifies bytes per pixel. The bitmap maximum value for row bytes must fit in 31 bits.
pub fn compute_offset(
&self,
point: impl Into<IPoint>,
row_bytes: usize,
) -> usize
pub fn compute_offset( &self, point: impl Into<IPoint>, row_bytes: usize, ) -> usize
Returns the byte offset of a pixel from the pixel base address.
Asserts in debug builds if point is outside of bounds. Does not assert if row_bytes is
smaller than Self::min_row_bytes(), even though the result may be incorrect.
pointpixel column and row; both must be within the image boundsrow_bytessize of the pixel row or larger
pub fn compute_byte_size(&self, row_bytes: usize) -> usize
pub fn compute_byte_size(&self, row_bytes: usize) -> usize
Returns the storage required by the pixel array, given ImageInfo dimensions, color
type, and row_bytes. row_bytes is assumed to be at least Self::min_row_bytes().
Returns zero if the height is zero. Returns usize::MAX if the answer exceeds the range of
usize.
row_bytessize of the pixel row or larger
pub fn compute_min_byte_size(&self) -> usize
pub fn compute_min_byte_size(&self) -> usize
Returns the least storage required by the pixel buffer, using Self::min_row_bytes() to
compute the bytes for each pixel row.
Returns zero if the height is zero. Returns usize::MAX if the answer exceeds the range of
usize.
pub fn valid_row_bytes(&self, row_bytes: usize) -> bool
pub fn valid_row_bytes(&self, row_bytes: usize) -> bool
Returns true if row_bytes is valid for this ImageInfo.
row_bytessize of the pixel row including padding
pub fn reset(&mut self) -> &mut Handle<SkImageInfo>
pub fn reset(&mut self) -> &mut Handle<SkImageInfo>
Creates an empty ImageInfo with ColorType::Unknown, AlphaType::Unknown, a width
and height of zero, and no ColorSpace.
§impl Handle<SkMeshSpecification_Varying>
impl Handle<SkMeshSpecification_Varying>
pub fn new( ty: SkMeshSpecification_Varying_Type, name: impl AsRef<str>, ) -> Handle<SkMeshSpecification_Varying>
pub fn ty(&self) -> SkMeshSpecification_Varying_Type
pub fn name(&self) -> &str
§impl Handle<SkPaint>
impl Handle<SkPaint>
pub fn new<'a>(
color: impl AsRef<Color4f>,
color_space: impl Into<Option<&'a RCHandle<SkColorSpace>>>,
) -> Handle<SkPaint>
pub fn new<'a>( color: impl AsRef<Color4f>, color_space: impl Into<Option<&'a RCHandle<SkColorSpace>>>, ) -> Handle<SkPaint>
Constructs a paint with default values and the given color.
Sets alpha and RGB used when stroking and filling. The color is four floating
point values, unpremultiplied. The color values are interpreted as being in
the color_space. If color_space is None, then color is assumed to be in the
sRGB color space.
colorunpremultiplied RGBAcolor_spaceColorSpacedescribing the encoding of color
pub fn reset(&mut self) -> &mut Handle<SkPaint>
pub fn reset(&mut self) -> &mut Handle<SkPaint>
Sets all Paint contents to their initial values. This is equivalent to replacing
Paint with the result of Paint::default().
Example (C++): https://fiddle.skia.org/c/@Paint_reset
pub fn is_anti_alias(&self) -> bool
pub fn is_anti_alias(&self) -> bool
Returns true if pixels on the active edges of crate::Path may be drawn with partial transparency.
Returns antialiasing state.
pub fn set_anti_alias(&mut self, anti_alias: bool) -> &mut Handle<SkPaint>
pub fn set_anti_alias(&mut self, anti_alias: bool) -> &mut Handle<SkPaint>
Requests, but does not require, that edge pixels draw opaque or with partial transparency.
anti_aliassetting for antialiasing
pub fn is_dither(&self) -> bool
pub fn is_dither(&self) -> bool
Returns true if color error may be distributed to smooth color transition.
Returns dithering state.
pub fn set_dither(&mut self, dither: bool) -> &mut Handle<SkPaint>
pub fn set_dither(&mut self, dither: bool) -> &mut Handle<SkPaint>
Requests, but does not require, to distribute color error.
dithersetting for dithering
pub fn style(&self) -> SkPaint_Style
pub fn style(&self) -> SkPaint_Style
Returns whether the geometry is filled, stroked, or filled and stroked.
pub fn set_style(&mut self, style: SkPaint_Style) -> &mut Handle<SkPaint>
pub fn set_style(&mut self, style: SkPaint_Style) -> &mut Handle<SkPaint>
Sets whether the geometry is filled, stroked, or filled and stroked.
Has no effect if style is not a legal Style value.
Example (C++): https://fiddle.skia.org/c/@Paint_setStyle Example (C++): https://fiddle.skia.org/c/@Stroke_Width
pub fn set_stroke(&mut self, stroke: bool) -> &mut Handle<SkPaint>
pub fn set_stroke(&mut self, stroke: bool) -> &mut Handle<SkPaint>
Set paint’s style to Style::Stroke if true, or Style::Fill if false.
pub fn color(&self) -> Color
pub fn color(&self) -> Color
Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
Returns unpremultiplied ARGB.
pub fn color4f(&self) -> Color4f
pub fn color4f(&self) -> Color4f
Retrieves alpha and RGB, unpremultiplied, as four floating point values. RGB are extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
Returns unpremultiplied RGBA.
pub fn set_color(&mut self, color: impl Into<Color>) -> &mut Handle<SkPaint>
pub fn set_color(&mut self, color: impl Into<Color>) -> &mut Handle<SkPaint>
Sets alpha and RGB used when stroking and filling. The color is a 32-bit value, unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
colorunpremultiplied ARGB
Example (C++): https://fiddle.skia.org/c/@Paint_setColor
pub fn set_color4f<'a>(
&mut self,
color: impl AsRef<Color4f>,
color_space: impl Into<Option<&'a RCHandle<SkColorSpace>>>,
) -> &mut Handle<SkPaint>
pub fn set_color4f<'a>( &mut self, color: impl AsRef<Color4f>, color_space: impl Into<Option<&'a RCHandle<SkColorSpace>>>, ) -> &mut Handle<SkPaint>
Sets alpha and RGB used when stroking and filling. The color is four floating
point values, unpremultiplied. The color values are interpreted as being in
the color_space. If color_space is None, then color is assumed to be in the
sRGB color space.
colorunpremultiplied RGBAcolor_spaceColorSpacedescribing the encoding of color
pub fn alpha_f(&self) -> f32
pub fn alpha_f(&self) -> f32
Retrieves alpha from the color used when stroking and filling.
Returns alpha ranging from zero, fully transparent, to one, fully opaque.
pub fn alpha(&self) -> u8
pub fn alpha(&self) -> u8
Helper that scales the alpha by 255.
Returns alpha, from fully transparent (0) to fully opaque (255).
pub fn set_alpha_f(&mut self, alpha: f32) -> &mut Handle<SkPaint>
pub fn set_alpha_f(&mut self, alpha: f32) -> &mut Handle<SkPaint>
Replaces alpha, leaving RGB
unchanged. An out of range value triggers an assert in the debug
build. alpha is a value from 0.0 to 1.0.
alpha set to zero makes color fully transparent; alpha set to 1.0 makes color
fully opaque.
alphaalpha component of color
pub fn set_alpha(&mut self, alpha: u8) -> &mut Handle<SkPaint>
pub fn set_alpha(&mut self, alpha: u8) -> &mut Handle<SkPaint>
Helper that accepts an int between 0 and 255, and divides it by 255.0
pub fn set_argb(&mut self, a: u8, r: u8, g: u8, b: u8) -> &mut Handle<SkPaint>
pub fn set_argb(&mut self, a: u8, r: u8, g: u8, b: u8) -> &mut Handle<SkPaint>
Sets color used when drawing solid fills. The color components range from 0 to 255. The color is unpremultiplied; alpha sets the transparency independent of RGB.
aamount of alpha, from fully transparent (0) to fully opaque (255)ramount of red, from no red (0) to full red (255)gamount of green, from no green (0) to full green (255)bamount of blue, from no blue (0) to full blue (255)
Example (C++): https://fiddle.skia.org/c/@Paint_setARGB
pub fn stroke_width(&self) -> f32
pub fn stroke_width(&self) -> f32
Returns the thickness of the pen used by Paint to
outline the shape.
Returns zero for hairline, greater than zero for pen thickness.
pub fn set_stroke_width(&mut self, width: f32) -> &mut Handle<SkPaint>
pub fn set_stroke_width(&mut self, width: f32) -> &mut Handle<SkPaint>
Sets the thickness of the pen used by the paint to outline the shape. A stroke-width of zero is treated as “hairline” width. Hairlines are always exactly one pixel wide in device space (their thickness does not change as the canvas is scaled). Negative stroke-widths are invalid; setting a negative width will have no effect.
widthzero thickness for hairline; greater than zero for pen thickness
Example (C++): https://fiddle.skia.org/c/@Miter_Limit Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeWidth
pub fn stroke_miter(&self) -> f32
pub fn stroke_miter(&self) -> f32
Returns the limit at which a sharp corner is drawn beveled.
Returns zero and greater miter limit.
pub fn set_stroke_miter(&mut self, miter_limit: f32) -> &mut Handle<SkPaint>
pub fn set_stroke_miter(&mut self, miter_limit: f32) -> &mut Handle<SkPaint>
When stroking a small joinAngle with miter, the miterLength may be very long. When miterLength > maxMiterLength (or joinAngle < minJoinAngle) the join will become bevel. miterLimit = maxMiterLength / strokeWidth or miterLimit = 1 / sin(minJoinAngle / 2).
This call has no effect if the miter_limit passed is less than zero.
Values less than one will be treated as bevel.
miter_limitzero and greater miter limit
Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeMiter
pub fn stroke_cap(&self) -> SkPaint_Cap
pub fn stroke_cap(&self) -> SkPaint_Cap
Returns the geometry drawn at the beginning and end of strokes.
pub fn set_stroke_cap(&mut self, cap: SkPaint_Cap) -> &mut Handle<SkPaint>
pub fn set_stroke_cap(&mut self, cap: SkPaint_Cap) -> &mut Handle<SkPaint>
Sets the geometry drawn at the beginning and end of strokes.
Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeCap_a Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeCap_b
pub fn stroke_join(&self) -> SkPaint_Join
pub fn stroke_join(&self) -> SkPaint_Join
Returns the geometry drawn at the corners of strokes.
pub fn set_stroke_join(&mut self, join: SkPaint_Join) -> &mut Handle<SkPaint>
pub fn set_stroke_join(&mut self, join: SkPaint_Join) -> &mut Handle<SkPaint>
Sets the geometry drawn at the corners of strokes.
Example (C++): https://fiddle.skia.org/c/@Paint_setStrokeJoin
pub fn shader(&self) -> Option<RCHandle<SkShader>>
pub fn shader(&self) -> Option<RCHandle<SkShader>>
Returns optional colors used when filling a path, such as a gradient.
Does not alter Shader SkRefCnt.
Returns Shader if previously set, None otherwise.
Example (C++): https://fiddle.skia.org/c/@Paint_refShader
pub fn set_shader(
&mut self,
shader: impl Into<Option<RCHandle<SkShader>>>,
) -> &mut Handle<SkPaint>
pub fn set_shader( &mut self, shader: impl Into<Option<RCHandle<SkShader>>>, ) -> &mut Handle<SkPaint>
Sets optional colors used when filling a path, such as a gradient.
Sets Shader to shader, decreasing SkRefCnt of the previous Shader.
Increments shader SkRefCnt by one.
shaderhow geometry is filled with color; ifNone, color is used instead
Example (C++): https://fiddle.skia.org/c/@Color_Filter_Methods Example (C++): https://fiddle.skia.org/c/@Paint_setShader
pub fn color_filter(&self) -> Option<RCHandle<SkColorFilter>>
pub fn color_filter(&self) -> Option<RCHandle<SkColorFilter>>
Returns ColorFilter if set, or None.
Does not alter ColorFilter SkRefCnt.
Returns ColorFilter if previously set, None otherwise.
Example (C++): https://fiddle.skia.org/c/@Paint_refColorFilter
pub fn set_color_filter(
&mut self,
color_filter: impl Into<Option<RCHandle<SkColorFilter>>>,
) -> &mut Handle<SkPaint>
pub fn set_color_filter( &mut self, color_filter: impl Into<Option<RCHandle<SkColorFilter>>>, ) -> &mut Handle<SkPaint>
Sets ColorFilter to color_filter, decreasing SkRefCnt of the previous
ColorFilter. Pass None to clear ColorFilter.
Increments color_filter SkRefCnt by one.
color_filterColorFilterto apply to subsequent draw
Example (C++): https://fiddle.skia.org/c/@Blend_Mode_Methods Example (C++): https://fiddle.skia.org/c/@Paint_setColorFilter
pub fn as_blend_mode(&self) -> Option<SkBlendMode>
pub fn as_blend_mode(&self) -> Option<SkBlendMode>
If the current blender can be represented as a BlendMode enum, this returns that
enum in the option’s value. If it cannot, then the returned option does not
contain a value.
pub fn blend_mode_or(&self, default_mode: SkBlendMode) -> SkBlendMode
pub fn blend_mode_or(&self, default_mode: SkBlendMode) -> SkBlendMode
Queries the blender, and if it can be represented as a BlendMode, return that mode,
else return the default_mode provided.
pub fn blend_mode(&self) -> SkBlendMode
Use as_blend_mode() or blend_mode_or() instead.
pub fn is_src_over(&self) -> bool
pub fn is_src_over(&self) -> bool
Returns true iff the current blender claims to be equivalent to BlendMode::SrcOver.
Also returns true of the current blender is None.
pub fn set_blend_mode(&mut self, mode: SkBlendMode) -> &mut Handle<SkPaint>
pub fn set_blend_mode(&mut self, mode: SkBlendMode) -> &mut Handle<SkPaint>
Helper method for calling Paint::set_blender().
This sets a blender that implements the specified blendmode enum.
pub fn set_blender(
&mut self,
blender: impl Into<Option<RCHandle<SkBlender>>>,
) -> &mut Handle<SkPaint>
pub fn set_blender( &mut self, blender: impl Into<Option<RCHandle<SkBlender>>>, ) -> &mut Handle<SkPaint>
Sets the current blender, increasing its refcnt, and if a blender is already present, decreasing that object’s refcnt.
A None blender signifies the default SrcOver behavior.
For convenience, you can call Paint::set_blend_mode() if the blend effect can be
expressed as one of those values.
blendertheBlenderassigned to this paint, orNonefor the default
pub fn path_effect(&self) -> Option<RCHandle<SkPathEffect>>
pub fn path_effect(&self) -> Option<RCHandle<SkPathEffect>>
Returns PathEffect if set, or None.
Does not alter PathEffect SkRefCnt.
Returns PathEffect if previously set, None otherwise.
Example (C++): https://fiddle.skia.org/c/@Paint_refPathEffect
pub fn set_path_effect(
&mut self,
path_effect: impl Into<Option<RCHandle<SkPathEffect>>>,
) -> &mut Handle<SkPaint>
pub fn set_path_effect( &mut self, path_effect: impl Into<Option<RCHandle<SkPathEffect>>>, ) -> &mut Handle<SkPaint>
Sets PathEffect to path_effect, decreasing SkRefCnt of the previous
PathEffect. Pass None to leave the path geometry unaltered.
Increments path_effect SkRefCnt by one.
path_effectreplacecrate::Pathwith a modification when drawn
Example (C++): https://fiddle.skia.org/c/@Mask_Filter_Methods Example (C++): https://fiddle.skia.org/c/@Paint_setPathEffect
pub fn mask_filter(&self) -> Option<RCHandle<SkMaskFilter>>
pub fn mask_filter(&self) -> Option<RCHandle<SkMaskFilter>>
Returns MaskFilter if set, or None.
Does not alter MaskFilter SkRefCnt.
Returns MaskFilter if previously set, None otherwise.
Example (C++): https://fiddle.skia.org/c/@Paint_refMaskFilter
pub fn set_mask_filter(
&mut self,
mask_filter: impl Into<Option<RCHandle<SkMaskFilter>>>,
) -> &mut Handle<SkPaint>
pub fn set_mask_filter( &mut self, mask_filter: impl Into<Option<RCHandle<SkMaskFilter>>>, ) -> &mut Handle<SkPaint>
Sets MaskFilter to mask_filter, decreasing SkRefCnt of the previous
MaskFilter. Pass None to clear MaskFilter and leave MaskFilter effect on
mask alpha unaltered.
Increments mask_filter SkRefCnt by one.
mask_filtermodifies clipping mask generated from drawn geometry
Example (C++): https://fiddle.skia.org/c/@Paint_setMaskFilter Example (C++): https://fiddle.skia.org/c/@Typeface_Methods
pub fn image_filter(&self) -> Option<RCHandle<SkImageFilter>>
pub fn image_filter(&self) -> Option<RCHandle<SkImageFilter>>
Returns ImageFilter if set, or None.
Does not alter ImageFilter SkRefCnt.
Returns ImageFilter if previously set, None otherwise.
Example (C++): https://fiddle.skia.org/c/@Paint_refImageFilter
pub fn set_image_filter(
&mut self,
image_filter: impl Into<Option<RCHandle<SkImageFilter>>>,
) -> &mut Handle<SkPaint>
pub fn set_image_filter( &mut self, image_filter: impl Into<Option<RCHandle<SkImageFilter>>>, ) -> &mut Handle<SkPaint>
Sets ImageFilter to image_filter, decreasing SkRefCnt of the previous
ImageFilter. Pass None to clear ImageFilter, and remove ImageFilter effect
on drawing.
Increments image_filter SkRefCnt by one.
image_filterhowcrate::Imageis sampled when transformed
Example (C++): https://fiddle.skia.org/c/@Paint_setImageFilter
pub fn nothing_to_draw(&self) -> bool
pub fn nothing_to_draw(&self) -> bool
Returns true if Paint prevents all drawing;
otherwise, the Paint may or may not allow drawing.
Returns true if, for example, BlendMode combined with alpha computes a
new alpha of zero.
Returns true if Paint prevents all drawing.
Example (C++): https://fiddle.skia.org/c/@Paint_nothingToDraw
§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 convexity.
pub fn raw(
points: &[Point],
verbs: &[SkPathVerb],
conic_weights: &[f32],
fill_type: SkPathFillType,
is_volatile: impl Into<Option<bool>>,
) -> Handle<SkPath>
pub fn raw( points: &[Point], verbs: &[SkPathVerb], conic_weights: &[f32], fill_type: SkPathFillType, is_volatile: impl Into<Option<bool>>, ) -> Handle<SkPath>
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 new_from(
points: &[Point],
verbs: &[u8],
conic_weights: &[f32],
fill_type: SkPathFillType,
is_volatile: impl Into<Option<bool>>,
) -> Handle<SkPath>
👎Deprecated since 0.88.0: use raw()
pub fn new_from( points: &[Point], verbs: &[u8], conic_weights: &[f32], fill_type: SkPathFillType, is_volatile: impl Into<Option<bool>>, ) -> Handle<SkPath>
use raw()
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: SkPathFillType, dir: impl Into<Option<SkPathDirection>>, ) -> Handle<SkPath>
pub fn rect( rect: impl AsRef<Rect>, dir: impl Into<Option<SkPathDirection>>, ) -> Handle<SkPath>
pub fn oval( oval: impl AsRef<Rect>, dir: impl Into<Option<SkPathDirection>>, ) -> Handle<SkPath>
pub fn oval_with_start_index( oval: impl AsRef<Rect>, dir: SkPathDirection, start_index: usize, ) -> Handle<SkPath>
pub fn circle( center: impl Into<Point>, radius: f32, dir: impl Into<Option<SkPathDirection>>, ) -> Handle<SkPath>
pub fn rrect( rect: impl AsRef<RRect>, dir: impl Into<Option<SkPathDirection>>, ) -> Handle<SkPath>
pub fn rrect_with_start_index( rect: impl AsRef<RRect>, dir: SkPathDirection, start_index: usize, ) -> Handle<SkPath>
pub fn polygon( pts: &[Point], is_closed: bool, fill_type: impl Into<Option<SkPathFillType>>, is_volatile: impl Into<Option<bool>>, ) -> Handle<SkPath>
pub fn line(a: impl Into<Point>, b: impl Into<Point>) -> Handle<SkPath>
pub fn new_with_fill_type(fill_type: SkPathFillType) -> Handle<SkPath>
pub fn new_with_fill_type(fill_type: SkPathFillType) -> Handle<SkPath>
pub fn new() -> Handle<SkPath>
pub fn is_interpolatable(&self, compare: &Handle<SkPath>) -> bool
pub fn is_interpolatable(&self, compare: &Handle<SkPath>) -> 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
Example (C++): https://fiddle.skia.org/c/@Path_isInterpolatable
pub fn interpolate(
&self,
ending: &Handle<SkPath>,
weight: f32,
) -> Option<Handle<SkPath>>
pub fn interpolate( &self, ending: &Handle<SkPath>, weight: f32, ) -> Option<Handle<SkPath>>
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
Example (C++): https://fiddle.skia.org/c/@Path_interpolate
pub fn interpolate_inplace(
&self,
ending: &Handle<SkPath>,
weight: f32,
out: &mut Handle<SkPath>,
) -> bool
pub fn interpolate_inplace( &self, ending: &Handle<SkPath>, weight: f32, out: &mut Handle<SkPath>, ) -> 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
Returns: true if Path contain same number of Point
Example (C++): https://fiddle.skia.org/c/@Path_interpolate
pub fn fill_type(&self) -> SkPathFillType
pub fn fill_type(&self) -> SkPathFillType
Returns PathFillType, the rule used to fill Path.
Returns: current PathFillType setting
pub fn with_fill_type(&self, new_fill_type: SkPathFillType) -> Handle<SkPath>
pub 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
pub fn with_toggle_inverse_fill_type(&self) -> Handle<SkPath>
pub fn with_toggle_inverse_fill_type(&self) -> Handle<SkPath>
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.
pub 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.
pub fn is_oval(&self) -> Option<Rect>
pub fn is_oval(&self) -> Option<Rect>
Returns true if this path is recognized as an oval or circle.
bounds receives bounds of oval.
bounds is unmodified if oval is not found.
bounds- storage for boundingRectof oval; may beNone
Returns: true if Path is recognized as an oval or circle
Example (C++): https://fiddle.skia.org/c/@Path_isOval
pub 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 (C++): https://fiddle.skia.org/c/@Path_isLastContourClosed
pub 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
pub fn with_is_volatile(&self, is_volatile: bool) -> Handle<SkPath>
pub fn with_is_volatile(&self, is_volatile: bool) -> Handle<SkPath>
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
pub 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
Example (C++): https://fiddle.skia.org/c/@Path_IsLineDegenerate
pub 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
pub 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
pub 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
Example (C++): https://fiddle.skia.org/c/@Path_isLine
pub fn verbs(&self) -> &[SkPathVerb]
pub fn verbs(&self) -> &[SkPathVerb]
Return a read-only view into the path’s verbs.
pub fn conic_weights(&self) -> &[f32]
pub fn conic_weights(&self) -> &[f32]
Return a read-only view into the path’s conic-weights.
pub fn count_points(&self) -> usize
pub fn count_verbs(&self) -> usize
pub fn last_pt(&self) -> Option<Point>
pub fn last_pt(&self) -> Option<Point>
Return the last point, or None
Returns: The last if the path contains one or more Point, else returns None
Example (C++): https://fiddle.skia.org/c/@Path_getLastPt
§impl Handle<SkPath>
impl Handle<SkPath>
pub fn get_points(&self, points: &mut [Point]) -> usize
👎Deprecated since 0.91.0: use points()
pub fn get_points(&self, points: &mut [Point]) -> usize
use points()
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
pub fn get_verbs(&self, verbs: &mut [u8]) -> usize
👎Deprecated since 0.91.0
pub fn get_verbs(&self, verbs: &mut [u8]) -> usize
Returns number of points in Path.
Copies N points from the path into the span, where N = min(#points, span capacity)
DEPRECATED
verbs- span to store the verbs. may be empty.
Returns: the number of verbs in the path
Example (C++): https://fiddle.skia.org/c/@Path_getVerbs
§impl Handle<SkPath>
impl Handle<SkPath>
pub 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
pub fn bounds(&self) -> &Rect
pub fn bounds(&self) -> &Rect
Returns the min/max of the path’s ‘trimmed’ points. The trimmed points are all of the
points in the path, with the exception of the path having more than one contour, and the
final contour containing only a Verb::Move. In that case the trailing Verb::Move point
is ignored when computing the bounds.
If the path has no verbs, or the path contains non-finite values,
then {0, 0, 0, 0} is returned. (see is_finite())
Returns: bounds of the path’s points
pub fn update_bounds_cache(&mut self) -> &mut Handle<SkPath>
👎Deprecated since 0.100.0: SkPath bounds are no longer computed lazily
pub fn update_bounds_cache(&mut self) -> &mut Handle<SkPath>
SkPath bounds are no longer computed lazily
Calls Self::bounds() and ignores the result.
pub 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
Example (C++): https://fiddle.skia.org/c/@Path_computeTightBounds
pub 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 (C++): https://fiddle.skia.org/c/@Path_conservativelyContainsRect
§impl Handle<SkPath>
impl Handle<SkPath>
pub fn convert_conic_to_quads(
p0: impl Into<Point>,
p1: impl Into<Point>,
p2: impl Into<Point>,
w: f32,
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: f32, 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
pub fn is_rect(&self) -> Option<(Rect, bool, SkPathDirection)>
pub fn is_rect(&self) -> Option<(Rect, bool, SkPathDirection)>
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
Example (C++): https://fiddle.skia.org/c/@Path_isRect
§impl Handle<SkPath>
impl Handle<SkPath>
pub fn try_make_transform(&self, matrix: &Matrix) -> Option<Handle<SkPath>>
pub fn try_make_transform(&self, matrix: &Matrix) -> Option<Handle<SkPath>>
pub fn try_make_offset(&self, d: impl Into<Point>) -> Option<Handle<SkPath>>
pub fn try_make_scale(&self, _: (f32, f32)) -> Option<Handle<SkPath>>
pub fn with_transform(&self, matrix: &Matrix) -> Handle<SkPath>
pub fn with_transform(&self, matrix: &Matrix) -> Handle<SkPath>
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) -> Handle<SkPath>
pub fn with_offset(&self, d: impl Into<Point>) -> Handle<SkPath>
pub fn with_offset(&self, d: impl Into<Point>) -> Handle<SkPath>
pub fn make_offset(&self, d: impl Into<Point>) -> Handle<SkPath>
pub fn make_scale(&self, _: (f32, f32)) -> Handle<SkPath>
§impl Handle<SkPath>
impl Handle<SkPath>
pub fn segment_masks(&self) -> PathSegmentMask
pub fn segment_masks(&self) -> PathSegmentMask
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
§impl Handle<SkPath>
impl Handle<SkPath>
pub fn set_is_volatile(&mut self, is_volatile: bool) -> &mut Handle<SkPath>
pub fn set_is_volatile(&mut self, is_volatile: bool) -> &mut Handle<SkPath>
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
pub fn swap(&mut self, other: &mut Handle<SkPath>) -> &mut Handle<SkPath>
pub fn swap(&mut self, other: &mut Handle<SkPath>) -> &mut Handle<SkPath>
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 (C++): https://fiddle.skia.org/c/@Path_swap
pub fn set_fill_type(&mut self, ft: SkPathFillType) -> &mut Handle<SkPath>
pub fn set_fill_type(&mut self, ft: SkPathFillType) -> &mut Handle<SkPath>
Sets FillType, the rule used to fill Path. While there is no check
that ft is legal, values outside of FillType are not supported.
pub fn toggle_inverse_fill_type(&mut self) -> &mut Handle<SkPath>
pub fn toggle_inverse_fill_type(&mut self) -> &mut Handle<SkPath>
Replaces FillType with its inverse. The inverse of FillType describes the area unmodified by the original FillType.
§impl Handle<SkPath>
impl Handle<SkPath>
pub 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
pub fn dump_as_data(&self, dump_as_hex: bool) -> RCHandle<SkData>
pub fn dump_as_data(&self, dump_as_hex: bool) -> RCHandle<SkData>
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 (C++): https://fiddle.skia.org/c/@Path_dump
pub fn dump(&self)
pub fn dump(&self)
pub fn dump_hex(&self)
pub fn dump_hex(&self)
pub fn serialize(&self) -> RCHandle<SkData>
pub fn serialize(&self) -> RCHandle<SkData>
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.
Returns: Path data wrapped in Data buffer
Example (C++): https://fiddle.skia.org/c/@Path_serialize
pub fn deserialize(data: &RCHandle<SkData>) -> Option<Handle<SkPath>>
pub fn generation_id(&self) -> u64
pub fn generation_id(&self) -> u64
(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
Example (C++): https://fiddle.skia.org/c/@Path_getGenerationID
§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: &Handle<SkPath>,
force_closed: bool,
res_scale: impl Into<Option<f32>>,
) -> Handle<SkPathMeasure>
pub fn new( path: &Handle<SkPath>, force_closed: bool, res_scale: impl Into<Option<f32>>, ) -> Handle<SkPathMeasure>
Initializes the path measure with the specified path. The parts of the path that are needed are copied, so the client is free to modify/delete the path after this call.
res_scale controls the precision of the measure. Values > 1 increase the precision (and
possibly slow down the computation).
pathpath to measureforce_closedwhether to treat the path as closedres_scaleprecision of the measure
pub fn from_path( path: &Handle<SkPath>, force_closed: bool, res_scale: impl Into<Option<f32>>, ) -> Handle<SkPathMeasure>
Use PathMeasure::new
pub fn set_path(
&mut self,
path: &Handle<SkPath>,
force_closed: bool,
) -> &mut Handle<SkPathMeasure>
pub fn set_path( &mut self, path: &Handle<SkPath>, force_closed: bool, ) -> &mut Handle<SkPathMeasure>
Resets the path measure with the specified path. The parts of the path that are needed are copied, so the client is free to modify/delete the path after this call.
pathpath to measureforce_closedwhether to treat the path as closed
pub fn length(&mut self) -> f32
pub fn length(&mut self) -> f32
Returns the total length of the current contour, or 0 if no path is associated.
pub fn pos_tan(&mut self, distance: f32) -> Option<(Point, Point)>
pub fn pos_tan(&mut self, distance: f32) -> Option<(Point, Point)>
Pins distance to 0 <= distance <= length(), and then computes the corresponding position
and tangent. Returns None if there is no path, or a zero-length path was specified, in
which case the position and tangent are unchanged.
distancedistance along the contour
pub fn matrix( &mut self, distance: f32, flags: impl Into<Option<MatrixFlags>>, ) -> Option<Matrix>
Use get_matrix()
pub fn get_matrix(
&mut self,
distance: f32,
matrix: &mut Matrix,
flags: impl Into<Option<MatrixFlags>>,
) -> bool
pub fn get_matrix( &mut self, distance: f32, matrix: &mut Matrix, flags: impl Into<Option<MatrixFlags>>, ) -> bool
Pins distance to 0 <= distance <= length(), and then computes the corresponding matrix
(by calling Self::pos_tan()). Returns false if there is no path, or a zero-length path
was specified, in which case matrix is unchanged.
distancedistance along the contourmatrixstorage for the computed matrixflagswhich matrix components to compute
pub fn segment( &mut self, start_d: f32, stop_d: f32, start_with_move_to: bool, ) -> Option<Handle<SkPath>>
Use get_segment()
pub fn get_segment(
&mut self,
start_d: f32,
stop_d: f32,
dst: &mut RefHandle<SkPathBuilder>,
start_with_move_to: bool,
) -> bool
pub fn get_segment( &mut self, start_d: f32, stop_d: f32, dst: &mut RefHandle<SkPathBuilder>, start_with_move_to: bool, ) -> bool
Given a start and stop distance, appends to dst the intervening segment(s). If the segment
is zero-length, returns false, else returns true. start_d and stop_d are pinned to legal
values (0..length()). If start_d > stop_d then returns false (and leaves dst
untouched). Begins the segment with a move-to if start_with_move_to is true.
start_dstart distancestop_dstop distancedstpath builder receiving the segmentstart_with_move_towhether to begin with a move-to
pub fn next_contour(&mut self) -> bool
pub fn next_contour(&mut self) -> bool
Moves to the next contour in the path. Returns true if one exists, or false if we’re done with the path.
pub fn current_measure(&self) -> &Option<RCHandle<SkContourMeasure>>
§impl Handle<SkPictureRecorder>
impl Handle<SkPictureRecorder>
pub fn new() -> Handle<SkPictureRecorder>
pub fn begin_recording(
&mut self,
bounds: impl AsRef<Rect>,
use_bbh: bool,
) -> &Canvas
pub fn begin_recording( &mut self, bounds: impl AsRef<Rect>, use_bbh: bool, ) -> &Canvas
Returns the canvas that records the drawing commands.
boundsthe cull rect used when recording this picture. Any drawing that falls outside of this rect is undefined, and may be drawn or it may notuse_bbhwhether to use a bounding box hierarchy
pub fn recording_canvas(&mut self) -> Option<&Canvas>
pub fn recording_canvas(&mut self) -> Option<&Canvas>
Returns the recording canvas if one is active, or None if recording is not active. This
does not alter the ref count on the canvas (if present).
pub fn finish_recording_as_picture(
&mut self,
cull_rect: Option<&Rect>,
) -> Option<RCHandle<SkPicture>>
pub fn finish_recording_as_picture( &mut self, cull_rect: Option<&Rect>, ) -> Option<RCHandle<SkPicture>>
Signals that the caller is done recording. This invalidates the canvas returned by
Self::begin_recording() or Self::recording_canvas().
The returned picture is immutable. If during recording drawables were added to the canvas, these will have been “drawn” into a recording canvas, so that this resulting picture will reflect their current state, but will not contain a live reference to the drawables themselves.
cull_rectoptional cull rectangle
pub fn finish_recording_as_drawable(&mut self) -> Option<RCHandle<SkDrawable>>
pub fn finish_recording_as_drawable(&mut self) -> Option<RCHandle<SkDrawable>>
Signals that the caller is done recording. This invalidates the canvas returned by
Self::begin_recording() or Self::recording_canvas().
Unlike Self::finish_recording_as_picture(), which returns an immutable picture, the
returned drawable may contain live references to other drawables (if they were added to the
recording canvas) and therefore this drawable will reflect the current state of those nested
drawables anytime it is drawn or a new picture is snapped from it.
§impl Handle<SkRegion>
impl Handle<SkRegion>
pub fn new() -> Handle<SkRegion>
pub fn new() -> Handle<SkRegion>
Constructs an empty region. The region is set to empty bounds at (0, 0) with zero width and height.
Example (C++): https://fiddle.skia.org/c/@Region_empty_constructor
pub fn from_rect(rect: impl AsRef<IRect>) -> Handle<SkRegion>
pub fn from_rect(rect: impl AsRef<IRect>) -> Handle<SkRegion>
Constructs a rectangular region matching the bounds of rect.
rectbounds of the constructed region
Example (C++): https://fiddle.skia.org/c/@Region_copy_const_SkIRect
pub fn set(&mut self, src: &Handle<SkRegion>) -> bool
pub fn set(&mut self, src: &Handle<SkRegion>) -> bool
Sets the region to src, and returns true if src bounds is not empty. This makes the
region and src identical by value. Internally, the region and src share pointer values.
The underlying rectangle array is copied when modified.
Creating a region copy is very efficient and never allocates memory. Regions are always copied by value from the interface; the underlying shared pointers are not exposed.
srcregion to copy
pub fn swap(&mut self, other: &mut Handle<SkRegion>)
pub fn swap(&mut self, other: &mut Handle<SkRegion>)
Exchanges the rectangle array of the region and other. swap internally exchanges
pointers, so it is lightweight and does not allocate memory.
swap usage has largely been replaced by assignment. Paths do not copy their content on
assignment until they are written to, making assignment as efficient as swap.
otherregion to swap with
Example (C++): https://fiddle.skia.org/c/@Region_swap
pub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the region is empty. An empty region has bounds width or height less than
or equal to zero. The default constructor constructs an empty region; set_empty and
set_rect with dimensionless data make the region empty.
pub fn is_complex(&self) -> bool
pub fn is_complex(&self) -> bool
Returns true if the region is described by more than one rectangle.
pub fn bounds(&self) -> &IRect
pub fn bounds(&self) -> &IRect
Returns the minimum and maximum axes values of the rectangle array. Returns (0, 0, 0, 0) if the region is empty.
pub fn compute_region_complexity(&self) -> usize
pub fn compute_region_complexity(&self) -> usize
Returns a value that increases with the number of elements in the region. Returns zero if
the region is empty. Returns one if the region equals an IRect; otherwise, returns a
value greater than one indicating that the region is complex.
Call to compare regions for relative complexity.
Example (C++): https://fiddle.skia.org/c/@Region_computeRegionComplexity
pub fn add_boundary_path(&self, path: &mut RefHandle<SkPathBuilder>) -> bool
pub fn add_boundary_path(&self, path: &mut RefHandle<SkPathBuilder>) -> bool
Appends the outline of the region to the path builder. Returns true if the region is not empty; otherwise, returns false, and leaves the path unmodified.
pathpath to append to
Example (C++): https://fiddle.skia.org/c/@Region_getBoundaryPath
pub fn get_boundary_path(&self, path: &mut Handle<SkPath>) -> bool
Use boundary_path()
pub fn boundary_path(&self) -> Option<Handle<SkPath>>
pub fn boundary_path(&self) -> Option<Handle<SkPath>>
Returns the boundary of the region as a path, or None if the region is empty.
pub fn set_empty(&mut self) -> bool
pub fn set_empty(&mut self) -> bool
Constructs an empty region. The region is set to empty bounds at (0, 0) with zero width and height. Always returns false.
Example (C++): https://fiddle.skia.org/c/@Region_setEmpty
pub fn set_rect(&mut self, rect: impl AsRef<IRect>) -> bool
pub fn set_rect(&mut self, rect: impl AsRef<IRect>) -> bool
Constructs a rectangular region matching the bounds of rect. If rect is empty,
constructs an empty region and returns false.
rectbounds of the constructed region
Example (C++): https://fiddle.skia.org/c/@Region_setRect
pub fn set_rects(&mut self, rects: &[IRect]) -> bool
pub fn set_rects(&mut self, rects: &[IRect]) -> bool
Constructs a region as the union of the rectangles in rects. If rects is empty,
constructs an empty region. Returns false if the constructed region is empty.
May be faster than repeated calls to op.
rectsarray of rectangles
Example (C++): https://fiddle.skia.org/c/@Region_setRects
pub fn set_region(&mut self, region: &Handle<SkRegion>) -> bool
pub fn set_region(&mut self, region: &Handle<SkRegion>) -> bool
Sets the region to a copy of region. Creating a region copy is very efficient and never
allocates memory. Regions are always copied by value from the interface; the underlying
shared pointers are not exposed.
regionregion to copy by value
Example (C++): https://fiddle.skia.org/c/@Region_setRegion
pub fn set_path(
&mut self,
path: &Handle<SkPath>,
clip: &Handle<SkRegion>,
) -> bool
pub fn set_path( &mut self, path: &Handle<SkPath>, clip: &Handle<SkRegion>, ) -> bool
Constructs a region to match the outline of path within clip. Returns false if the
constructed region is empty.
The constructed region draws the same pixels as path through clip when anti-aliasing is
disabled.
pathpath providing outlineclipregion containing path
Example (C++): https://fiddle.skia.org/c/@Region_setPath
pub fn intersects_rect(&self, rect: impl AsRef<IRect>) -> bool
pub fn intersects_rect(&self, rect: impl AsRef<IRect>) -> bool
Returns true if the region intersects rect. Returns false if either rect or the region
is empty, or they do not intersect.
rectrectangle to intersect
Example (C++): https://fiddle.skia.org/c/@Region_intersects
pub fn intersects_region(&self, other: &Handle<SkRegion>) -> bool
pub fn intersects_region(&self, other: &Handle<SkRegion>) -> bool
Returns true if the region intersects other. Returns false if either other or the region
is empty, or they do not intersect.
otherregion to intersect
Example (C++): https://fiddle.skia.org/c/@Region_intersects_2
pub fn contains_point(&self, point: IPoint) -> bool
pub fn contains_point(&self, point: IPoint) -> bool
Returns true if the point (point.x, point.y) is inside the region. Returns false if the
region is empty.
pointtest point
Example (C++): https://fiddle.skia.org/c/@Region_contains
pub fn contains_rect(&self, rect: impl AsRef<IRect>) -> bool
pub fn contains_rect(&self, rect: impl AsRef<IRect>) -> bool
Returns true if rect is completely inside the region. Returns false if the region or
rect is empty.
rectrectangle to contain
Example (C++): https://fiddle.skia.org/c/@Region_contains_2
pub fn contains_region(&self, other: &Handle<SkRegion>) -> bool
pub fn contains_region(&self, other: &Handle<SkRegion>) -> bool
Returns true if other is completely inside the region. Returns false if the region or
other is empty.
otherregion to contain
Example (C++): https://fiddle.skia.org/c/@Region_contains_3
pub fn quick_contains(&self, r: impl AsRef<IRect>) -> bool
pub fn quick_contains(&self, r: impl AsRef<IRect>) -> bool
Returns true if the region is a single rectangle and contains r. May return false even
though the region contains r.
rrectangle to contain
pub fn quick_reject_rect(&self, rect: impl AsRef<IRect>) -> bool
pub fn quick_reject_rect(&self, rect: impl AsRef<IRect>) -> bool
Returns true if the region does not intersect rect. Returns true if rect is empty or the
region is empty. May return false even though the region does not intersect rect.
rectrectangle to intersect
pub fn quick_reject_region(&self, rgn: &Handle<SkRegion>) -> bool
pub fn quick_reject_region(&self, rgn: &Handle<SkRegion>) -> bool
Returns true if the region does not intersect rgn. Returns true if rgn is empty or the
region is empty. May return false even though the region does not intersect rgn.
rgnregion to intersect
pub fn translate(&mut self, d: impl Into<IPoint>)
pub fn translate(&mut self, d: impl Into<IPoint>)
Offsets the region by the vector (d.x, d.y). Has no effect if the region is empty.
doffset vector
Example (C++): https://fiddle.skia.org/c/@Region_translate_2
pub fn translated(&self, d: impl Into<IPoint>) -> Handle<SkRegion>
pub fn translated(&self, d: impl Into<IPoint>) -> Handle<SkRegion>
Returns a copy of the region offset by the vector (d.x, d.y).
doffset vector
pub fn op_rect(&mut self, rect: impl AsRef<IRect>, op: SkRegion_Op) -> bool
pub fn op_rect(&mut self, rect: impl AsRef<IRect>, op: SkRegion_Op) -> bool
Replaces the region with the result of the region op rect. Returns true if the replaced
region is not empty.
rectrectangle operandoplogical operation
pub fn op_region(&mut self, region: &Handle<SkRegion>, op: SkRegion_Op) -> bool
pub fn op_region(&mut self, region: &Handle<SkRegion>, op: SkRegion_Op) -> bool
Replaces the region with the result of the region op region. Returns true if the
replaced region is not empty.
regionregion operandoplogical operation
Example (C++): https://fiddle.skia.org/c/@Region_op_6
pub fn op_rect_region(
&mut self,
rect: impl AsRef<IRect>,
region: &Handle<SkRegion>,
op: SkRegion_Op,
) -> bool
pub fn op_rect_region( &mut self, rect: impl AsRef<IRect>, region: &Handle<SkRegion>, op: SkRegion_Op, ) -> bool
Replaces the region with the result of rect op region. Returns true if the replaced
region is not empty.
rectrectangle operandregionregion operandoplogical operation
Example (C++): https://fiddle.skia.org/c/@Region_op_4
pub fn op_region_rect(
&mut self,
region: &Handle<SkRegion>,
rect: impl AsRef<IRect>,
op: SkRegion_Op,
) -> bool
pub fn op_region_rect( &mut self, region: &Handle<SkRegion>, rect: impl AsRef<IRect>, op: SkRegion_Op, ) -> bool
Replaces the region with the result of region op rect. Returns true if the replaced
region is not empty.
regionregion operandrectrectangle operandoplogical operation
Example (C++): https://fiddle.skia.org/c/@Region_op_5
pub fn write_to_memory(&self, buf: &mut Vec<u8>)
pub fn write_to_memory(&self, buf: &mut Vec<u8>)
Writes the region to buf, and returns the number of bytes written.
bufstorage for binary data
Example (C++): https://fiddle.skia.org/c/@Region_writeToMemory
pub fn read_from_memory(&mut self, buf: &[u8]) -> usize
pub fn read_from_memory(&mut self, buf: &[u8]) -> usize
Constructs the region from buf of size buf.len(). Returns the bytes read. The returned
value will be a multiple of four or zero if the length was too small.
bufstorage for binary data
Example (C++): https://fiddle.skia.org/c/@Region_readFromMemory
§impl Handle<SkStrikeRef>
impl Handle<SkStrikeRef>
pub fn get_widths(&self, glyphs: &[u16], widths: &mut [f32])
pub fn get_widths(&self, glyphs: &[u16], widths: &mut [f32])
Retrieves the advance widths for each glyph.
widths receives min(widths.len(), glyphs.len()) values.
glyphsarray of glyph indices to be measuredwidthsreturns text advances for each glyph, in font units
pub fn get_width(&self, glyph: u16) -> f32
pub fn get_width(&self, glyph: u16) -> f32
Retrieves the advance width for a single glyph.
glyphglyph index to be measured
Returns advance width in font units.
pub fn get_widths_strided(
&self,
count: usize,
glyphs: &[u32],
glyph_stride_32: usize,
advances: &mut [f32],
advance_stride_32: usize,
)
pub fn get_widths_strided( &self, count: usize, glyphs: &[u32], glyph_stride_32: usize, advances: &mut [f32], advance_stride_32: usize, )
Retrieves the advance widths for each glyph, handling arbitrary strides for both input glyphs and output advances.
countnumber of glyphs to measureglyphsslice containing the first glyph ID, glyph is 32-bit, instead ofGlyphId, in preparation for large glyph ids.glyph_stride_32stride in 32-bit words between input glyph IDsadvancesslice containing the first output advanceadvance_stride_32stride in 32-bit words between output advances
pub fn get_widths_bounds(
&self,
glyphs: &[u16],
widths: Option<&mut [f32]>,
bounds: Option<&mut [Rect]>,
)
pub fn get_widths_bounds( &self, glyphs: &[u16], widths: Option<&mut [f32]>, bounds: Option<&mut [Rect]>, )
Retrieves the advance widths and bounds for each glyph.
widths receives min(widths.len(), glyphs.len()) values.
bounds receives min(bounds.len(), glyphs.len()) values.
glyphsarray of glyph indices to be measuredwidthsreturns text advances for each glyphboundsreturns bounds for each glyph relative to(0, 0)
§impl Handle<SkStrokeRec>
impl Handle<SkStrokeRec>
pub fn new(init_style: SkStrokeRec_InitStyle) -> Handle<SkStrokeRec>
pub fn new_hairline() -> Handle<SkStrokeRec>
pub fn new_fill() -> Handle<SkStrokeRec>
pub fn from_paint( paint: &Handle<SkPaint>, style: impl Into<Option<SkPaint_Style>>, res_scale: impl Into<Option<f32>>, ) -> Handle<SkStrokeRec>
pub fn style(&self) -> SkStrokeRec_Style
pub fn width(&self) -> f32
pub fn miter(&self) -> f32
pub fn cap(&self) -> SkPaint_Cap
pub fn join(&self) -> SkPaint_Join
pub fn is_hairline_style(&self) -> bool
pub fn is_fill_style(&self) -> bool
pub fn set_fill_style(&mut self) -> &mut Handle<SkStrokeRec>
pub fn set_hairline_style(&mut self) -> &mut Handle<SkStrokeRec>
pub fn set_stroke_style(
&mut self,
width: f32,
stroke_and_fill: impl Into<Option<bool>>,
) -> &mut Handle<SkStrokeRec>
pub fn set_stroke_style( &mut self, width: f32, stroke_and_fill: impl Into<Option<bool>>, ) -> &mut Handle<SkStrokeRec>
Specify the stroke width, and optionally if you want stroke + fill.
Note, if width is 0, then this request is taken to mean:
stroke_and_fill set to Some(true) -> new style will be Style::Fill
stroke_and_fill set to Some(false) or None -> new style will be Style::Hairline
widththe stroke widthstroke_and_fillwhether to stroke and fill
pub fn set_stroke_params( &mut self, cap: SkPaint_Cap, join: SkPaint_Join, miter_limit: f32, ) -> &mut Handle<SkStrokeRec>
pub fn res_scale(&self) -> f32
pub fn set_res_scale(&mut self, rs: f32)
pub fn need_to_apply(&self) -> bool
pub fn need_to_apply(&self) -> bool
Returns true if this specifies any thick stroking, i.e. Self::apply_to_path() will
return true.
pub fn apply_to_path(
&self,
dst: &mut RefHandle<SkPathBuilder>,
src: &Handle<SkPath>,
) -> bool
pub fn apply_to_path( &self, dst: &mut RefHandle<SkPathBuilder>, src: &Handle<SkPath>, ) -> bool
Apply these stroke parameters to the src path, returning the result in dst.
If there was no change (i.e. style == Style::Hairline or Style::Fill) this returns
false and dst is unchanged. Otherwise returns true and the result is stored in dst.
src and dst may be the same path.
dstpath builder receiving the resultsrcsource path
pub fn apply_to_path_inplace(&self, path: &mut Handle<SkPath>) -> bool
Use apply_to_path()
pub fn apply_to_paint(&self, paint: &mut Handle<SkPaint>)
pub fn apply_to_paint(&self, paint: &mut Handle<SkPaint>)
Applies these stroke parameters to a paint.
paintpaint to apply the stroke parameters to
pub fn inflation_radius(&self) -> f32
pub fn inflation_radius(&self) -> f32
Gives a conservative value for the outset that should be applied to a geometry’s bounds to account for any inflation due to applying this stroke record to the geometry.
pub fn inflation_radius_from_paint_and_style(
paint: &Handle<SkPaint>,
style: SkPaint_Style,
) -> f32
pub fn inflation_radius_from_paint_and_style( paint: &Handle<SkPaint>, style: SkPaint_Style, ) -> f32
Equivalent to constructing a stroke record from paint and style and calling
Self::inflation_radius(). This does not account for other effects on the paint (i.e.
path effects).
paintpaint used to construct the stroke recordstylestyle used to construct the stroke record
pub fn inflation_radius_from_params( join: SkPaint_Join, miter_limit: f32, cap: SkPaint_Cap, stroke_width: f32, ) -> f32
pub fn has_equal_effect(&self, other: &Handle<SkStrokeRec>) -> bool
pub fn has_equal_effect(&self, other: &Handle<SkStrokeRec>) -> bool
Compares if two stroke records have an equal effect on a path. Equal stroke records produce equal paths. Equality of produced paths does not take the res scale parameter into account.
otherstroke record to compare with
§impl Handle<SkTextBlobBuilder>
impl Handle<SkTextBlobBuilder>
pub fn new() -> Handle<SkTextBlobBuilder>
pub fn new() -> Handle<SkTextBlobBuilder>
Constructs an empty text blob builder. By default, the text blob builder has no runs.
pub fn make(&mut self) -> Option<RCHandle<SkTextBlob>>
pub fn make(&mut self) -> Option<RCHandle<SkTextBlob>>
Returns a TextBlob built from runs of glyphs added by the builder. The returned
TextBlob is immutable; it may be copied, but its contents may not be altered. Returns
None if no runs of glyphs were added by the builder.
Resets the text blob builder to its initial empty state, allowing it to be reused to build a new set of runs.
pub fn alloc_run(
&mut self,
font: &Handle<SkFont>,
count: usize,
offset: impl Into<Point>,
bounds: Option<&Rect>,
) -> &mut [u16]
pub fn alloc_run( &mut self, font: &Handle<SkFont>, count: usize, offset: impl Into<Point>, bounds: Option<&Rect>, ) -> &mut [u16]
Returns a run with storage for glyphs. The caller must write count glyphs to the returned
glyph buffer before the next call to the text blob builder.
Glyphs share metrics in font.
Glyphs are positioned on a baseline at offset, using font metrics to determine their
relative placement.
bounds defines an optional bounding box, used to suppress drawing when the text blob bounds
does not intersect the surface bounds. If bounds is None, the text blob bounds is
computed from offset and the glyph metrics.
fontfont used for this runcountnumber of glyphsoffsethorizontal and vertical offset within the blobboundsoptional run bounding box
pub fn alloc_run_pos_h(
&mut self,
font: &Handle<SkFont>,
count: usize,
y: f32,
bounds: Option<&Rect>,
) -> (&mut [u16], &mut [f32])
pub fn alloc_run_pos_h( &mut self, font: &Handle<SkFont>, count: usize, y: f32, bounds: Option<&Rect>, ) -> (&mut [u16], &mut [f32])
Returns a run with storage for glyphs and positions along a baseline. The caller must write
count glyphs to the returned glyph buffer and count scalars to the returned position
buffer before the next call to the text blob builder.
Glyphs share metrics in font.
Glyphs are positioned on a baseline at y, using x-axis positions written by the caller to
the returned position buffer.
bounds defines an optional bounding box, used to suppress drawing when the text blob bounds
does not intersect the surface bounds. If bounds is None, the text blob bounds is
computed from y, the position buffer, and the glyph metrics.
fontfont used for this runcountnumber of glyphsyvertical offset within the blobboundsoptional run bounding box
pub fn alloc_run_pos(
&mut self,
font: &Handle<SkFont>,
count: usize,
bounds: Option<&Rect>,
) -> (&mut [u16], &mut [Point])
pub fn alloc_run_pos( &mut self, font: &Handle<SkFont>, count: usize, bounds: Option<&Rect>, ) -> (&mut [u16], &mut [Point])
Returns a run with storage for glyphs and point positions. The caller must write count
glyphs to the returned glyph buffer and count points to the returned position buffer
before the next call to the text blob builder.
Glyphs share metrics in font.
Glyphs are positioned using the points written by the caller to the returned position buffer, using two scalar values for each point.
bounds defines an optional bounding box, used to suppress drawing when the text blob bounds
does not intersect the surface bounds. If bounds is None, the text blob bounds is
computed from the position buffer and the glyph metrics.
fontfont used for this runcountnumber of glyphsboundsoptional run bounding box
pub fn alloc_run_rsxform(
&mut self,
font: &Handle<SkFont>,
count: usize,
) -> (&mut [u16], &mut [RSXform])
pub fn alloc_run_rsxform( &mut self, font: &Handle<SkFont>, count: usize, ) -> (&mut [u16], &mut [RSXform])
Returns a run with storage for glyphs and RSXform positions. The caller must write
count glyphs to the returned glyph buffer and count RSXforms to the returned position
buffer before the next call to the text blob builder.
Glyphs share metrics in font.
fontfont used for this runcountnumber of glyphs
pub fn alloc_run_text(
&mut self,
font: &Handle<SkFont>,
count: usize,
offset: impl Into<Point>,
text_byte_count: usize,
bounds: Option<&Rect>,
) -> (&mut [u16], &mut [u8], &mut [u32])
pub fn alloc_run_text( &mut self, font: &Handle<SkFont>, count: usize, offset: impl Into<Point>, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [u16], &mut [u8], &mut [u32])
Returns a run with storage for glyphs, text, and clusters. The caller must write count
glyphs to the returned glyph buffer, text_byte_count UTF-8 code units into the returned
text buffer, and count monotonic indexes into the text buffer into the returned cluster
buffer before the next call to the text blob builder.
Glyphs share metrics in font.
Glyphs are positioned on a baseline at offset, using font metrics to determine their
relative placement.
bounds defines an optional bounding box, used to suppress drawing when the text blob bounds
does not intersect the surface bounds. If bounds is None, the text blob bounds is
computed from offset and the glyph metrics.
fontfont used for this runcountnumber of glyphsoffsethorizontal and vertical offset within the blobtext_byte_countnumber of UTF-8 code unitsboundsoptional run bounding box
pub fn alloc_run_text_pos_h(
&mut self,
font: &Handle<SkFont>,
count: usize,
y: f32,
text_byte_count: usize,
bounds: Option<&Rect>,
) -> (&mut [u16], &mut [f32], &mut [u8], &mut [u32])
pub fn alloc_run_text_pos_h( &mut self, font: &Handle<SkFont>, count: usize, y: f32, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [u16], &mut [f32], &mut [u8], &mut [u32])
Returns a run with storage for glyphs, positions along a baseline, text, and clusters. The
caller must write count glyphs to the returned glyph buffer, count scalars to the
returned position buffer, text_byte_count UTF-8 code units into the returned text buffer,
and count monotonic indexes into the text buffer into the returned cluster buffer before
the next call to the text blob builder.
Glyphs share metrics in font.
Glyphs are positioned on a baseline at y, using x-axis positions written by the caller to
the returned position buffer.
bounds defines an optional bounding box, used to suppress drawing when the text blob bounds
does not intersect the surface bounds. If bounds is None, the text blob bounds is
computed from y, the position buffer, and the glyph metrics.
fontfont used for this runcountnumber of glyphsyvertical offset within the blobtext_byte_countnumber of UTF-8 code unitsboundsoptional run bounding box
pub fn alloc_run_text_pos(
&mut self,
font: &Handle<SkFont>,
count: usize,
text_byte_count: usize,
bounds: Option<&Rect>,
) -> (&mut [u16], &mut [Point], &mut [u8], &mut [u32])
pub fn alloc_run_text_pos( &mut self, font: &Handle<SkFont>, count: usize, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [u16], &mut [Point], &mut [u8], &mut [u32])
Returns a run with storage for glyphs, point positions, text, and clusters. The caller must
write count glyphs to the returned glyph buffer, count points to the returned position
buffer, text_byte_count UTF-8 code units into the returned text buffer, and count
monotonic indexes into the text buffer into the returned cluster buffer before the next call
to the text blob builder.
Glyphs share metrics in font.
Glyphs are positioned using the points written by the caller to the returned position buffer, using two scalar values for each point.
bounds defines an optional bounding box, used to suppress drawing when the text blob bounds
does not intersect the surface bounds. If bounds is None, the text blob bounds is
computed from the position buffer and the glyph metrics.
fontfont used for this runcountnumber of glyphstext_byte_countnumber of UTF-8 code unitsboundsoptional run bounding box
pub fn alloc_run_text_rsxform( &mut self, font: &Handle<SkFont>, count: usize, text_byte_count: usize, bounds: Option<&Rect>, ) -> (&mut [u16], &mut [RSXform], &mut [u8], &mut [u32])
§impl Handle<SkVertices_Builder>
impl Handle<SkVertices_Builder>
pub fn new( mode: SkVertices_VertexMode, vertex_count: usize, index_count: usize, flags: BuilderFlags, ) -> Handle<SkVertices_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
returns false
pub fn bone_indices(&mut self) -> Option<&mut [[u32; 4]]>
returns None
pub fn bone_weights(&mut self) -> Option<&mut [[u32; 4]]>
returns None
§impl Handle<SkYUVAInfo>
impl Handle<SkYUVAInfo>
pub const MAX_PLANES: usize
pub fn new(
dimensions: impl Into<ISize>,
config: SkYUVAInfo_PlaneConfig,
subsampling: Subsampling,
color_space: SkYUVColorSpace,
origin: impl Into<Option<EncodedOrigin>>,
siting_xy: impl Into<Option<(SkYUVAInfo_Siting, SkYUVAInfo_Siting)>>,
) -> Option<Handle<SkYUVAInfo>>
pub fn new( dimensions: impl Into<ISize>, config: SkYUVAInfo_PlaneConfig, subsampling: Subsampling, color_space: SkYUVColorSpace, origin: impl Into<Option<EncodedOrigin>>, siting_xy: impl Into<Option<(SkYUVAInfo_Siting, SkYUVAInfo_Siting)>>, ) -> Option<Handle<SkYUVAInfo>>
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) -> SkYUVAInfo_PlaneConfig
pub fn subsampling(&self) -> Subsampling
pub fn plane_subsampling_factors(&self, plane_index: usize) -> (i32, i32)
pub 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) -> SkYUVColorSpace
pub fn siting_xy(&self) -> (SkYUVAInfo_Siting, SkYUVAInfo_Siting)
pub fn origin(&self) -> EncodedOrigin
pub fn origin_matrix(&self) -> Matrix
pub fn inverse_origin_matrix(&self) -> Matrix
pub fn has_alpha(&self) -> bool
pub 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)].
pub 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>
pub fn with_subsampling(
&self,
subsampling: Subsampling,
) -> Option<Handle<SkYUVAInfo>>
pub fn with_subsampling( &self, subsampling: Subsampling, ) -> Option<Handle<SkYUVAInfo>>
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.
§impl Handle<SkYUVAPixmapInfo>
impl Handle<SkYUVAPixmapInfo>
pub const MAX_PLANES: usize
pub const DATA_TYPE_CNT: usize
pub fn new(
info: &Handle<SkYUVAInfo>,
color_types: &[ColorType],
row_bytes: Option<&[usize]>,
) -> Option<Handle<SkYUVAPixmapInfo>>
pub fn new( info: &Handle<SkYUVAInfo>, color_types: &[ColorType], row_bytes: Option<&[usize]>, ) -> Option<Handle<SkYUVAPixmapInfo>>
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.
pub fn from_data_type(
info: &Handle<SkYUVAInfo>,
data_type: SkYUVAPixmapInfo_DataType,
row_bytes: Option<&[usize]>,
) -> Option<Handle<SkYUVAPixmapInfo>>
pub fn from_data_type( info: &Handle<SkYUVAInfo>, data_type: SkYUVAPixmapInfo_DataType, row_bytes: Option<&[usize]>, ) -> Option<Handle<SkYUVAPixmapInfo>>
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) -> &Handle<SkYUVAInfo>
pub fn yuv_color_space(&self) -> SkYUVColorSpace
pub fn num_planes(&self) -> usize
pub fn num_planes(&self) -> usize
The number of Pixmap planes.
pub fn data_type(&self) -> SkYUVAPixmapInfo_DataType
pub fn data_type(&self) -> SkYUVAPixmapInfo_DataType
The per-YUV[A] channel data type.
pub 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 is out of range.
pub 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.
pub fn plane_info(&self, i: usize) -> Option<&Handle<SkImageInfo>>
pub fn plane_info(&self, i: usize) -> Option<&Handle<SkImageInfo>>
Image info for the ith plane.
Returns None if i is out of range.
pub fn plane_infos(&self) -> impl Iterator<Item = &Handle<SkImageInfo>>
pub fn plane_infos(&self) -> impl Iterator<Item = &Handle<SkImageInfo>>
An iterator of all planes’ image infos.
pub 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.
pub 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.
pub fn is_supported(
&self,
data_types: &Handle<SkYUVAPixmapInfo_SupportedDataTypes>,
) -> bool
pub fn is_supported( &self, data_types: &Handle<SkYUVAPixmapInfo_SupportedDataTypes>, ) -> bool
Is this valid and does it use color types allowed by the passed SupportedDataTypes?
§impl Handle<SkYUVAPixmaps>
impl Handle<SkYUVAPixmaps>
pub const MAX_PLANES: usize = YUVAPixmapInfo::MAX_PLANES
pub fn recommended_rgba_color_type(dt: SkYUVAPixmapInfo_DataType) -> ColorType
pub fn allocate(
info: &Handle<SkYUVAPixmapInfo>,
) -> Option<Handle<SkYUVAPixmaps>>
pub fn allocate( info: &Handle<SkYUVAPixmapInfo>, ) -> Option<Handle<SkYUVAPixmaps>>
Allocate space for pixmaps’ pixels in the YUVAPixmaps.
pub fn from_data(
info: &Handle<SkYUVAPixmapInfo>,
data: impl Into<RCHandle<SkData>>,
) -> Option<Handle<SkYUVAPixmaps>>
pub fn from_data( info: &Handle<SkYUVAPixmapInfo>, data: impl Into<RCHandle<SkData>>, ) -> Option<Handle<SkYUVAPixmaps>>
Use storage in Data as backing store for pixmaps’ pixels. Data is retained by the
YUVAPixmaps.
pub unsafe fn from_external_memory(
info: &Handle<SkYUVAPixmapInfo>,
memory: *mut c_void,
) -> Option<Handle<SkYUVAPixmaps>>
pub unsafe fn from_external_memory( info: &Handle<SkYUVAPixmapInfo>, memory: *mut c_void, ) -> Option<Handle<SkYUVAPixmaps>>
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::compute_total_bytes() allocated starting at memory.
pub unsafe fn from_external_pixmaps(
info: &Handle<SkYUVAInfo>,
pixmaps: &[Pixmap<'_>; 4],
) -> Option<Handle<SkYUVAPixmaps>>
pub unsafe fn from_external_pixmaps( info: &Handle<SkYUVAInfo>, pixmaps: &[Pixmap<'_>; 4], ) -> Option<Handle<SkYUVAPixmaps>>
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) -> &Handle<SkYUVAInfo>
pub fn data_type(&self) -> SkYUVAPixmapInfo_DataType
pub fn pixmaps_info(&self) -> Handle<SkYUVAPixmapInfo>
pub fn num_planes(&self) -> usize
pub fn num_planes(&self) -> usize
Number of pixmap planes.
§impl Handle<SkYUVAPixmapInfo_SupportedDataTypes>
impl Handle<SkYUVAPixmapInfo_SupportedDataTypes>
pub fn all() -> Handle<SkYUVAPixmapInfo_SupportedDataTypes>
pub fn all() -> Handle<SkYUVAPixmapInfo_SupportedDataTypes>
All legal combinations of PlaneConfig and DataType are supported.
pub fn supported(
&self,
pc: SkYUVAInfo_PlaneConfig,
dt: SkYUVAPixmapInfo_DataType,
) -> bool
pub fn supported( &self, pc: SkYUVAInfo_PlaneConfig, dt: SkYUVAPixmapInfo_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.
pub fn enable_data_type(
&mut self,
dt: SkYUVAPixmapInfo_DataType,
num_channels: usize,
)
pub fn enable_data_type( &mut self, dt: SkYUVAPixmapInfo_DataType, num_channels: usize, )
Update to add support for pixmaps with num_channels channels where each channel is
represented as DataType.
§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, ) -> Handle<SkColorMatrix>
pub fn rgb_to_yuv(rgb: SkYUVColorSpace) -> Handle<SkColorMatrix>
pub fn yuv_to_rgb(yuv: SkYUVColorSpace) -> Handle<SkColorMatrix>
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: &Handle<SkColorMatrix>, b: &Handle<SkColorMatrix>, )
pub fn pre_concat(&mut self, mat: &Handle<SkColorMatrix>)
pub fn post_concat(&mut self, mat: &Handle<SkColorMatrix>)
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])
§impl Handle<SkRuntimeEffect_Uniform>
impl Handle<SkRuntimeEffect_Uniform>
pub fn ty(&self) -> SkRuntimeEffect_Uniform_Type
pub fn ty(&self) -> SkRuntimeEffect_Uniform_Type
The SkSL type of the uniform.
pub fn flags(&self) -> Flags
pub fn flags(&self) -> Flags
The flags of the uniform, see uniform::Flags.
pub fn is_array(&self) -> bool
pub fn is_array(&self) -> bool
Returns true if the uniform is declared as an array. Uniform::count() contains the
array length.
pub fn is_color(&self) -> bool
pub fn is_color(&self) -> bool
Returns true if the uniform is declared with layout(color). Colors should be supplied
as unpremultiplied, extended-range (unclamped) sRGB. The uniform will be automatically
transformed to unpremultiplied extended-range working-space colors.
pub fn size_in_bytes(&self) -> usize
pub fn size_in_bytes(&self) -> usize
The size in bytes of the uniform (or the whole array, for array uniforms).
§impl Handle<SkRuntimeEffect_Child>
impl Handle<SkRuntimeEffect_Child>
pub fn ty(&self) -> SkRuntimeEffect_ChildType
pub fn ty(&self) -> SkRuntimeEffect_ChildType
The ChildType of the child.
pub fn index(&self) -> usize
pub fn index(&self) -> usize
The index of the child in RuntimeEffect::children().
§impl Handle<SkRuntimeEffectBuilder>
impl Handle<SkRuntimeEffectBuilder>
pub fn new(effect: RCHandle<SkRuntimeEffect>) -> Handle<SkRuntimeEffectBuilder>
pub fn new(effect: RCHandle<SkRuntimeEffect>) -> Handle<SkRuntimeEffectBuilder>
Creates a builder for effect that manages creating an input data block and provides
named access to the uniform variables in that block. The equivalent of Skia’s
SkRuntimeEffectBuilder.
pub fn make_shader(&self, local_matrix: &Matrix) -> Option<RCHandle<SkShader>>
pub fn make_shader(&self, local_matrix: &Matrix) -> Option<RCHandle<SkShader>>
Creates the Shader from the configured builder.
local_matrixthe local matrix applied to the resulting shader
pub 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]
pub 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]
§impl Handle<SkBitmap>
impl Handle<SkBitmap>
pub fn encode(
&self,
format: SkEncodedImageFormat,
quality: impl Into<Option<u32>>,
) -> Option<Vec<u8>>
pub fn encode( &self, format: SkEncodedImageFormat, quality: impl Into<Option<u32>>, ) -> Option<Vec<u8>>
Encodes the pixels of this bitmap into an image in the given format, and returns the encoded
bytes, or None if the format is not supported or the encoding fails.
qualityAn encoder specific value in the range0..=100.Noneselects the default of100.
§impl Handle<GrBackendSemaphore>
impl Handle<GrBackendSemaphore>
pub fn backend(&self) -> GrBackendApi
§impl Handle<GrBackendFormat>
impl Handle<GrBackendFormat>
pub fn new_gl(format: u32, target: u32) -> Handle<GrBackendFormat>
pub fn new_gl(format: u32, target: u32) -> Handle<GrBackendFormat>
Creates a BackendFormat for a GL format and texture target.
pub fn backend(&self) -> GrBackendApi
pub fn backend(&self) -> GrBackendApi
The crate::gpu::ganesh::BackendApi this format is used with.
pub fn channel_mask(&self) -> u32
pub fn channel_mask(&self) -> u32
Gets the channels present in the format as a bitfield of
crate::ColorChannelFlag values. Luminance channels are reported as
crate::ColorChannelFlag::GRAY.
pub fn as_gl_format(&self) -> GrGLFormat
pub fn as_gl_format(&self) -> GrGLFormat
The GL format of this BackendFormat, or None if this format is not GL.
pub fn as_gl_format_enum(&self) -> u32
pub fn as_gl_format_enum(&self) -> u32
The GL format enum of this BackendFormat, or None if this format is not GL.
pub fn to_texture_2d(&self) -> Handle<GrBackendFormat>
pub fn to_texture_2d(&self) -> Handle<GrBackendFormat>
If possible, copies the BackendFormat and forces the texture type to be Texture2D.
If the BackendFormat was for Vulkan and it originally had a
skgpu::VulkanYcbcrConversionInfo, the conversion is removed and the format is set to be
VK_FORMAT_R8G8B8A8_UNORM.
§impl Handle<GrBackendRenderTarget>
impl Handle<GrBackendRenderTarget>
pub fn dimensions(&self) -> ISize
pub fn dimensions(&self) -> ISize
The dimensions of the render target in pixels.
pub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
The number of samples per pixel.
pub fn stencil_bits(&self) -> usize
pub fn stencil_bits(&self) -> usize
The number of stencil bits.
pub fn backend(&self) -> GrBackendApi
pub fn backend(&self) -> GrBackendApi
The crate::gpu::ganesh::BackendApi this render target is used with.
pub fn is_framebuffer_only(&self) -> bool
pub fn is_framebuffer_only(&self) -> bool
Whether this render target is only usable as a framebuffer.
pub fn gl_framebuffer_info(&self) -> Option<FramebufferInfo>
pub fn gl_framebuffer_info(&self) -> Option<FramebufferInfo>
The GL framebuffer info, or None if this render target is not GL.
pub fn backend_format(&self) -> Handle<GrBackendFormat>
pub fn backend_format(&self) -> Handle<GrBackendFormat>
Get the BackendFormat for this render target (or an invalid format if this is not
valid).
pub fn set_mutable_state(&mut self, state: &RCHandle<skgpu_MutableTextureState>)
pub fn set_mutable_state(&mut self, state: &RCHandle<skgpu_MutableTextureState>)
If the client changes any of the mutable state of the BackendRenderTarget they
should call this function to inform Skia that those values have changed. The backend
API specific state that can be set from this function are:
Vulkan: VkImageLayout and QueueFamilyIndex
pub fn is_protected(&self) -> bool
pub fn is_protected(&self) -> bool
Returns true if we are working with protected content.
§impl Handle<GrGLExtensions>
impl Handle<GrGLExtensions>
pub fn is_initialized(&self) -> bool
pub fn has(&self, extension: impl AsRef<str>) -> bool
pub fn has(&self, extension: impl AsRef<str>) -> bool
Queries whether an extension is present. This will fail if init() has not been called.
pub fn remove(&mut self, extension: impl AsRef<str>) -> bool
pub fn remove(&mut self, extension: impl AsRef<str>) -> bool
Removes an extension if present. Returns true if the extension was present before the call.
pub fn reset(&mut self)
§impl Handle<GrYUVABackendTextureInfo>
impl Handle<GrYUVABackendTextureInfo>
pub const MAX_PLANES: usize = YUVAInfo::MAX_PLANES
pub fn new(
info: &Handle<SkYUVAInfo>,
formats: &[Handle<GrBackendFormat>],
mip_mapped: skgpu_Mipmapped,
origin: GrSurfaceOrigin,
) -> Option<Handle<GrYUVABackendTextureInfo>>
pub fn new( info: &Handle<SkYUVAInfo>, formats: &[Handle<GrBackendFormat>], mip_mapped: skgpu_Mipmapped, origin: GrSurfaceOrigin, ) -> Option<Handle<GrYUVABackendTextureInfo>>
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 yuv_color_space(&self) -> SkYUVColorSpace
pub fn yuv_color_space(&self) -> SkYUVColorSpace
The YUVColorSpace of the planar layout.
pub fn mipmapped(&self) -> skgpu_Mipmapped
pub fn mipmapped(&self) -> skgpu_Mipmapped
Whether the described textures are mipmapped.
pub fn texture_origin(&self) -> GrSurfaceOrigin
pub fn texture_origin(&self) -> GrSurfaceOrigin
The origin that all the described textures share.
pub fn num_planes(&self) -> usize
pub fn num_planes(&self) -> usize
The number of crate::Pixmap planes.
pub fn plane_format(&self, i: usize) -> Option<&Handle<GrBackendFormat>>
pub fn plane_format(&self, i: usize) -> Option<&Handle<GrBackendFormat>>
Format of the ith plane, or None if i >= Self::num_planes()
pub fn plane_formats(&self) -> &[Handle<GrBackendFormat>]
pub fn plane_formats(&self) -> &[Handle<GrBackendFormat>]
All plane formats.
§impl Handle<SkDynamicMemoryWStream>
impl Handle<SkDynamicMemoryWStream>
pub fn new() -> Handle<SkDynamicMemoryWStream>
pub fn from_bytes(bytes: &[u8]) -> Handle<SkDynamicMemoryWStream>
pub fn write(&mut self, bytes: &[u8]) -> bool
pub fn detach_as_data(&mut self) -> RCHandle<SkData>
pub fn detach_as_stream(&mut self) -> Stream<SkStreamAsset>
§impl Handle<skia_textlayout_FontArguments>
impl Handle<skia_textlayout_FontArguments>
pub fn clone_typeface( &self, typeface: impl Into<RCHandle<SkTypeface>>, ) -> Option<RCHandle<SkTypeface>>
§impl Handle<skia_textlayout_StrutStyle>
impl Handle<skia_textlayout_StrutStyle>
pub fn new() -> Handle<skia_textlayout_StrutStyle>
pub fn font_families(&self) -> FontFamilies<'_>
pub fn set_font_families( &mut self, families: &[impl AsRef<str>], ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn font_style(&self) -> FontStyle
pub fn set_font_style( &mut self, font_style: FontStyle, ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn font_size(&self) -> f32
pub fn set_font_size( &mut self, font_size: f32, ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn set_height( &mut self, height: f32, ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn height(&self) -> f32
pub fn set_leading( &mut self, leading: f32, ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn leading(&self) -> f32
pub fn strut_enabled(&self) -> bool
pub fn set_strut_enabled( &mut self, enabled: bool, ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn force_strut_height(&self) -> bool
pub fn set_force_strut_height( &mut self, force_height: bool, ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn height_override(&self) -> bool
pub fn set_height_override( &mut self, height_override: bool, ) -> &mut Handle<skia_textlayout_StrutStyle>
pub fn half_leading(&self) -> bool
pub fn set_half_leading( &mut self, half_leading: bool, ) -> &mut Handle<skia_textlayout_StrutStyle>
§impl Handle<skia_textlayout_TextStyle>
impl Handle<skia_textlayout_TextStyle>
pub fn new() -> Handle<skia_textlayout_TextStyle>
pub fn to_placeholder(&self) -> Handle<skia_textlayout_TextStyle>
Use clone_for_placeholder
pub fn clone_for_placeholder(&self) -> Handle<skia_textlayout_TextStyle>
pub fn equals(&self, other: &Handle<skia_textlayout_TextStyle>) -> bool
pub fn equals_by_fonts(&self, that: &Handle<skia_textlayout_TextStyle>) -> bool
pub fn match_one_attribute( &self, style_type: skia_textlayout_StyleType, other: &Handle<skia_textlayout_TextStyle>, ) -> bool
pub fn color(&self) -> Color
pub fn set_color( &mut self, color: impl Into<Color>, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn has_foreground(&self) -> bool
pub fn foreground(&self) -> Handle<SkPaint>
pub fn set_foreground_paint( &mut self, paint: &Handle<SkPaint>, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn set_foreground_color( &mut self, paint: &Handle<SkPaint>, ) -> &mut Handle<skia_textlayout_TextStyle>
use set_foreground_paint()
pub fn clear_foreground_color( &mut self, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn has_background(&self) -> bool
pub fn background(&self) -> Handle<SkPaint>
pub fn set_background_paint( &mut self, paint: &Handle<SkPaint>, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn set_background_color( &mut self, paint: &Handle<SkPaint>, ) -> &mut Handle<skia_textlayout_TextStyle>
use set_background_paint()
pub fn clear_background_color( &mut self, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn decoration(&self) -> &Decoration
pub fn decoration_type(&self) -> TextDecoration
pub fn decoration_mode(&self) -> skia_textlayout_TextDecorationMode
pub fn decoration_color(&self) -> Color
pub fn decoration_style(&self) -> skia_textlayout_TextDecorationStyle
pub fn decoration_thickness_multiplier(&self) -> f32
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: skia_textlayout_TextDecorationMode)
pub fn set_decoration_style( &mut self, style: skia_textlayout_TextDecorationStyle, )
pub fn set_decoration_color(&mut self, color: impl Into<Color>)
pub fn set_decoration_thickness_multiplier(&mut self, multiplier: f32)
pub fn decoration_mut(&mut self) -> &mut Decoration
use set_decoration()
pub fn font_style(&self) -> FontStyle
pub fn set_font_style( &mut self, font_style: FontStyle, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn shadows(&self) -> &[TextShadow]
pub fn add_shadow( &mut self, shadow: TextShadow, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn reset_shadows(&mut self) -> &mut Handle<skia_textlayout_TextStyle>
pub fn font_features(&self) -> &[Handle<skia_textlayout_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<&Handle<skia_textlayout_FontArguments>>
pub 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, and
the crate::FontArguments can be safely deleted after set_font_arguments returns.
pub fn font_size(&self) -> f32
pub fn set_font_size( &mut self, size: f32, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn font_families(&self) -> FontFamilies<'_>
pub fn set_font_families( &mut self, families: &[impl AsRef<str>], ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn baseline_shift(&self) -> f32
pub fn set_baseline_shift( &mut self, baseline_shift: f32, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn set_height( &mut self, height: f32, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn height(&self) -> f32
pub fn set_height_override( &mut self, height_override: bool, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn height_override(&self) -> bool
pub fn set_half_leading( &mut self, half_leading: bool, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn half_leading(&self) -> bool
pub fn set_letter_spacing( &mut self, letter_spacing: f32, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn letter_spacing(&self) -> f32
pub fn set_word_spacing( &mut self, word_spacing: f32, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn word_spacing(&self) -> f32
pub fn typeface(&self) -> Option<RCHandle<SkTypeface>>
pub fn set_typeface( &mut self, typeface: impl Into<Option<RCHandle<SkTypeface>>>, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn locale(&self) -> &str
pub fn set_locale( &mut self, locale: impl AsRef<str>, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn text_baseline(&self) -> skia_textlayout_TextBaseline
pub fn set_text_baseline( &mut self, baseline: skia_textlayout_TextBaseline, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn font_metrics(&self) -> FontMetrics
pub fn is_placeholder(&self) -> bool
pub fn set_placeholder(&mut self) -> &mut Handle<skia_textlayout_TextStyle>
pub fn set_font_edging( &mut self, edging: SkFont_Edging, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn font_edging(&self) -> SkFont_Edging
pub fn set_subpixel( &mut self, subpixel: bool, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn subpixel(&self) -> bool
pub fn set_font_hinting( &mut self, hinting: SkFontHinting, ) -> &mut Handle<skia_textlayout_TextStyle>
pub fn font_hinting(&self) -> SkFontHinting
§impl Handle<SkSVGColor>
impl Handle<SkSVGColor>
pub fn color(&self) -> Option<Color>
pub fn kind(&self) -> ColorKind
pub fn current_color() -> Handle<SkSVGColor>
pub fn from_color(color: Color) -> Handle<SkSVGColor>
§impl Handle<SkOpBuilder>
impl Handle<SkOpBuilder>
pub fn add(
&mut self,
path: &Handle<SkPath>,
operator: SkPathOp,
) -> &mut Handle<SkOpBuilder>
pub fn add( &mut self, path: &Handle<SkPath>, operator: SkPathOp, ) -> &mut Handle<SkOpBuilder>
Add one or more paths and their operand. The builder is empty before the first path is added, so the result of a single add is (emptyPath OP path).
pathThe second operand.operatorThe operator to apply to the existing and supplied paths.
§impl Handle<SkPath>
impl Handle<SkPath>
pub fn op( &self, path: &Handle<SkPath>, path_op: SkPathOp, ) -> Option<Handle<SkPath>>
pub fn simplify(&self) -> Option<Handle<SkPath>>
pub fn tight_bounds(&self) -> Option<Rect>
Use Path::compute_tight_bounds() and test if the resulting Rect::is_finite()
pub fn as_winding(&self) -> Option<Handle<SkPath>>
§impl Handle<SkCustomTypefaceBuilder>
impl Handle<SkCustomTypefaceBuilder>
pub const FACTORY_ID: FourByteTag
pub fn new() -> Handle<SkCustomTypefaceBuilder>
pub fn set_glyph<'a>( &mut self, glyph_id: u16, advance: f32, typeface_glyph: impl Into<TypefaceGlyph<'a>>, ) -> &mut Handle<SkCustomTypefaceBuilder>
pub fn set_metrics( &mut self, font_metrics: &FontMetrics, scale: impl Into<Option<f32>>, ) -> &mut Handle<SkCustomTypefaceBuilder>
pub fn set_font_style( &mut self, font_style: FontStyle, ) -> &mut Handle<SkCustomTypefaceBuilder>
pub fn detach(&mut self) -> Option<RCHandle<SkTypeface>>
pub fn from_data( data: impl Into<RCHandle<SkData>>, font_arguments: &FontArguments<'_, '_>, ) -> Option<RCHandle<SkTypeface>>
Trait Implementations§
§impl Combine<Handle<SkRegion>, Handle<SkRegion>> for Handle<SkRegion>
impl Combine<Handle<SkRegion>, Handle<SkRegion>> for Handle<SkRegion>
fn combine( a: &Handle<SkRegion>, op: SkRegion_Op, b: &Handle<SkRegion>, ) -> Handle<SkRegion>
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
§impl Combine<Handle<SkRegion>, IRect> for Handle<SkRegion>
impl Combine<Handle<SkRegion>, IRect> for Handle<SkRegion>
fn combine( region: &Handle<SkRegion>, op: SkRegion_Op, rect: &IRect, ) -> Handle<SkRegion>
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
§impl Combine<IRect, Handle<SkRegion>> for Handle<SkRegion>
impl Combine<IRect, Handle<SkRegion>> for Handle<SkRegion>
fn combine( rect: &IRect, op: SkRegion_Op, region: &Handle<SkRegion>, ) -> Handle<SkRegion>
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
§impl Default for Handle<SkPaint>
impl Default for Handle<SkPaint>
§fn default() -> Handle<SkPaint>
fn default() -> Handle<SkPaint>
Constructs a Paint with default values.
Example (C++): https://fiddle.skia.org/c/@Paint_empty_constructor
§impl<'a> From<&'a Handle<SkPath>> for TypefaceGlyph<'a>
impl<'a> From<&'a Handle<SkPath>> for TypefaceGlyph<'a>
§fn from(path: &'a Handle<SkPath>) -> TypefaceGlyph<'a>
fn from(path: &'a Handle<SkPath>) -> TypefaceGlyph<'a>
§impl From<FontArguments<'_, '_>> for Handle<skia_textlayout_FontArguments>
impl From<FontArguments<'_, '_>> for Handle<skia_textlayout_FontArguments>
§fn from(fa: FontArguments<'_, '_>) -> Handle<skia_textlayout_FontArguments>
fn from(fa: FontArguments<'_, '_>) -> Handle<skia_textlayout_FontArguments>
§impl Intersects<Handle<SkRegion>> for Handle<SkRegion>
impl Intersects<Handle<SkRegion>> for Handle<SkRegion>
fn intersects(&self, other: &Handle<SkRegion>) -> bool
§impl Intersects<IRect> for Handle<SkRegion>
impl Intersects<IRect> for Handle<SkRegion>
fn intersects(&self, rect: &IRect) -> bool
§impl Iterator for Handle<SkContourMeasureIter>
impl Iterator for Handle<SkContourMeasureIter>
§fn next(&mut self) -> Option<<Handle<SkContourMeasureIter> as Iterator>::Item>
fn next(&mut self) -> Option<<Handle<SkContourMeasureIter> as Iterator>::Item>
Iterates through contours in the path, returning a ContourMeasure for each contour.
Returns None when iteration is complete.
Only non-zero-length contours are returned, where a contour is the segments between a move verb and either:
- the next move verb,
- one or more close verbs,
- or the end of the path.
Zero-length contours are skipped.
Source§fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
iter_next_chunk)N values. Read more1.0.0 (const: unstable) · Source§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
1.0.0 (const: unstable) · Source§fn count(self) -> usizewhere
Self: Sized,
fn count(self) -> usizewhere
Self: Sized,
1.0.0 (const: unstable) · Source§fn last(self) -> Option<Self::Item>where
Self: Sized,
fn last(self) -> Option<Self::Item>where
Self: Sized,
Source§fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
iter_advance_by)n elements. Read more1.0.0 (const: unstable) · Source§fn nth(&mut self, n: usize) -> Option<Self::Item>
fn nth(&mut self, n: usize) -> Option<Self::Item>
nth element of the iterator. Read more1.28.0 (const: unstable) · Source§fn step_by(self, step: usize) -> StepBy<Self> ⓘwhere
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self> ⓘwhere
Self: Sized,
1.0.0 (const: unstable) · Source§fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> ⓘ
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter> ⓘ
1.0.0 (const: unstable) · Source§fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator,
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter> ⓘwhere
Self: Sized,
U: IntoIterator,
Source§fn intersperse(self, separator: Self::Item) -> Intersperse<Self> ⓘ
fn intersperse(self, separator: Self::Item) -> Intersperse<Self> ⓘ
iter_intersperse)separator between items
of the original iterator. Read moreSource§fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> ⓘ
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G> ⓘ
iter_intersperse)separator
between items of the original iterator. Read more1.0.0 (const: unstable) · Source§fn map<B, F>(self, f: F) -> Map<Self, F> ⓘ
fn map<B, F>(self, f: F) -> Map<Self, F> ⓘ
1.21.0 (const: unstable) · Source§fn for_each<F>(self, f: F)
fn for_each<F>(self, f: F)
1.0.0 (const: unstable) · Source§fn filter<P>(self, predicate: P) -> Filter<Self, P> ⓘ
fn filter<P>(self, predicate: P) -> Filter<Self, P> ⓘ
1.0.0 (const: unstable) · Source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> ⓘ
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> ⓘ
1.0.0 (const: unstable) · Source§fn enumerate(self) -> Enumerate<Self> ⓘwhere
Self: Sized,
fn enumerate(self) -> Enumerate<Self> ⓘwhere
Self: Sized,
1.0.0 (const: unstable) · Source§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> ⓘ
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> ⓘ
1.57.0 (const: unstable) · Source§fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> ⓘ
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P> ⓘ
1.0.0 (const: unstable) · Source§fn skip(self, n: usize) -> Skip<Self> ⓘwhere
Self: Sized,
fn skip(self, n: usize) -> Skip<Self> ⓘwhere
Self: Sized,
n elements. Read more1.0.0 (const: unstable) · Source§fn take(self, n: usize) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, n: usize) -> Take<Self> ⓘwhere
Self: Sized,
n elements, or fewer
if the underlying iterator ends sooner. Read more1.0.0 (const: unstable) · Source§fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> ⓘ
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> ⓘ
1.0.0 (const: unstable) · Source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> ⓘ
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> ⓘ
1.29.0 (const: unstable) · Source§fn flatten(self) -> Flatten<Self> ⓘ
fn flatten(self) -> Flatten<Self> ⓘ
Source§fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N> ⓘ
fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N> ⓘ
iter_map_windows)f for each contiguous window of size N over
self and returns an iterator over the outputs of f. Like slice::windows(),
the windows during mapping overlap as well. Read more1.0.0 (const: unstable) · Source§fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
fn inspect<F>(self, f: F) -> Inspect<Self, F> ⓘ
1.0.0 (const: unstable) · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Iterator. Read more1.0.0 (const: unstable) · Source§fn collect<B>(self) -> B
fn collect<B>(self) -> B
Source§fn try_collect<B>(
&mut self,
) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
fn try_collect<B>( &mut self, ) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
iterator_try_collect)Source§fn collect_into<E>(self, collection: &mut E) -> &mut E
fn collect_into<E>(self, collection: &mut E) -> &mut E
iter_collect_into)1.0.0 (const: unstable) · Source§fn partition<B, F>(self, f: F) -> (B, B)
fn partition<B, F>(self, f: F) -> (B, B)
Source§fn partition_in_place<'a, T, P>(self, predicate: P) -> usize
fn partition_in_place<'a, T, P>(self, predicate: P) -> usize
iter_partition_in_place)true precede all those that return false.
Returns the number of true elements found. Read moreSource§fn is_partitioned<P>(self, predicate: P) -> bool
fn is_partitioned<P>(self, predicate: P) -> bool
iter_is_partitioned)true precede all those that return false. Read more1.27.0 (const: unstable) · Source§fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
1.27.0 (const: unstable) · Source§fn try_for_each<F, R>(&mut self, f: F) -> R
fn try_for_each<F, R>(&mut self, f: F) -> R
1.0.0 (const: unstable) · Source§fn fold<B, F>(self, init: B, f: F) -> B
fn fold<B, F>(self, init: B, f: F) -> B
1.51.0 (const: unstable) · Source§fn reduce<F>(self, f: F) -> Option<Self::Item>
fn reduce<F>(self, f: F) -> Option<Self::Item>
Source§fn try_reduce<R>(
&mut self,
f: impl FnMut(Self::Item, Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
fn try_reduce<R>( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
iterator_try_reduce)1.0.0 (const: unstable) · Source§fn all<F>(&mut self, f: F) -> bool
fn all<F>(&mut self, f: F) -> bool
1.0.0 (const: unstable) · Source§fn any<F>(&mut self, f: F) -> bool
fn any<F>(&mut self, f: F) -> bool
1.0.0 (const: unstable) · Source§fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
1.30.0 (const: unstable) · Source§fn find_map<B, F>(&mut self, f: F) -> Option<B>
fn find_map<B, F>(&mut self, f: F) -> Option<B>
Source§fn try_find<R>(
&mut self,
f: impl FnMut(&Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
fn try_find<R>( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
try_find)1.0.0 (const: unstable) · Source§fn position<P>(&mut self, predicate: P) -> Option<usize>
fn position<P>(&mut self, predicate: P) -> Option<usize>
1.0.0 (const: unstable) · Source§fn rposition<P>(&mut self, predicate: P) -> Option<usize>
fn rposition<P>(&mut self, predicate: P) -> Option<usize>
1.0.0 (const: unstable) · Source§fn max(self) -> Option<Self::Item>
fn max(self) -> Option<Self::Item>
1.0.0 (const: unstable) · Source§fn min(self) -> Option<Self::Item>
fn min(self) -> Option<Self::Item>
1.6.0 (const: unstable) · Source§fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 (const: unstable) · Source§fn max_by<F>(self, compare: F) -> Option<Self::Item>
fn max_by<F>(self, compare: F) -> Option<Self::Item>
1.6.0 (const: unstable) · Source§fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 (const: unstable) · Source§fn min_by<F>(self, compare: F) -> Option<Self::Item>
fn min_by<F>(self, compare: F) -> Option<Self::Item>
1.0.0 (const: unstable) · Source§fn rev(self) -> Rev<Self> ⓘwhere
Self: Sized + DoubleEndedIterator,
fn rev(self) -> Rev<Self> ⓘwhere
Self: Sized + DoubleEndedIterator,
1.0.0 (const: unstable) · Source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
1.36.0 (const: unstable) · Source§fn copied<'a, T>(self) -> Copied<Self> ⓘ
fn copied<'a, T>(self) -> Copied<Self> ⓘ
1.0.0 (const: unstable) · Source§fn cycle(self) -> Cycle<Self> ⓘ
fn cycle(self) -> Cycle<Self> ⓘ
Source§fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> ⓘwhere
Self: Sized,
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N> ⓘwhere
Self: Sized,
iter_array_chunks)N elements of the iterator at a time. Read more1.11.0 (const: unstable) · Source§fn product<P>(self) -> P
fn product<P>(self) -> P
Source§fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
iter_order_by)Iterator with those
of another with respect to the specified comparison function. Read more1.5.0 (const: unstable) · Source§fn partial_cmp<I>(self, other: I) -> Option<Ordering>
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
PartialOrd elements of
this Iterator with those of another. The comparison works like short-circuit
evaluation, returning a result without comparing the remaining elements.
As soon as an order can be determined, the evaluation stops and a result is returned. Read moreSource§fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
iter_order_by)Iterator with those
of another with respect to the specified comparison function. Read moreSource§fn eq_by<I, F>(self, other: I, eq: F) -> bool
fn eq_by<I, F>(self, other: I, eq: F) -> bool
iter_order_by)1.5.0 (const: unstable) · Source§fn lt<I>(self, other: I) -> bool
fn lt<I>(self, other: I) -> bool
Iterator are lexicographically
less than those of another. Read more1.5.0 (const: unstable) · Source§fn le<I>(self, other: I) -> bool
fn le<I>(self, other: I) -> bool
Iterator are lexicographically
less or equal to those of another. Read more1.5.0 (const: unstable) · Source§fn gt<I>(self, other: I) -> bool
fn gt<I>(self, other: I) -> bool
Iterator are lexicographically
greater than those of another. Read more1.5.0 (const: unstable) · Source§fn ge<I>(self, other: I) -> bool
fn ge<I>(self, other: I) -> bool
Iterator are lexicographically
greater than or equal to those of another. Read more1.82.0 (const: unstable) · Source§fn is_sorted(self) -> bool
fn is_sorted(self) -> bool
1.82.0 (const: unstable) · Source§fn is_sorted_by<F>(self, compare: F) -> bool
fn is_sorted_by<F>(self, compare: F) -> bool
§impl QuickReject<Handle<SkPath>> for Canvas
impl QuickReject<Handle<SkPath>> for Canvas
§fn quick_reject(&self, path: &Handle<SkPath>) -> bool
fn quick_reject(&self, path: &Handle<SkPath>) -> 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
Example (C++): https://fiddle.skia.org/c/@Canvas_quickReject_2
§impl QuickReject<Handle<SkRegion>> for Handle<SkRegion>
impl QuickReject<Handle<SkRegion>> for Handle<SkRegion>
fn quick_reject(&self, other: &Handle<SkRegion>) -> bool
§impl QuickReject<IRect> for Handle<SkRegion>
impl QuickReject<IRect> for Handle<SkRegion>
fn quick_reject(&self, rect: &IRect) -> bool
§impl<N> RefWrapper<N> for Handle<N>where
N: NativeDrop,
impl<N> RefWrapper<N> for Handle<N>where
N: NativeDrop,
impl Send for Handle<SkCodecs_Decoder>
impl Send for Handle<SkContextOptions>
impl Send for Handle<SkContourMeasureIter>
impl Send for Handle<SkFont>
impl Send for Handle<SkColorInfo>
impl Send for Handle<SkImageInfo>
impl Send for Handle<SkMeshSpecification_Attribute>
impl Send for Handle<SkMeshSpecification_Varying>
impl Send for Handle<SkPaint>
impl Send for Handle<SkPath>
impl Send for Handle<SkRegion>
impl Send for Handle<SkStrikeRef>
impl Send for Handle<SkStrokeRec>
impl Send for Handle<SkTextBlobBuilder>
impl Send for Handle<SkVertices_Builder>
impl Send for Handle<SkYUVAInfo>
impl Send for Handle<SkYUVAPixmapInfo>
impl Send for Handle<SkYUVAPixmaps>
impl Send for Handle<SkYUVAPixmapInfo_SupportedDataTypes>
impl Send for Handle<SkColorMatrix>
impl Send for Handle<SkRuntimeEffect_Uniform>
impl Send for Handle<SkRuntimeEffect_Child>
impl Send for Handle<SkRuntimeEffectBuilder>
impl Send for Handle<GrBackendSemaphore>
impl Send for Handle<GrBackendFormat>
impl Send for Handle<GrBackendRenderTarget>
impl Send for Handle<GrGLExtensions>
impl Send for Handle<GrYUVABackendTextureInfo>
impl Send for Handle<SkString>
impl Send for Handle<SkStrings>
impl Send for Handle<skia_textlayout_FontArguments>
impl Send for Handle<skia_textlayout_StrutStyle>
impl Send for Handle<skia_textlayout_FontFeature>
impl Send for Handle<skia_textlayout_TextStyle>
impl Send for Handle<SkOpBuilder>
impl Send for Handle<SkCustomTypefaceBuilder>
impl Sync for Handle<SkCodecs_Decoder>
impl Sync for Handle<SkContextOptions>
impl Sync for Handle<SkContourMeasureIter>
impl Sync for Handle<SkFont>
impl Sync for Handle<SkColorInfo>
impl Sync for Handle<SkImageInfo>
impl Sync for Handle<SkMeshSpecification_Attribute>
impl Sync for Handle<SkMeshSpecification_Varying>
impl Sync for Handle<SkPaint>
impl Sync for Handle<SkRegion>
impl Sync for Handle<SkStrikeRef>
impl Sync for Handle<SkStrokeRec>
impl Sync for Handle<SkTextBlobBuilder>
impl Sync for Handle<SkVertices_Builder>
impl Sync for Handle<SkYUVAInfo>
impl Sync for Handle<SkYUVAPixmapInfo>
impl Sync for Handle<SkYUVAPixmaps>
impl Sync for Handle<SkYUVAPixmapInfo_SupportedDataTypes>
impl Sync for Handle<SkColorMatrix>
impl Sync for Handle<SkRuntimeEffect_Uniform>
impl Sync for Handle<SkRuntimeEffect_Child>
impl Sync for Handle<SkRuntimeEffectBuilder>
impl Sync for Handle<GrBackendSemaphore>
impl Sync for Handle<GrBackendFormat>
impl Sync for Handle<GrBackendRenderTarget>
impl Sync for Handle<GrGLExtensions>
impl Sync for Handle<GrYUVABackendTextureInfo>
impl Sync for Handle<SkString>
impl Sync for Handle<SkStrings>
impl Sync for Handle<skia_textlayout_FontArguments>
impl Sync for Handle<skia_textlayout_StrutStyle>
impl Sync for Handle<skia_textlayout_FontFeature>
impl Sync for Handle<skia_textlayout_TextStyle>
impl Sync for Handle<SkOpBuilder>
impl Sync for Handle<SkCustomTypefaceBuilder>
Auto Trait Implementations§
impl<N> !Freeze for Handle<N>
impl<N> !RefUnwindSafe for Handle<N>
impl<N> !Send for Handle<N>
impl<N> !Sync for Handle<N>
impl<N> Unpin for Handle<N>where
N: Unpin,
impl<N> UnsafeUnpin for Handle<N>where
N: UnsafeUnpin,
impl<N> UnwindSafe for Handle<N>where
N: UnwindSafe,
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<I> IntoIterator for Iwhere
I: Iterator,
impl<I> IntoIterator for Iwhere
I: Iterator,
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
Source§impl<T> ToStringLocalized for Twhere
T: ToString,
impl<T> ToStringLocalized for Twhere
T: ToString,
Source§fn to_string_local(&self, _cx: &impl DataContext) -> String
fn to_string_local(&self, _cx: &impl DataContext) -> String
String via a translation using fluent.