pub struct RCHandle<Native: NativeRefCounted>(/* private fields */);
Expand description
A wrapper type represented by a reference counted pointer to the native type.
Implementations§
Source§impl RCHandle<SkColorFilter>
impl RCHandle<SkColorFilter>
ColorFilters are optional objects in the drawing pipeline. When present in a paint, they are called with the “src” colors, and return new colors, which are then passed onto the next stage (either ImageFilter or Xfermode).
All subclasses are required to be reentrant-safe : it must be legal to share the same instance between several threads.
Sourcepub fn to_a_color_mode(&self) -> Option<(Color, BlendMode)>
pub fn to_a_color_mode(&self) -> Option<(Color, BlendMode)>
If the filter can be represented by a source color plus Mode, this
returns the color and mode appropriately.
If not, this returns None
and ignores the parameters.
Sourcepub fn to_a_color_matrix(&self) -> Option<[scalar; 20]>
pub fn to_a_color_matrix(&self) -> Option<[scalar; 20]>
If the filter can be represented by a 5x4 matrix, this
returns the matrix appropriately.
If not, this returns None
and ignores the parameter.
Sourcepub fn is_alpha_unchanged(&self) -> bool
pub fn is_alpha_unchanged(&self) -> bool
Returns true
if the filter is guaranteed to never change the alpha of a color it filters.
pub fn filter_color(&self, color: impl Into<Color>) -> Color
Sourcepub fn filter_color4f(
&self,
color: impl Into<Color4f>,
src_color_space: Option<&ColorSpace>,
dst_color_space: Option<&ColorSpace>,
) -> Color4f
pub fn filter_color4f( &self, color: impl Into<Color4f>, src_color_space: Option<&ColorSpace>, dst_color_space: Option<&ColorSpace>, ) -> Color4f
Converts the src color (in src colorspace), into the dst colorspace, then applies this filter to it, returning the filtered color in the dst colorspace.
Sourcepub fn composed(&self, inner: impl Into<ColorFilter>) -> Option<Self>
pub fn composed(&self, inner: impl Into<ColorFilter>) -> Option<Self>
Construct a color filter whose effect is to first apply the inner filter and then apply this filter, applied to the output of the inner filter.
result = this(inner(…))
Sourcepub fn with_working_color_space(
&self,
color_space: impl Into<ColorSpace>,
) -> Option<Self>
pub fn with_working_color_space( &self, color_space: impl Into<ColorSpace>, ) -> Option<Self>
Return a color filter that will compute this filter in a specific color space. By default all filters operate in the destination (surface) color space. This allows filters like Blend and Matrix, or runtime color filters to perform their math in a known space.
Source§impl RCHandle<SkColorSpace>
impl RCHandle<SkColorSpace>
pub fn new_srgb() -> Self
pub fn new_srgb_linear() -> Self
pub fn to_xyzd50_hash(&self) -> XYZD50Hash
pub fn with_linear_gamma(&self) -> Self
pub fn with_srgb_gamma(&self) -> Self
pub fn with_color_spin(&self) -> Self
pub fn is_srgb(&self) -> bool
pub fn serialize(&self) -> Data
pub fn deserialize(data: impl Into<Data>) -> Self
Source§impl RCHandle<SkColorTable>
impl RCHandle<SkColorTable>
Sourcepub fn new(table: &[u8; 256]) -> Self
pub fn new(table: &[u8; 256]) -> Self
Creates a new ColorTable
with ‘table’ used for all four channels. The table is copied
into the ColorTable
.
pub fn new_per_channel<'a>( table_a: impl Into<Option<&'a [u8; 256]>>, table_r: impl Into<Option<&'a [u8; 256]>>, table_g: impl Into<Option<&'a [u8; 256]>>, table_b: impl Into<Option<&'a [u8; 256]>>, ) -> Option<Self>
pub fn alpha_table(&self) -> &[u8; 256]
pub fn red_table(&self) -> &[u8; 256]
pub fn green_table(&self) -> &[u8; 256]
pub fn blue_table(&self) -> &[u8; 256]
Source§impl RCHandle<SkContourMeasure>
impl RCHandle<SkContourMeasure>
pub fn length(&self) -> scalar
pub fn pos_tan(&self, distance: scalar) -> Option<(Point, Vector)>
pub fn get_matrix( &self, distance: scalar, flags: impl Into<Option<MatrixFlags>>, ) -> Option<Matrix>
pub fn segment( &self, start_d: scalar, stop_d: scalar, start_with_move_to: bool, ) -> Option<Path>
pub fn is_closed(&self) -> bool
pub fn verbs(&self) -> ForwardVerbIterator<'_> ⓘ
Source§impl RCHandle<SkData>
impl RCHandle<SkData>
pub fn size(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn copy_range(&self, offset: usize, buffer: &mut [u8]) -> &Self
pub fn new_copy(data: &[u8]) -> Self
Sourcepub unsafe fn new_bytes(data: &[u8]) -> Self
pub unsafe fn new_bytes(data: &[u8]) -> Self
Constructs Data from a given byte slice without copying it.
Users must make sure that the underlying slice will outlive the lifetime of the Data.
pub unsafe fn new_uninitialized(length: usize) -> Data
pub fn new_zero_initialized(length: usize) -> Data
pub fn new_subset(data: &Data, offset: usize, length: usize) -> Data
Sourcepub fn new_str(str: impl AsRef<str>) -> Data
pub fn new_str(str: impl AsRef<str>) -> Data
Constructs Data from a copy of a &str.
Functions that use Data
as a string container usually expect it to contain a c-string
including the terminating 0 byte, so this function converts the Rust str
to a CString
and calls Self::new_cstr()
.
Sourcepub fn from_filename(path: impl AsRef<Path>) -> Option<Self>
pub fn from_filename(path: impl AsRef<Path>) -> Option<Self>
Create a new Data
referencing the file with the specified path. If the file cannot be
opened, the path contains 0 bytes, or the path is not valid UTF-8, this returns None
.
This function opens the file as a memory mapped file for the lifetime of Data
returned.
Sourcepub fn from_stream(stream: impl Read, size: usize) -> Option<Self>
pub fn from_stream(stream: impl Read, size: usize) -> Option<Self>
Attempt to read size bytes into a Data
. If the read succeeds, return the data,
else return None
. Either way the stream’s cursor may have been changed as a result
of calling read().
pub fn new_empty() -> Self
Source§impl RCHandle<SkDataTable>
impl RCHandle<SkDataTable>
pub fn is_empty(&self) -> bool
pub fn count(&self) -> usize
pub fn at_size(&self, index: usize) -> usize
pub fn at(&self, index: usize) -> &[u8] ⓘ
pub unsafe fn at_t<T: Copy>(&self, index: usize) -> &[T]
pub fn at_str(&self, index: usize) -> &CStr
pub fn new_empty() -> Self
pub fn from_slices(slices: &[&[u8]]) -> Self
pub fn from_slice<T: Copy>(slice: &[T]) -> Self
pub fn iter(&self) -> Iter<'_> ⓘ
Source§impl RCHandle<SkDrawable>
impl RCHandle<SkDrawable>
pub fn draw(&mut self, canvas: &Canvas, matrix: Option<&Matrix>)
pub fn draw_at(&mut self, canvas: &Canvas, point: impl Into<Point>)
pub fn snap_gpu_draw_handler( &mut self, api: BackendAPI, matrix: &Matrix, clip_bounds: impl Into<IRect>, buffer_info: &ImageInfo, ) -> Option<GPUDrawHandler>
pub fn make_picture_snapshot(&mut self) -> Picture
pub fn generation_id(&mut self) -> u32
pub fn bounds(&mut self) -> Rect
pub fn approximate_bytes_used(&mut self) -> usize
pub fn notify_drawing_changed(&mut self)
Source§impl RCHandle<SkFontMgr>
impl RCHandle<SkFontMgr>
pub fn new() -> Self
pub fn empty() -> Self
pub fn count_families(&self) -> usize
pub fn family_name(&self, index: usize) -> String
pub fn family_names(&self) -> impl Iterator<Item = String> + use<'_>
pub fn new_styleset(&self, index: usize) -> FontStyleSet
pub fn new_style_set(&self, index: usize) -> FontStyleSet
pub fn match_family(&self, family_name: impl AsRef<str>) -> FontStyleSet
pub fn match_family_style( &self, family_name: impl AsRef<str>, style: FontStyle, ) -> Option<Typeface>
pub fn match_family_style_character( &self, family_name: impl AsRef<str>, style: FontStyle, bcp_47: &[&str], character: Unichar, ) -> Option<Typeface>
pub fn match_face_style( &self, _typeface: impl AsRef<Typeface>, _style: FontStyle, ) -> !
pub fn new_from_data( &self, bytes: &[u8], ttc_index: impl Into<Option<usize>>, ) -> Option<Typeface>
pub fn legacy_make_typeface<'a>( &self, family_name: impl Into<Option<&'a str>>, style: FontStyle, ) -> Option<Typeface>
Source§impl RCHandle<SkImage>
impl RCHandle<SkImage>
Sourcepub fn from_raster_data(
info: &ImageInfo,
pixels: impl Into<Data>,
row_bytes: usize,
) -> Option<Image>
👎Deprecated since 0.63.0: use images::raster_from_data()
pub fn from_raster_data( info: &ImageInfo, pixels: impl Into<Data>, row_bytes: usize, ) -> Option<Image>
Creates Image
from ImageInfo
, sharing pixels.
Image
is returned if ImageInfo
is valid. Valid ImageInfo
parameters include:
dimensions are greater than zero;
each dimension fits in 29 bits;
ColorType
and AlphaType
are valid, and ColorType
is not ColorType::Unknown
;
rowBytes are large enough to hold one row of pixels;
pixels is not nullptr, and contains enough data for Image
.
info
contains width, height,AlphaType
,ColorType
,ColorSpace
pixels
address or pixel storagerowBytes
size of pixel row or larger
Returns: Image
sharing pixels, or None
Sourcepub fn from_bitmap(bitmap: &Bitmap) -> Option<Image>
👎Deprecated since 0.63.0: use images::raster_from_bitmap()
pub fn from_bitmap(bitmap: &Bitmap) -> Option<Image>
Creates Image
from bitmap, sharing or copying bitmap pixels. If the bitmap
is marked immutable, and its pixel memory is shareable, it may be shared
instead of copied.
Image
is returned if bitmap is valid. Valid Bitmap
parameters include:
dimensions are greater than zero;
each dimension fits in 29 bits;
ColorType
and AlphaType
are valid, and ColorType
is not ColorType::Unknown
;
row bytes are large enough to hold one row of pixels;
pixel address is not null
.
bitmap
ImageInfo
, row bytes, and pixels
Returns: created Image
, or None
Sourcepub fn from_generator(image_generator: ImageGenerator) -> Option<Image>
👎Deprecated since 0.63.0: use images::deferred_from_generator()
pub fn from_generator(image_generator: ImageGenerator) -> Option<Image>
Creates Image
from data returned by image_generator
. Generated data is owned by Image
and
may not be shared or accessed.
Image
is returned if generator data is valid. Valid data parameters vary by type of data
and platform.
imageGenerator may wrap Picture
data, codec data, or custom data.
image_generator
stock or custom routines to retrieveImage
Returns: created Image
, or None
Sourcepub fn from_encoded_with_alpha_type(
data: impl Into<Data>,
alpha_type: impl Into<Option<AlphaType>>,
) -> Option<Image>
pub fn from_encoded_with_alpha_type( data: impl Into<Data>, alpha_type: impl Into<Option<AlphaType>>, ) -> Option<Image>
Return an image backed by the encoded data, but attempt to defer decoding until the image is actually used/drawn. This deferral allows the system to cache the result, either on the CPU or on the GPU, depending on where the image is drawn. If memory is low, the cache may be purged, causing the next draw of the image to have to re-decode.
If alphaType is None
, the image’s alpha type will be chosen automatically based on the
image format. Transparent images will default to AlphaType::Premul
. If alphaType contains
AlphaType::Premul
or AlphaType::Unpremul
, that alpha type will be used. Forcing opaque
(passing AlphaType::Opaque
) is not allowed, and will return nullptr.
This is similar to decode_to_{raster,texture}
, but this method will attempt to defer the
actual decode, while the decode_to
… method explicitly decode and allocate the backend
when the call is made.
If the encoded format is not supported, None
is returned.
encoded
the encoded data
Returns: created Image
, or None
pub fn decode_to_raster(_encoded: &[u8], _subset: impl Into<Option<IRect>>) -> !
Sourcepub fn new_raster_from_compressed(
data: impl Into<Data>,
dimensions: impl Into<ISize>,
ty: TextureCompressionType,
) -> Option<Image>
👎Deprecated since 0.63.0: use images::raster_from_compressed_texture_data()
pub fn new_raster_from_compressed( data: impl Into<Data>, dimensions: impl Into<ISize>, ty: TextureCompressionType, ) -> Option<Image>
Creates a CPU-backed Image
from compressed data.
This method will decompress the compressed data and create an image wrapping it. Any mipmap levels present in the compressed data are discarded.
data
compressed data to store inImage
width
width of fullImage
height
height of fullImage
ty
type of compression used
Returns: created Image
, or None
Sourcepub fn from_picture(
picture: impl Into<Picture>,
dimensions: impl Into<ISize>,
matrix: Option<&Matrix>,
paint: Option<&Paint>,
bit_depth: BitDepth,
color_space: impl Into<Option<ColorSpace>>,
) -> Option<Image>
👎Deprecated since 0.63.0: use images::deferred_from_picture()
pub fn from_picture( picture: impl Into<Picture>, dimensions: impl Into<ISize>, matrix: Option<&Matrix>, paint: Option<&Paint>, bit_depth: BitDepth, color_space: impl Into<Option<ColorSpace>>, ) -> Option<Image>
Sourcepub fn from_picture_with_props(
picture: impl Into<Picture>,
dimensions: impl Into<ISize>,
matrix: Option<&Matrix>,
paint: Option<&Paint>,
bit_depth: BitDepth,
color_space: impl Into<Option<ColorSpace>>,
props: SurfaceProps,
) -> Option<Image>
👎Deprecated since 0.63.0: use images::deferred_from_picture()
pub fn from_picture_with_props( picture: impl Into<Picture>, dimensions: impl Into<ISize>, matrix: Option<&Matrix>, paint: Option<&Paint>, bit_depth: BitDepth, color_space: impl Into<Option<ColorSpace>>, props: SurfaceProps, ) -> Option<Image>
Creates Image
from picture. Returned Image
width and height are set by dimensions.
Image
draws picture with matrix and paint, set to bitDepth and colorSpace.
If matrix is None
, draws with identity Matrix
. If paint is None
, draws
with default Paint
. color_space may be None
.
picture
stream of drawing commandsdimensions
width and heightmatrix
Matrix
to rotate, scale, translate, and so on; may beNone
paint
Paint
to apply transparency, filtering, and so on; may beNone
bitDepth
8-bit integer or 16-bit float: per componentcolor_space
range of colors; may beNone
props
props to use when rasterizing the picture
Returns: created Image
, or None
Sourcepub fn new_texture_from_compressed(
context: &mut DirectContext,
data: Data,
dimensions: impl Into<ISize>,
ty: TextureCompressionType,
mipmapped: impl Into<Option<Mipmapped>>,
is_protected: impl Into<Option<Protected>>,
) -> Option<Image>
👎Deprecated since 0.63.0: use gpu::images::texture_from_compressed_texture_data()
pub fn new_texture_from_compressed( context: &mut DirectContext, data: Data, dimensions: impl Into<ISize>, ty: TextureCompressionType, mipmapped: impl Into<Option<Mipmapped>>, is_protected: impl Into<Option<Protected>>, ) -> Option<Image>
Creates a GPU-backed Image
from compressed data.
This method will return an Image
representing the compressed data.
If the GPU doesn’t support the specified compression method, the data
will be decompressed and then wrapped in a GPU-backed image.
Note: one can query the supported compression formats via
gpu::RecordingContext::compressed_backend_format
.
context
GPU contextdata
compressed data to store inImage
width
width of fullImage
height
height of fullImage
ty
type of compression usedmipmapped
does ‘data’ contain data for all the mipmap levels?is_protected
do the contents of ‘data’ require DRM protection (on Vulkan)?
Returns: created Image
, or None
pub fn from_compressed( _context: &mut RecordingContext, _data: Data, _dimensions: impl Into<ISize>, _ct: TextureCompressionType, ) -> !
Sourcepub fn from_texture(
context: &mut RecordingContext,
backend_texture: &BackendTexture,
origin: SurfaceOrigin,
color_type: ColorType,
alpha_type: AlphaType,
color_space: impl Into<Option<ColorSpace>>,
) -> Option<Image>
pub fn from_texture( context: &mut RecordingContext, backend_texture: &BackendTexture, origin: SurfaceOrigin, color_type: ColorType, alpha_type: AlphaType, color_space: impl Into<Option<ColorSpace>>, ) -> Option<Image>
Creates Image
from GPU texture associated with context. GPU texture must stay
valid and unchanged until texture_release_proc
is called. texture_release_proc
is
passed release_context
when Image
is deleted or no longer refers to texture.
Image
is returned if format of backend_texture
is recognized and supported.
Recognized formats vary by GPU back-end.
Note: When using a DDL recording context, texture_release_proc
will be called on the
GPU thread after the DDL is played back on the direct context.
context
GPU contextbackend_texture
Texture residing on GPUorigin
Origin ofbackend_texture
color_type
Color type of the resulting imagealpha_type
Alpha type of the resulting imagecolor_space
This describes the color space of this image’s contents, as seen after sampling. In general, if the format of the backend texture is SRGB, some linearcolor_space
should be supplied (e.g.,ColorSpace::new_srgb_linear()
)). If the format of the backend texture is linear, then thecolor_space
should include a description of the transfer function as well (e.g.,ColorSpace::MakeSRGB
).texture_release_proc
Function called when texture can be releasedrelease_context
State passed totexture_release_proc
Returns: Created Image
, or None
pub fn from_pixmap_cross_context( context: &mut DirectContext, pixmap: &Pixmap<'_>, build_mips: bool, limit_to_max_texture_size: impl Into<Option<bool>>, ) -> Option<Image>
Sourcepub fn new_cross_context_from_pixmap(
context: &mut DirectContext,
pixmap: &Pixmap<'_>,
build_mips: bool,
limit_to_max_texture_size: impl Into<Option<bool>>,
) -> Option<Image>
👎Deprecated since 0.63.0: use gpu::images::cross_context_texture_from_pixmap()
pub fn new_cross_context_from_pixmap( context: &mut DirectContext, pixmap: &Pixmap<'_>, build_mips: bool, limit_to_max_texture_size: impl Into<Option<bool>>, ) -> Option<Image>
Creates Image
from pixmap. Image
is uploaded to GPU back-end using context.
Created Image
is available to other GPU contexts, and is available across thread
boundaries. All contexts must be in the same GPU share group, or otherwise
share resources.
When Image
is no longer referenced, context releases texture memory
asynchronously.
ColorSpace
of Image
is determined by pixmap.color_space()
.
Image
is returned referring to GPU back-end if context is not None
,
format of data is recognized and supported, and if context supports moving
resources between contexts. Otherwise, pixmap pixel data is copied and Image
as returned in raster format if possible; None
may be returned.
Recognized GPU formats vary by platform and GPU back-end.
context
GPU contextpixmap
ImageInfo
, pixel address, and row bytesbuild_mips
createImage
as mip map iftrue
limit_to_max_texture_size
downscale image to GPU maximum texture size, if necessary
Returns: created Image
, or None
Sourcepub fn from_adopted_texture(
context: &mut RecordingContext,
backend_texture: &BackendTexture,
texture_origin: SurfaceOrigin,
color_type: ColorType,
alpha_type: impl Into<Option<AlphaType>>,
color_space: impl Into<Option<ColorSpace>>,
) -> Option<Image>
👎Deprecated since 0.63.0: use gpu::images::adopt_texture_from()
pub fn from_adopted_texture( context: &mut RecordingContext, backend_texture: &BackendTexture, texture_origin: SurfaceOrigin, color_type: ColorType, alpha_type: impl Into<Option<AlphaType>>, color_space: impl Into<Option<ColorSpace>>, ) -> Option<Image>
Creates Image
from backend_texture
associated with context. backend_texture
and
returned Image
are managed internally, and are released when no longer needed.
Image
is returned if format of backend_texture
is recognized and supported.
Recognized formats vary by GPU back-end.
context
GPU contextbackend_texture
texture residing on GPUtexture_origin
origin ofbackend_texture
color_type
color type of the resulting imagealpha_type
alpha type of the resulting imagecolor_space
range of colors; may beNone
Returns: created Image
, or None
Sourcepub fn from_yuva_textures(
context: &mut RecordingContext,
yuva_textures: &YUVABackendTextures,
image_color_space: impl Into<Option<ColorSpace>>,
) -> Option<Image>
👎Deprecated since 0.63.0: use gpu::images::texture_from_yuva_textures()
pub fn from_yuva_textures( context: &mut RecordingContext, yuva_textures: &YUVABackendTextures, image_color_space: impl Into<Option<ColorSpace>>, ) -> Option<Image>
Creates an Image
from YUV[A]
planar textures. This requires that the textures stay valid
for the lifetime of the image. The ReleaseContext
can be used to know when it is safe to
either delete or overwrite the textures. If ReleaseProc
is provided it is also called before
return on failure.
context
GPU contextyuva_textures
A set of textures containing YUVA data and a description of the data and transformation to RGBA.image_color_space
range of colors of the resulting image after conversion to RGB; may beNone
texture_release_proc
called when the backend textures can be releasedrelease_context
state passed totexture_release_proc
Returns: created Image
, or None
Sourcepub fn from_yuva_pixmaps(
context: &mut RecordingContext,
yuva_pixmaps: &YUVAPixmaps,
build_mips: impl Into<Option<Mipmapped>>,
limit_to_max_texture_size: impl Into<Option<bool>>,
image_color_space: impl Into<Option<ColorSpace>>,
) -> Option<Image>
👎Deprecated since 0.63.0: use gpu::images::texture_from_yuva_pixmaps()
pub fn from_yuva_pixmaps( context: &mut RecordingContext, yuva_pixmaps: &YUVAPixmaps, build_mips: impl Into<Option<Mipmapped>>, limit_to_max_texture_size: impl Into<Option<bool>>, image_color_space: impl Into<Option<ColorSpace>>, ) -> Option<Image>
Creates Image
from crate::YUVAPixmaps
.
The image will remain planar with each plane converted to a texture using the passed
gpu::RecordingContext
.
crate::YUVAPixmaps
has a crate::YUVAInfo
which specifies the transformation from YUV to RGB.
The ColorSpace
of the resulting RGB values is specified by image_color_space
. This will
be the ColorSpace
reported by the image and when drawn the RGB values will be converted
from this space into the destination space (if the destination is tagged).
Currently, this is only supported using the GPU backend and will fail if context is None
.
crate::YUVAPixmaps
does not need to remain valid after this returns.
context
GPU contextpixmaps
The planes as pixmaps with supportedcrate::YUVAInfo
that specifies conversion to RGB.build_mips
create internal YUVA textures as mip map ifYes
. This is silently ignored if the context does not support mip maps.limit_to_max_texture_size
downscale image to GPU maximum texture size, if necessaryimage_color_space
range of colors of the resulting image; may beNone
Returns: created Image
, or None
pub fn from_nv12_textures_copy( _context: &mut DirectContext, _yuv_color_space: YUVColorSpace, _nv12_textures: &[BackendTexture; 2], _image_origin: SurfaceOrigin, _image_color_space: impl Into<Option<ColorSpace>>, ) -> !
Sourcepub fn image_info(&self) -> &ImageInfo
pub fn image_info(&self) -> &ImageInfo
Sourcepub fn dimensions(&self) -> ISize
pub fn dimensions(&self) -> ISize
Returns ISize
{ width(), height() }
.
Returns: integral size of width()
and height()
Sourcepub fn bounds(&self) -> IRect
pub fn bounds(&self) -> IRect
Returns IRect
{ 0, 0, width(), height() }
.
Returns: integral rectangle from origin to width()
and height()
Sourcepub fn alpha_type(&self) -> AlphaType
pub fn alpha_type(&self) -> AlphaType
Sourcepub fn color_type(&self) -> ColorType
pub fn color_type(&self) -> ColorType
Returns ColorType
if known; otherwise, returns ColorType::Unknown
.
Sourcepub fn color_space(&self) -> ColorSpace
pub fn color_space(&self) -> ColorSpace
Returns a smart pointer to ColorSpace
, the range of colors, associated with
Image
. The smart pointer tracks the number of objects sharing this
ColorSpace
reference so the memory is released when the owners destruct.
The returned ColorSpace
is immutable.
ColorSpace
returned was passed to an Image
constructor,
or was parsed from encoded data. ColorSpace
returned may be ignored when Image
is drawn, depending on the capabilities of the crate::Surface
receiving the drawing.
Returns: ColorSpace
in Image
, or None
, wrapped in a smart pointer
Sourcepub fn is_alpha_only(&self) -> bool
pub fn is_alpha_only(&self) -> bool
Returns true
if Image
pixels represent transparency only. If true
, each pixel
is packed in 8 bits as defined by ColorType::Alpha8
.
Returns: true
if pixels represent a transparency mask
Sourcepub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
Returns true
if pixels ignore their alpha value and are treated as fully opaque.
Returns: true
if AlphaType
is AlphaType::Opaque
Sourcepub fn to_shader<'a>(
&self,
tile_modes: impl Into<Option<(TileMode, TileMode)>>,
sampling: impl Into<SamplingOptions>,
local_matrix: impl Into<Option<&'a Matrix>>,
) -> Option<Shader>
pub fn to_shader<'a>( &self, tile_modes: impl Into<Option<(TileMode, TileMode)>>, sampling: impl Into<SamplingOptions>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>
Make a shader with the specified tiling and mipmap sampling.
Sourcepub fn to_raw_shader<'a>(
&self,
tile_modes: impl Into<Option<(TileMode, TileMode)>>,
sampling: impl Into<SamplingOptions>,
local_matrix: impl Into<Option<&'a Matrix>>,
) -> Option<Shader>
pub fn to_raw_shader<'a>( &self, tile_modes: impl Into<Option<(TileMode, TileMode)>>, sampling: impl Into<SamplingOptions>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>
to_raw_shader
functions like to_shader
, but for images that contain non-color data.
This includes images encoding things like normals, material properties (eg, roughness),
heightmaps, or any other purely mathematical data that happens to be stored in an image.
These types of images are useful with some programmable shaders (see: crate::RuntimeEffect
).
Raw image shaders work like regular image shaders (including filtering and tiling), with a few major differences:
- No color space transformation is ever applied (the color space of the image is ignored).
- Images with an alpha type of
Unpremul
are not automatically premultiplied. - Bicubic filtering is not supported. If
SamplingOptions::use_cubic
istrue
, these factories will returnNone
.
Sourcepub fn peek_pixels(&self) -> Option<Pixmap<'_>>
pub fn peek_pixels(&self) -> Option<Pixmap<'_>>
Copies Image
pixel address, row bytes, and ImageInfo
to pixmap, if address
is available, and returns true
. If pixel address is not available, return
false
and leave pixmap unchanged.
pixmap
storage for pixel state if pixels are readable; otherwise, ignored
Returns: true
if Image
has direct access to pixels
Sourcepub fn is_texture_backed(&self) -> bool
pub fn is_texture_backed(&self) -> bool
Sourcepub fn texture_size(&self) -> usize
pub fn texture_size(&self) -> usize
Returns an approximation of the amount of texture memory used by the image. Returns zero if the image is not texture backed or if the texture has an external format.
Sourcepub fn is_valid(&self, context: &mut RecordingContext) -> bool
pub fn is_valid(&self, context: &mut RecordingContext) -> bool
Returns true
if Image
can be drawn on either raster surface or GPU surface.
If context is None
, tests if Image
draws on raster surface;
otherwise, tests if Image
draws on GPU surface associated with context.
Image
backed by GPU texture may become invalid if associated context is
invalid. lazy image may be invalid and may not draw to raster surface or
GPU surface or both.
context
GPU context
Returns: true
if Image
can be drawn
Sourcepub fn make_scaled(
&self,
info: &ImageInfo,
scaling: impl Into<SamplingOptions>,
) -> Option<Image>
pub fn make_scaled( &self, info: &ImageInfo, scaling: impl Into<SamplingOptions>, ) -> Option<Image>
Create a new image by copying this image and scaling to fit the ImageInfo
’s dimensions
and converting the pixels into the ImageInfo’s crate::ColorInfo
.
This is done retaining the domain (backend) of the image (e.g. gpu, raster).
Returns None
if the requested crate::ColorInfo
is not supported, its dimensions are out
of range.
Sourcepub fn flush<'a>(
&self,
context: &mut DirectContext,
flush_info: impl Into<Option<&'a FlushInfo>>,
) -> SemaphoresSubmitted
👎Deprecated since 0.63.0: use gpu::DirectContext::flush()
pub fn flush<'a>( &self, context: &mut DirectContext, flush_info: impl Into<Option<&'a FlushInfo>>, ) -> SemaphoresSubmitted
Sourcepub fn flush_with_info(
&self,
context: &mut DirectContext,
flush_info: &FlushInfo,
) -> SemaphoresSubmitted
👎Deprecated since 0.46.0: use gpu::DirectContext::flush()
pub fn flush_with_info( &self, context: &mut DirectContext, flush_info: &FlushInfo, ) -> SemaphoresSubmitted
Flushes any pending uses of texture-backed images in the GPU backend. If the image is not
texture-backed (including promise texture images) or if the gpu::DirectContext
does not
have the same context ID as the context backing the image then this is a no-op.
If the image was not used in any non-culled draws in the current queue of work for the
passed gpu::DirectContext
then this is a no-op unless the gpu::FlushInfo
contains semaphores or
a finish proc. Those are respected even when the image has not been used.
context
the context on which to flush pending usages of the image.info
flush options
Sourcepub fn flush_and_submit(&self, context: &mut DirectContext)
👎Deprecated since 0.63.0: use gpu::DirectContext::flush_and_submit()
pub fn flush_and_submit(&self, context: &mut DirectContext)
Version of flush()
that uses a default gpu::FlushInfo
. Also submits the flushed work to the
GPU.
Sourcepub fn backend_texture(
&self,
flush_pending_gr_context_io: bool,
) -> Option<(BackendTexture, SurfaceOrigin)>
👎Deprecated since 0.63.0: use gpu::images::get_backend_texture_from_image()
pub fn backend_texture( &self, flush_pending_gr_context_io: bool, ) -> Option<(BackendTexture, SurfaceOrigin)>
Retrieves the back-end texture. If Image
has no back-end texture, None
is returned.
If flush_pending_gr_context_io
is true
, completes deferred I/O operations.
If origin in not None
, copies location of content drawn into Image
.
flush_pending_gr_context_io
flag to flush outstanding requests
Returns: back-end API texture handle; invalid on failure
Sourcepub fn read_pixels_with_context<'a, P>(
&self,
context: impl Into<Option<&'a mut DirectContext>>,
dst_info: &ImageInfo,
pixels: &mut [P],
dst_row_bytes: usize,
src: impl Into<IPoint>,
caching_hint: CachingHint,
) -> bool
pub fn read_pixels_with_context<'a, P>( &self, context: impl Into<Option<&'a mut DirectContext>>, dst_info: &ImageInfo, pixels: &mut [P], dst_row_bytes: usize, src: impl Into<IPoint>, caching_hint: CachingHint, ) -> bool
Copies crate::Rect
of pixels from Image
to dst_pixels
. Copy starts at offset (src_x
, src_y
),
and does not exceed Image
(width(), height()).
Graphite has deprecated this API in favor of the equivalent asynchronous API on
skgpu::graphite::Context
(with an optional explicit synchronization).
dst_info
specifies width, height, ColorType
, AlphaType
, and ColorSpace
of
destination. dst_row_bytes
specifies the gap from one destination row to the next.
Returns true
if pixels are copied. Returns false
if:
dst_info
.addr()
equalsNone
dst_row_bytes
is less thandst_info.min_row_bytes()
crate::PixelRef
isNone
Pixels are copied only if pixel conversion is possible. If Image
ColorType
is
ColorType::Gray8
, or ColorType::Alpha8
; dst_info.color_type()
must match.
If Image
ColorType
is ColorType::Gray8
, dst_info
.color_space()
must match.
If Image
AlphaType
is AlphaType::Opaque
, dst_info
.alpha_type()
must
match. If Image
ColorSpace
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 width()
or height()
is zero or negative.
Returns false
if abs(src_x
) >= Image width(), or if abs(src_y
) >= Image height().
If caching_hint
is CachingHint::Allow
, pixels may be retained locally.
If caching_hint
is CachingHint::Disallow
, pixels are not added to the local cache.
context
thegpu::DirectContext
in play, if it existsdst_info
destination width, height,ColorType
,AlphaType
,ColorSpace
dst_pixels
destination pixel storagedst_row_bytes
destination row lengthsrc_x
column index whose absolute value is less thanwidth()
src_y
row index whose absolute value is less thanheight()
caching_hint
whether the pixels should be cached locally
Returns: true
if pixels are copied to dst_pixels
Sourcepub fn read_pixels_to_pixmap_with_context<'a>(
&self,
context: impl Into<Option<&'a mut DirectContext>>,
dst: &Pixmap<'_>,
src: impl Into<IPoint>,
caching_hint: CachingHint,
) -> bool
pub fn read_pixels_to_pixmap_with_context<'a>( &self, context: impl Into<Option<&'a mut DirectContext>>, dst: &Pixmap<'_>, src: impl Into<IPoint>, caching_hint: CachingHint, ) -> bool
Copies a crate::Rect
of pixels from Image
to dst. Copy starts at (src_x
, src_y
), and
does not exceed Image
(width(), height()).
Graphite has deprecated this API in favor of the equivalent asynchronous API on
skgpu::graphite::Context
(with an optional explicit synchronization).
dst specifies width, height, ColorType
, AlphaType
, ColorSpace
, pixel storage,
and row bytes 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 pixel storage equals
None
- dst.
row_bytes
is less thanImageInfo::min_row_bytes
crate::PixelRef
isNone
Pixels are copied only if pixel conversion is possible. If Image
ColorType
is
ColorType::Gray8
, or ColorType::Alpha8
; dst.color_type()
must match.
If Image
ColorType
is ColorType::Gray8
, dst.color_space()
must match.
If Image
AlphaType
is AlphaType::Opaque
, dst.alpha_type()
must
match. If Image
ColorSpace
is None
, dst.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 width()
or height()
is zero or negative.
Returns false
if abs(src_x
) >= Image width(), or if abs(src_y
) >= Image height().
If caching_hint
is CachingHint::Allow
, pixels may be retained locally.
If caching_hint
is CachingHint::Disallow
, pixels are not added to the local cache.
context
thegpu::DirectContext
in play, if it existsdst
destinationPixmap
:ImageInfo
, pixels, row bytessrc_x
column index whose absolute value is less thanwidth()
src_y
row index whose absolute value is less thanheight()
caching_hint
whether the pixels should be cachedlocally_z
Returns: true
if pixels are copied to dst
Sourcepub fn read_pixels<P>(
&self,
dst_info: &ImageInfo,
pixels: &mut [P],
dst_row_bytes: usize,
src: impl Into<IPoint>,
caching_hint: CachingHint,
) -> bool
pub fn read_pixels<P>( &self, dst_info: &ImageInfo, pixels: &mut [P], dst_row_bytes: usize, src: impl Into<IPoint>, caching_hint: CachingHint, ) -> bool
Sourcepub unsafe fn read_pixels_to_pixmap(
&self,
dst: &Pixmap<'_>,
src: impl Into<IPoint>,
caching_hint: CachingHint,
) -> bool
pub unsafe fn read_pixels_to_pixmap( &self, dst: &Pixmap<'_>, src: impl Into<IPoint>, caching_hint: CachingHint, ) -> bool
Sourcepub fn scale_pixels(
&self,
dst: &Pixmap<'_>,
sampling: impl Into<SamplingOptions>,
caching_hint: impl Into<Option<CachingHint>>,
) -> bool
pub fn scale_pixels( &self, dst: &Pixmap<'_>, sampling: impl Into<SamplingOptions>, caching_hint: impl Into<Option<CachingHint>>, ) -> bool
Copies Image
to dst, scaling pixels to fit dst.width()
and dst.height()
, and
converting pixels to match dst.color_type()
and dst.alpha_type()
. Returns true
if
pixels are copied. Returns false
if dst.addr()
is None
, or dst.row_bytes()
is
less than dst ImageInfo::min_row_bytes
.
Pixels are copied only if pixel conversion is possible. If Image
ColorType
is
ColorType::Gray8
, or ColorType::Alpha8
; dst.color_type()
must match.
If Image
ColorType
is ColorType::Gray8
, dst.color_space()
must match.
If Image
AlphaType
is AlphaType::Opaque
, dst.alpha_type()
must
match. If Image
ColorSpace
is None
, dst.color_space()
must match. Returns
false
if pixel conversion is not possible.
If caching_hint
is CachingHint::Allow
, pixels may be retained locally.
If caching_hint
is CachingHint::Disallow
, pixels are not added to the local cache.
Returns: true
if pixels are scaled to fit dst
Sourcepub fn encode_to_data_with_context(
&self,
context: impl Into<Option<DirectContext>>,
image_format: EncodedImageFormat,
quality: impl Into<Option<u32>>,
) -> Option<Data>
👎Deprecated since 0.63.0: Use encode
pub fn encode_to_data_with_context( &self, context: impl Into<Option<DirectContext>>, image_format: EncodedImageFormat, quality: impl Into<Option<u32>>, ) -> Option<Data>
Encodes Image
pixels, returning result as Data
.
Returns None
if encoding fails, or if encoded_image_format
is not supported.
Image
encoding in a format requires both building with one or more of:
SK_ENCODE_JPEG, SK_ENCODE_PNG, SK_ENCODE_WEBP; and platform support
for the encoded format.
If SK_BUILD_FOR_MAC or SK_BUILD_FOR_IOS is defined, encoded_image_format
can
additionally be one of: EncodedImageFormat::ICO
, EncodedImageFormat::BMP
,
EncodedImageFormat::GIF
.
quality is a platform and format specific metric trading off size and encoding error. When used, quality equaling 100 encodes with the least error. quality may be ignored by the encoder.
context
- thegpu::DirectContext
in play, if it exists; can beNone
encoded_image_format
- one of:EncodedImageFormat::JPEG
,EncodedImageFormat::PNG
,EncodedImageFormat::WEBP
quality
- encoder specific metric with 100 equaling best
Returns: encoded Image
, or None
Sourcepub fn encode_to_data(&self, image_format: EncodedImageFormat) -> Option<Data>
👎Deprecated since 0.63.0: Support for encoding GPU backed images without a context was removed, use encode_to_data_with_context
instead
pub fn encode_to_data(&self, image_format: EncodedImageFormat) -> Option<Data>
encode_to_data_with_context
insteadSourcepub fn encode_to_data_with_quality(
&self,
image_format: EncodedImageFormat,
quality: u32,
) -> Option<Data>
👎Deprecated since 0.63.0: Support for encoding GPU backed images without a context was removed, use encode_to_data_with_context
instead
pub fn encode_to_data_with_quality( &self, image_format: EncodedImageFormat, quality: u32, ) -> Option<Data>
encode_to_data_with_context
insteadEncodes Image
pixels, returning result as Data
.
Returns None
if encoding fails, or if encoded_image_format
is not supported.
Image
encoding in a format requires both building with one or more of:
SK_ENCODE_JPEG, SK_ENCODE_PNG, SK_ENCODE_WEBP; and platform support
for the encoded format.
If SK_BUILD_FOR_MAC or SK_BUILD_FOR_IOS is defined, encoded_image_format
can
additionally be one of: EncodedImageFormat::ICO
, EncodedImageFormat::BMP
,
EncodedImageFormat::GIF
.
quality is a platform and format specific metric trading off size and encoding error. When used, quality equaling 100 encodes with the least error. quality may be ignored by the encoder.
encoded_image_format
one of:EncodedImageFormat::JPEG
,EncodedImageFormat::PNG
,EncodedImageFormat::WEBP
quality
encoder specific metric with 100 equaling best
Returns: encoded Image
, or None
Sourcepub fn encoded_data(&self) -> Option<Data>
pub fn encoded_data(&self) -> Option<Data>
Returns encoded Image
pixels as Data
, if Image
was created from supported
encoded stream format. Platform support for formats vary and may require building
with one or more of: SK_ENCODE_JPEG, SK_ENCODE_PNG, SK_ENCODE_WEBP.
Returns None
if Image
contents are not encoded.
Returns: encoded Image
, or None
Sourcepub fn new_subset(&self, rect: impl AsRef<IRect>) -> Option<Image>
👎Deprecated since 0.64.0: use make_subset()
pub fn new_subset(&self, rect: impl AsRef<IRect>) -> Option<Image>
Sourcepub fn new_subset_with_context<'a>(
&self,
rect: impl AsRef<IRect>,
direct: impl Into<Option<&'a mut DirectContext>>,
) -> Option<Image>
👎Deprecated since 0.64.0: use make_subset()
pub fn new_subset_with_context<'a>( &self, rect: impl AsRef<IRect>, direct: impl Into<Option<&'a mut DirectContext>>, ) -> Option<Image>
Returns subset of this image.
Returns None
if any of the following are true:
- Subset is empty
- Subset is not contained inside the image’s bounds
- Pixels in the image could not be read or copied
If this image is texture-backed, the context parameter is required and must match the context of the source image. If the context parameter is provided, and the image is raster-backed, the subset will be converted to texture-backed.
subset
bounds of returnedImage
context
thegpu::DirectContext
in play, if it exists
Returns: the subsetted image, or None
Sourcepub fn make_subset<'a>(
&self,
direct: impl Into<Option<&'a mut DirectContext>>,
subset: impl AsRef<IRect>,
) -> Option<Image>
pub fn make_subset<'a>( &self, direct: impl Into<Option<&'a mut DirectContext>>, subset: impl AsRef<IRect>, ) -> Option<Image>
Returns subset of this image.
Returns None
if any of the following are true:
- Subset is empty - Subset is not contained inside the image’s bounds
- Pixels in the source image could not be read or copied
- This image is texture-backed and the provided context is null or does not match the
source image’s context.
If the source image was texture-backed, the resulting image will be texture-backed also. Otherwise, the returned image will be raster-backed.
direct
- thegpu::DirectContext
of the source image (None
is ok if the source image is not texture-backed).subset
- bounds of returnedImage
Returns: the subsetted image, orNone
Sourcepub fn has_mipmaps(&self) -> bool
pub fn has_mipmaps(&self) -> bool
Returns true
if the image has mipmap levels.
Sourcepub fn with_default_mipmaps(&self) -> Option<Image>
pub fn with_default_mipmaps(&self) -> Option<Image>
Returns an image with the same “base” pixels as the this image, but with mipmap levels automatically generated and attached.
Sourcepub fn new_texture_image(
&self,
context: &mut DirectContext,
mipmapped: Mipmapped,
) -> Option<Image>
pub fn new_texture_image( &self, context: &mut DirectContext, mipmapped: Mipmapped, ) -> Option<Image>
Sourcepub fn new_texture_image_budgeted(
&self,
direct_context: &mut DirectContext,
mipmapped: Mipmapped,
budgeted: Budgeted,
) -> Option<Image>
pub fn new_texture_image_budgeted( &self, direct_context: &mut DirectContext, mipmapped: Mipmapped, budgeted: Budgeted, ) -> Option<Image>
Returns Image
backed by GPU texture associated with context. Returned Image
is
compatible with crate::Surface
created with dst_color_space
. The returned Image
respects
mipmapped setting; if mipmapped equals gpu::Mipmapped::Yes
, the backing texture
allocates mip map levels.
The mipmapped parameter is effectively treated as No
if MIP maps are not supported by the
GPU.
Returns original Image
if the image is already texture-backed, the context matches, and
mipmapped is compatible with the backing GPU texture. crate::Budgeted
is ignored in this case.
Returns None
if context is None
, or if Image
was created with another
gpu::DirectContext
.
direct_context
thegpu::DirectContext
in play, if it existsmipmapped
whether createdImage
texture must allocate mip map levelsbudgeted
whether to count a newly created texture for the returned image counts against the context’s budget.
Returns: created Image
, or None
Sourcepub fn to_non_texture_image(&self) -> Option<Image>
👎Deprecated since 0.64.0: use make_non_texture_image()
pub fn to_non_texture_image(&self) -> Option<Image>
Returns raster image or lazy image. Copies Image
backed by GPU texture into
CPU memory if needed. Returns original Image
if decoded in raster bitmap,
or if encoded in a stream.
Returns None
if backed by GPU texture and copy fails.
Returns: raster image, lazy image, or None
example: https://fiddle.skia.org/c/@Image_makeNonTextureImage
Sourcepub fn make_non_texture_image<'a>(
&self,
context: impl Into<Option<&'a mut DirectContext>>,
) -> Option<Image>
pub fn make_non_texture_image<'a>( &self, context: impl Into<Option<&'a mut DirectContext>>, ) -> Option<Image>
Returns raster image or lazy image. Copies Image
backed by GPU texture into
CPU memory if needed. Returns original Image
if decoded in raster bitmap,
or if encoded in a stream.
Returns None
if backed by GPU texture and copy fails.
Returns: raster image, lazy image, or None
example: https://fiddle.skia.org/c/@Image_makeNonTextureImage
Sourcepub fn to_raster_image(
&self,
caching_hint: impl Into<Option<CachingHint>>,
) -> Option<Image>
👎Deprecated since 0.64.0: use make_raster_image()
pub fn to_raster_image( &self, caching_hint: impl Into<Option<CachingHint>>, ) -> Option<Image>
Returns raster image. Copies Image
backed by GPU texture into CPU memory,
or decodes Image
from lazy image. Returns original Image
if decoded in
raster bitmap.
Returns None
if copy, decode, or pixel read fails.
If caching_hint
is CachingHint::Allow
, pixels may be retained locally.
If caching_hint
is CachingHint::Disallow
, pixels are not added to the local cache.
Returns: raster image, or None
Sourcepub fn make_raster_image<'a>(
&self,
context: impl Into<Option<&'a mut DirectContext>>,
caching_hint: impl Into<Option<CachingHint>>,
) -> Option<Image>
pub fn make_raster_image<'a>( &self, context: impl Into<Option<&'a mut DirectContext>>, caching_hint: impl Into<Option<CachingHint>>, ) -> Option<Image>
Returns raster image. Copies Image
backed by GPU texture into CPU memory,
or decodes Image
from lazy image. Returns original Image
if decoded in
raster bitmap.
Returns None
if copy, decode, or pixel read fails.
If caching_hint
is CachingHint::Allow
, pixels may be retained locally.
If caching_hint
is CachingHint::Disallow
, pixels are not added to the local cache.
Returns: raster image, or None
Sourcepub fn new_with_filter(
&self,
_context: Option<&mut RecordingContext>,
filter: &ImageFilter,
clip_bounds: impl Into<IRect>,
subset: impl Into<IRect>,
) -> Option<(Image, IRect, IPoint)>
👎Deprecated since 0.67.0: use images::make_with_filter()
pub fn new_with_filter( &self, _context: Option<&mut RecordingContext>, filter: &ImageFilter, clip_bounds: impl Into<IRect>, subset: impl Into<IRect>, ) -> Option<(Image, IRect, IPoint)>
Creates filtered Image
. filter processes original Image
, potentially changing
color, position, and size. subset is the bounds of original Image
processed
by filter. clip_bounds
is the expected bounds of the filtered Image
. out_subset
is required storage for the actual bounds of the filtered Image
. offset is
required storage for translation of returned Image
.
Returns None
if Image
could not be created or if the recording context provided doesn’t
match the GPU context in which the image was created. If None
is returned, out_subset
and offset are undefined.
Useful for animation of ImageFilter
that varies size from frame to frame.
Returned Image
is created larger than required by filter so that GPU texture
can be reused with different sized effects. out_subset
describes the valid bounds
of GPU texture returned. offset translates the returned Image
to keep subsequent
animation frames aligned with respect to each other.
context
thegpu::RecordingContext
in play - if it existsfilter
howImage
is sampled when transformedsubset
bounds ofImage
processed by filterclip_bounds
expected bounds of filteredImage
out_subset
storage for returnedImage
boundsoffset
storage for returnedImage
translation
Returns: filtered Image
, or None
Sourcepub fn is_lazy_generated(&self) -> bool
pub fn is_lazy_generated(&self) -> bool
Returns true
if Image
is backed by an image-generator or other service that creates
and caches its pixels or texture on-demand.
Returns: true
if Image
is created as needed
example: https://fiddle.skia.org/c/@Image_isLazyGenerated_a example: https://fiddle.skia.org/c/@Image_isLazyGenerated_b
Sourcepub fn new_color_space(
&self,
color_space: impl Into<Option<ColorSpace>>,
) -> Option<Image>
👎Deprecated since 0.64.0: use make_color_space()
pub fn new_color_space( &self, color_space: impl Into<Option<ColorSpace>>, ) -> Option<Image>
Sourcepub fn new_color_space_with_context<'a>(
&self,
color_space: impl Into<Option<ColorSpace>>,
direct: impl Into<Option<&'a mut DirectContext>>,
) -> Option<Image>
👎Deprecated since 0.64.0: use make_color_space()
pub fn new_color_space_with_context<'a>( &self, color_space: impl Into<Option<ColorSpace>>, direct: impl Into<Option<&'a mut DirectContext>>, ) -> Option<Image>
Creates Image
in target ColorSpace
.
Returns None
if Image
could not be created.
Returns original Image
if it is in target ColorSpace
.
Otherwise, converts pixels from Image
ColorSpace
to target ColorSpace
.
If Image
color_space()
returns None
, Image
ColorSpace
is assumed to be s_rgb
.
If this image is texture-backed, the context parameter is required and must match the context of the source image.
target
ColorSpace
describing color range of returnedImage
direct
Thegpu::DirectContext
in play, if it exists
Returns: created Image
in target ColorSpace
Sourcepub fn make_color_space<'a>(
&self,
direct: impl Into<Option<&'a mut DirectContext>>,
color_space: impl Into<Option<ColorSpace>>,
) -> Option<Image>
pub fn make_color_space<'a>( &self, direct: impl Into<Option<&'a mut DirectContext>>, color_space: impl Into<Option<ColorSpace>>, ) -> Option<Image>
Creates Image
in target ColorSpace
.
Returns None
if Image
could not be created.
Returns original Image
if it is in target ColorSpace
.
Otherwise, converts pixels from Image
ColorSpace
to target ColorSpace
.
If Image
color_space()
returns None
, Image
ColorSpace
is assumed to be s_rgb
.
If this image is texture-backed, the context parameter is required and must match the context of the source image.
direct
Thegpu::DirectContext
in play, if it existstarget
ColorSpace
describing color range of returnedImage
Returns: created Image
in target ColorSpace
Sourcepub fn reinterpret_color_space(
&self,
new_color_space: impl Into<ColorSpace>,
) -> Option<Image>
pub fn reinterpret_color_space( &self, new_color_space: impl Into<ColorSpace>, ) -> Option<Image>
Creates a new Image
identical to this one, but with a different ColorSpace
.
This does not convert the underlying pixel data, so the resulting image will draw
differently.
Source§impl RCHandle<SkImageFilter>
impl RCHandle<SkImageFilter>
pub fn filter_bounds<'a>( &self, src: impl AsRef<IRect>, ctm: &Matrix, map_direction: MapDirection, input_rect: impl Into<Option<&'a IRect>>, ) -> IRect
pub fn color_filter_node(&self) -> Option<ColorFilter>
pub fn to_a_color_filter(&self) -> Option<ColorFilter>
pub fn count_inputs(&self) -> usize
pub fn input(&self, i: usize) -> Option<ImageFilter>
pub fn get_input(&self, i: usize) -> Option<ImageFilter>
pub fn inputs(&self) -> impl Iterator<Item = Option<ImageFilter>> + use<'_>
pub fn compute_fast_bounds(&self, bounds: impl AsRef<Rect>) -> Rect
pub fn can_compute_fast_bounds(&self) -> bool
pub fn with_local_matrix(&self, matrix: &Matrix) -> Option<ImageFilter>
Source§impl RCHandle<SkMaskFilter>
impl RCHandle<SkMaskFilter>
Sourcepub fn blur(
style: BlurStyle,
sigma: scalar,
respect_ctm: impl Into<Option<bool>>,
) -> Option<Self>
pub fn blur( style: BlurStyle, sigma: scalar, respect_ctm: impl Into<Option<bool>>, ) -> Option<Self>
Create a blur mask filter.
style
TheBlurStyle
to usesigma
Standard deviation of the Gaussian blur to apply. Must be > 0.respect_ctm
iftrue
the blur’s sigma is modified by thectm
.
Returns the new blur mask filter
Sourcepub fn approximate_filtered_bounds(&self, src: impl AsRef<Rect>) -> Rect
pub fn approximate_filtered_bounds(&self, src: impl AsRef<Rect>) -> Rect
Returns the approximate bounds that would result from filtering the src
rect. The actual
result may be different, but it should be contained within the returned bounds.
pub fn compose(_outer: Self, _inner: Self) -> !
pub fn combine(_filter_a: Self, _filter_b: Self, _mode: CoverageMode) -> !
pub fn with_matrix(&self, _matrix: &Matrix) -> !
Source§impl RCHandle<SkPathEffect>
impl RCHandle<SkPathEffect>
pub fn sum( first: impl Into<PathEffect>, second: impl Into<PathEffect>, ) -> PathEffect
pub fn compose( first: impl Into<PathEffect>, second: impl Into<PathEffect>, ) -> PathEffect
pub fn filter_path( &self, src: &Path, stroke_rec: &StrokeRec, cull_rect: impl AsRef<Rect>, ) -> Option<(Path, StrokeRec)>
pub fn filter_path_inplace( &self, dst: &mut Path, src: &Path, stroke_rec: &mut StrokeRec, cull_rect: impl AsRef<Rect>, ) -> bool
pub fn filter_path_inplace_with_matrix( &self, dst: &mut Path, src: &Path, stroke_rec: &mut StrokeRec, cull_rect: impl AsRef<Rect>, ctm: &Matrix, ) -> bool
pub fn needs_ctm(&self) -> bool
Source§impl RCHandle<SkPicture>
impl RCHandle<SkPicture>
pub fn from_data(data: &Data) -> Option<Picture>
pub fn from_bytes(bytes: &[u8]) -> Option<Picture>
pub fn playback(&self, canvas: &Canvas)
pub fn cull_rect(&self) -> Rect
pub fn unique_id(&self) -> u32
pub fn serialize(&self) -> Data
pub fn new_placeholder(cull: impl AsRef<Rect>) -> Picture
pub fn approximate_op_count(&self) -> usize
pub fn approximate_op_count_nested( &self, nested: impl Into<Option<bool>>, ) -> usize
pub fn approximate_bytes_used(&self) -> usize
pub fn to_shader<'a, 'b>( &self, tm: impl Into<Option<(TileMode, TileMode)>>, mode: FilterMode, local_matrix: impl Into<Option<&'a Matrix>>, tile_rect: impl Into<Option<&'b Rect>>, ) -> Shader
Source§impl RCHandle<SkPixelRef>
impl RCHandle<SkPixelRef>
pub fn dimensions(&self) -> ISize
pub fn width(&self) -> i32
pub fn height(&self) -> i32
pub unsafe fn pixels(&self) -> *mut c_void
pub fn row_bytes(&self) -> usize
pub fn generation_id(&self) -> u32
pub fn notify_pixels_changed(&mut self)
pub fn is_immutable(&self) -> bool
pub fn set_immutable(&mut self)
pub fn notify_added_to_cache(&mut self)
Source§impl RCHandle<SkShader>
impl RCHandle<SkShader>
Shaders specify the source color(s) for what is being drawn. If a paint has no shader, then the paint’s color is used. If the paint has a shader, then the shader’s color(s) are use instead, but they are modulated by the paint’s alpha. This makes it easy to create a shader once (e.g. bitmap tiling or gradient) and then change its transparency w/o having to modify the original shader… only the paint’s alpha needs to be modified.
Sourcepub fn is_opaque(&self) -> bool
pub fn is_opaque(&self) -> bool
Returns true
if the shader is guaranteed to produce only opaque
colors, subject to the crate::Paint
using the shader to apply an opaque
alpha value. Subclasses should override this to allow some
optimizations.
Sourcepub fn image(&self) -> Option<(Image, Matrix, (TileMode, TileMode))>
pub fn image(&self) -> Option<(Image, Matrix, (TileMode, TileMode))>
Returns iff this shader is backed by a single Image
.
If not, returns None
.
pub fn is_a_image(&self) -> bool
Sourcepub fn with_local_matrix(&self, matrix: &Matrix) -> Self
pub fn with_local_matrix(&self, matrix: &Matrix) -> Self
Return a shader that will apply the specified local_matrix
to this shader.
The specified matrix will be applied before any matrix associated with this shader.
Sourcepub fn with_color_filter(&self, color_filter: impl Into<ColorFilter>) -> Self
pub fn with_color_filter(&self, color_filter: impl Into<ColorFilter>) -> Self
Create a new shader that produces the same colors as invoking this shader and then applying the color filter.
Sourcepub fn with_working_color_space(
&self,
color_space: impl Into<ColorSpace>,
) -> Self
pub fn with_working_color_space( &self, color_space: impl Into<ColorSpace>, ) -> Self
Return a shader that will compute this shader in a specific color space. By default, all shaders operate in the destination (surface) color space. The results of a shader are still always converted to the destination - this API has no impact on simple shaders or images. Primarily, it impacts shaders that perform mathematical operations, like Blend shaders, or runtime shaders.
Source§impl RCHandle<SkSurface>
impl RCHandle<SkSurface>
Sourcepub fn new_raster_direct<'pixels>(
image_info: &ImageInfo,
pixels: &'pixels mut [u8],
row_bytes: impl Into<Option<usize>>,
surface_props: Option<&SurfaceProps>,
) -> Option<Borrows<'pixels, Surface>>
👎Deprecated since 0.64.0: use surfaces::wrap_pixels()
pub fn new_raster_direct<'pixels>( image_info: &ImageInfo, pixels: &'pixels mut [u8], row_bytes: impl Into<Option<usize>>, surface_props: Option<&SurfaceProps>, ) -> Option<Borrows<'pixels, Surface>>
Allocates raster Surface
. Canvas
returned by Surface
draws directly into pixels.
Surface
is returned if all parameters are valid.
Valid parameters include:
info dimensions are greater than zero;
info contains crate::ColorType
and crate::AlphaType
supported by raster surface;
pixels is not None
;
row_bytes
is large enough to contain info width pixels of crate::ColorType
.
Pixel buffer size should be info height times computed row_bytes
.
Pixels are not initialized.
To access pixels after drawing, Self::peek_pixels()
or Self::read_pixels()
.
image_info
- width, height,crate::ColorType
,crate::AlphaType
,crate::ColorSpace
, of raster surface; width and height must be greater than zeropixels
- pointer to destination pixels bufferrow_bytes
- interval from oneSurface
row to the nextsurface_props
- LCD striping orientation and setting for device independent fonts; may beNone
Returns: Surface
if all parameters are valid; otherwise, None
Sourcepub fn new_raster(
image_info: &ImageInfo,
row_bytes: impl Into<Option<usize>>,
surface_props: Option<&SurfaceProps>,
) -> Option<Self>
👎Deprecated since 0.64.0: use surfaces::raster()
pub fn new_raster( image_info: &ImageInfo, row_bytes: impl Into<Option<usize>>, surface_props: Option<&SurfaceProps>, ) -> Option<Self>
Allocates raster Surface
. Canvas
returned by Surface
draws directly into pixels.
Allocates and zeroes pixel memory. Pixel memory size is image_info.height()
times
row_bytes
, or times image_info.min_row_bytes()
if row_bytes
is zero.
Pixel memory is deleted when Surface
is deleted.
Surface
is returned if all parameters are valid.
Valid parameters include:
info dimensions are greater than zero;
info contains crate::ColorType
and crate::AlphaType
supported by raster surface;
row_bytes
is large enough to contain info width pixels of crate::ColorType
, or is zero.
If row_bytes
is zero, a suitable value will be chosen internally.
image_info
- width, height,crate::ColorType
,crate::AlphaType
,crate::ColorSpace
, of raster surface; width and height must be greater than zerorow_bytes
- interval from oneSurface
row to the next; may be zerosurface_props
- LCD striping orientation and setting for device independent fonts; may beNone
Returns: Surface
if all parameters are valid; otherwise, None
Sourcepub fn new_raster_n32_premul(size: impl Into<ISize>) -> Option<Self>
👎Deprecated since 0.64.0: use surfaces::raster_n32_premul()
pub fn new_raster_n32_premul(size: impl Into<ISize>) -> Option<Self>
Allocates raster Surface
. Canvas
returned by Surface
draws directly into pixels.
Allocates and zeroes pixel memory. Pixel memory size is height times width times
four. Pixel memory is deleted when Surface
is deleted.
Internally, sets ImageInfo
to width, height, native color type, and
crate::AlphaType::Premul
.
Surface
is returned if width and height are greater than zero.
Use to create Surface
that matches crate::PMColor
, the native pixel arrangement on
the platform. Surface
drawn to output device skips converting its pixel format.
width
- pixel column count; must be greater than zeroheight
- pixel row count; must be greater than zerosurface_props
- LCD striping orientation and setting for device independent fonts; may beNone
Returns: Surface
if all parameters are valid; otherwise, None
Source§impl RCHandle<SkSurface>
impl RCHandle<SkSurface>
Sourcepub fn from_backend_texture(
context: &mut RecordingContext,
backend_texture: &BackendTexture,
origin: SurfaceOrigin,
sample_cnt: impl Into<Option<usize>>,
color_type: ColorType,
color_space: impl Into<Option<ColorSpace>>,
surface_props: Option<&SurfaceProps>,
) -> Option<Self>
👎Deprecated since 0.64.0: use gpu::surfaces::wrap_backend_texture()
pub fn from_backend_texture( context: &mut RecordingContext, backend_texture: &BackendTexture, origin: SurfaceOrigin, sample_cnt: impl Into<Option<usize>>, color_type: ColorType, color_space: impl Into<Option<ColorSpace>>, surface_props: Option<&SurfaceProps>, ) -> Option<Self>
Wraps a GPU-backed texture into Surface
. Caller must ensure the texture is
valid for the lifetime of returned Surface
. If sample_cnt
greater than zero,
creates an intermediate MSAA Surface
which is used for drawing backend_texture
.
Surface
is returned if all parameters are valid. backend_texture
is valid if
its pixel configuration agrees with color_space
and context; for instance, if
backend_texture
has an sRGB configuration, then context must support sRGB,
and color_space
must be present. Further, backend_texture
width and height must
not exceed context capabilities, and the context must be able to support
back-end textures.
context
- GPU contextbackend_texture
- texture residing on GPUsample_cnt
- samples per pixel, or 0 to disable full scene anti-aliasingcolor_space
- range of colors; may beNone
surface_props
- LCD striping orientation and setting for device independent fonts; may beNone
Returns: Surface
if all parameters are valid; otherwise, None
Sourcepub fn from_backend_render_target(
context: &mut RecordingContext,
backend_render_target: &BackendRenderTarget,
origin: SurfaceOrigin,
color_type: ColorType,
color_space: impl Into<Option<ColorSpace>>,
surface_props: Option<&SurfaceProps>,
) -> Option<Self>
👎Deprecated since 0.64.0: use gpu::surfaces::wrap_backend_render_target()
pub fn from_backend_render_target( context: &mut RecordingContext, backend_render_target: &BackendRenderTarget, origin: SurfaceOrigin, color_type: ColorType, color_space: impl Into<Option<ColorSpace>>, surface_props: Option<&SurfaceProps>, ) -> Option<Self>
Wraps a GPU-backed buffer into Surface
. Caller must ensure backend_render_target
is valid for the lifetime of returned Surface
.
Surface
is returned if all parameters are valid. backend_render_target
is valid if
its pixel configuration agrees with color_space
and context; for instance, if
backend_render_target
has an sRGB configuration, then context must support sRGB,
and color_space
must be present. Further, backend_render_target
width and height must
not exceed context capabilities, and the context must be able to support
back-end render targets.
context
- GPU contextbackend_render_target
- GPU intermediate memory buffercolor_space
- range of colorssurface_props
- LCD striping orientation and setting for device independent fonts; may beNone
Returns: Surface
if all parameters are valid; otherwise, None
Sourcepub fn new_render_target(
context: &mut RecordingContext,
budgeted: Budgeted,
image_info: &ImageInfo,
sample_count: impl Into<Option<usize>>,
surface_origin: impl Into<Option<SurfaceOrigin>>,
surface_props: Option<&SurfaceProps>,
should_create_with_mips: impl Into<Option<bool>>,
) -> Option<Self>
👎Deprecated since 0.64.0: use gpu::surfaces::render_target()
pub fn new_render_target( context: &mut RecordingContext, budgeted: Budgeted, image_info: &ImageInfo, sample_count: impl Into<Option<usize>>, surface_origin: impl Into<Option<SurfaceOrigin>>, surface_props: Option<&SurfaceProps>, should_create_with_mips: impl Into<Option<bool>>, ) -> Option<Self>
Returns Surface
on GPU indicated by context. Allocates memory for
pixels, based on the width, height, and crate::ColorType
in ImageInfo
. budgeted
selects whether allocation for pixels is tracked by context. image_info
describes the pixel format in crate::ColorType
, and transparency in
crate::AlphaType
, and color matching in crate::ColorSpace
.
sample_count
requests the number of samples per pixel.
Pass zero to disable multi-sample anti-aliasing. The request is rounded
up to the next supported count, or rounded down if it is larger than the
maximum supported count.
surface_origin
pins either the top-left or the bottom-left corner to the origin.
should_create_with_mips
hints that Image
returned by Image::image_snapshot
is mip map.
context
- GPU contextimage_info
- width, height,crate::ColorType
,crate::AlphaType
,crate::ColorSpace
; width, or height, or both, may be zerosample_count
- samples per pixel, or 0 to disable full scene anti-aliasingsurface_props
- LCD striping orientation and setting for device independent fonts; may beNone
should_create_with_mips
- hint thatSurface
will host mip map images
Returns: Surface
if all parameters are valid; otherwise, None
Sourcepub unsafe fn from_ca_metal_layer(
context: &mut RecordingContext,
layer: Handle,
origin: SurfaceOrigin,
sample_cnt: impl Into<Option<usize>>,
color_type: ColorType,
color_space: impl Into<Option<ColorSpace>>,
surface_props: Option<&SurfaceProps>,
drawable: *mut Handle,
) -> Option<Self>
👎Deprecated since 0.65.0: Use gpu::surfaces::wrap_ca_metal_layer
pub unsafe fn from_ca_metal_layer( context: &mut RecordingContext, layer: Handle, origin: SurfaceOrigin, sample_cnt: impl Into<Option<usize>>, color_type: ColorType, color_space: impl Into<Option<ColorSpace>>, surface_props: Option<&SurfaceProps>, drawable: *mut Handle, ) -> Option<Self>
Creates Surface
from CAMetalLayer.
Returned Surface
takes a reference on the CAMetalLayer. The ref on the layer will be
released when the Surface
is destroyed.
Only available when Metal API is enabled.
Will grab the current drawable from the layer and use its texture as a backend_rt
to
create a renderable surface.
context
- GPU contextlayer
-gpu::mtl::Handle
(expected to be a CAMetalLayer*)sample_cnt
- samples per pixel, or 0 to disable full scene anti-aliasingcolor_space
- range of colors; may beNone
surface_props
- LCD striping orientation and setting for device independent fonts; may beNone
drawable
- Pointer to drawable to be filled in when this surface is instantiated; may not beNone
Returns: created Surface
, or None
Sourcepub unsafe fn from_mtk_view(
context: &mut RecordingContext,
mtk_view: Handle,
origin: SurfaceOrigin,
sample_count: impl Into<Option<usize>>,
color_type: ColorType,
color_space: impl Into<Option<ColorSpace>>,
surface_props: Option<&SurfaceProps>,
) -> Option<Self>
👎Deprecated since 0.65.0: Use gpu::surfaces::wrap_mtk_view
pub unsafe fn from_mtk_view( context: &mut RecordingContext, mtk_view: Handle, origin: SurfaceOrigin, sample_count: impl Into<Option<usize>>, color_type: ColorType, color_space: impl Into<Option<ColorSpace>>, surface_props: Option<&SurfaceProps>, ) -> Option<Self>
Creates Surface
from MTKView.
Returned Surface
takes a reference on the MTKView
. The ref on the layer will be
released when the Surface
is destroyed.
Only available when Metal API is enabled.
Will grab the current drawable from the layer and use its texture as a backend_rt
to
create a renderable surface.
context
- GPU contextlayer
-gpu::mtl::Handle
(expected to be aMTKView*
)sample_cnt
- samples per pixel, or 0 to disable full scene anti-aliasingcolor_space
- range of colors; may beNone
surface_props
- LCD striping orientation and setting for device independent fonts; may beNone
Returns: created Surface
, or None
Source§impl RCHandle<SkSurface>
impl RCHandle<SkSurface>
Sourcepub fn new_null(size: impl Into<ISize>) -> Option<Self>
👎Deprecated since 0.64.0: use surfaces::null()
pub fn new_null(size: impl Into<ISize>) -> Option<Self>
Sourcepub fn width(&self) -> i32
pub fn width(&self) -> i32
Returns pixel count in each row; may be zero or greater.
Returns: number of pixel columns
Sourcepub fn height(&self) -> i32
pub fn height(&self) -> i32
Returns pixel row count; may be zero or greater.
Returns: number of pixel rows
Sourcepub fn image_info(&mut self) -> ImageInfo
pub fn image_info(&mut self) -> ImageInfo
Returns an ImageInfo
describing the surface.
Sourcepub fn generation_id(&mut self) -> u32
pub fn generation_id(&mut self) -> u32
Returns unique value identifying the content of Surface
. Returned value changes
each time the content changes. Content is changed by drawing, or by calling
Self::notify_content_will_change()
.
Returns: unique content identifier
example: https://fiddle.skia.org/c/@Surface_notifyContentWillChange
Sourcepub fn notify_content_will_change(
&mut self,
mode: ContentChangeMode,
) -> &mut Self
pub fn notify_content_will_change( &mut self, mode: ContentChangeMode, ) -> &mut Self
Notifies that Surface
contents will be changed by code outside of Skia.
Subsequent calls to Self::generation_id()
return a different value.
example: https://fiddle.skia.org/c/@Surface_notifyContentWillChange
Source§impl RCHandle<SkSurface>
impl RCHandle<SkSurface>
Sourcepub fn recording_context(&self) -> Option<RecordingContext>
pub fn recording_context(&self) -> Option<RecordingContext>
Returns the recording context being used by the Surface
.
Returns: the recording context, if available; None
otherwise
Sourcepub fn direct_context(&self) -> Option<DirectContext>
pub fn direct_context(&self) -> Option<DirectContext>
rust-skia helper, not in Skia
Sourcepub fn get_backend_texture(
&mut self,
handle_access: BackendHandleAccess,
) -> Option<BackendTexture>
👎Deprecated since 0.64.0: use gpu::surfaces::get_backend_texture()
pub fn get_backend_texture( &mut self, handle_access: BackendHandleAccess, ) -> Option<BackendTexture>
Retrieves the back-end texture. If Surface
has no back-end texture, None
is returned.
The returned gpu::BackendTexture
should be discarded if the Surface
is drawn to or deleted.
Returns: GPU texture reference; None
on failure
Sourcepub fn get_backend_render_target(
&mut self,
handle_access: BackendHandleAccess,
) -> Option<BackendRenderTarget>
👎Deprecated since 0.64.0: use gpu::surfaces::get_backend_render_target()
pub fn get_backend_render_target( &mut self, handle_access: BackendHandleAccess, ) -> Option<BackendRenderTarget>
Retrieves the back-end render target. If Surface
has no back-end render target, None
is returned.
The returned gpu::BackendRenderTarget
should be discarded if the Surface
is drawn to
or deleted.
Returns: GPU render target reference; None
on failure
Sourcepub fn replace_backend_texture(
&mut self,
backend_texture: &BackendTexture,
origin: SurfaceOrigin,
) -> bool
pub fn replace_backend_texture( &mut self, backend_texture: &BackendTexture, origin: SurfaceOrigin, ) -> bool
If the surface was made via Self::from_backend_texture
then it’s backing texture may be
substituted with a different texture. The contents of the previous backing texture are
copied into the new texture. Canvas
state is preserved. The original sample count is
used. The gpu::BackendFormat
and dimensions of replacement texture must match that of
the original.
backend_texture
- the new backing texture for the surface
Sourcepub fn replace_backend_texture_with_mode(
&mut self,
backend_texture: &BackendTexture,
origin: SurfaceOrigin,
mode: impl Into<Option<ContentChangeMode>>,
) -> bool
pub fn replace_backend_texture_with_mode( &mut self, backend_texture: &BackendTexture, origin: SurfaceOrigin, mode: impl Into<Option<ContentChangeMode>>, ) -> bool
If the surface was made via Self::from_backend_texture()
then it’s backing texture may be
substituted with a different texture. The contents of the previous backing texture are
copied into the new texture. Canvas
state is preserved. The original sample count is
used. The gpu::BackendFormat
and dimensions of replacement texture must match that of
the original.
backend_texture
- the new backing texture for the surfacemode
- Retain or discard current Content
Source§impl RCHandle<SkSurface>
impl RCHandle<SkSurface>
Sourcepub fn new_surface(&mut self, image_info: &ImageInfo) -> Option<Self>
pub fn new_surface(&mut self, image_info: &ImageInfo) -> Option<Self>
Returns a compatible Surface
, or None
. Returned Surface
contains
the same raster, GPU, or null properties as the original. Returned Surface
does not share the same pixels.
Returns None
if image_info
width or height are zero, or if image_info
is incompatible with Surface
.
image_info
- width, height,crate::ColorType
,crate::AlphaType
,crate::ColorSpace
, ofSurface
; width and height must be greater than zero
Returns: compatible Surface
or None
Sourcepub fn new_surface_with_dimensions(
&mut self,
dim: impl Into<ISize>,
) -> Option<Self>
pub fn new_surface_with_dimensions( &mut self, dim: impl Into<ISize>, ) -> Option<Self>
Calls Self::new_surface()
with the same ImageInfo
as this surface, but with the
specified width and height.
Sourcepub fn image_snapshot(&mut self) -> Image
pub fn image_snapshot(&mut self) -> Image
Returns Image
capturing Surface
contents. Subsequent drawing to Surface
contents
are not captured. Image
allocation is accounted for if Surface
was created with
gpu::Budgeted::Yes
.
Returns: Image
initialized with Surface
contents
example: https://fiddle.skia.org/c/@Surface_makeImageSnapshot
Sourcepub fn image_snapshot_with_bounds(
&mut self,
bounds: impl AsRef<IRect>,
) -> Option<Image>
pub fn image_snapshot_with_bounds( &mut self, bounds: impl AsRef<IRect>, ) -> Option<Image>
Like the no-parameter version, this returns an image of the current surface contents. This variant takes a rectangle specifying the subset of the surface that is of interest. These bounds will be sanitized before being used.
- If bounds extends beyond the surface, it will be trimmed to just the intersection of it and the surface.
- If bounds does not intersect the surface, then this returns
None
. - If bounds == the surface, then this is the same as calling the no-parameter variant.
example: https://fiddle.skia.org/c/@Surface_makeImageSnapshot_2
Sourcepub fn draw(
&mut self,
canvas: &Canvas,
offset: impl Into<Point>,
sampling: impl Into<SamplingOptions>,
paint: Option<&Paint>,
)
pub fn draw( &mut self, canvas: &Canvas, offset: impl Into<Point>, sampling: impl Into<SamplingOptions>, paint: Option<&Paint>, )
Draws Surface
contents to canvas, with its top-left corner at (offset.x, offset.y)
.
If Paint
paint is not None
, apply crate::ColorFilter
, alpha, crate::ImageFilter
, and crate::BlendMode
.
canvas
-Canvas
drawn intooffset.x
- horizontal offset inCanvas
offset.y
- vertical offset inCanvas
sampling
- what technique to use when sampling the surface pixelspaint
-Paint
containingcrate::BlendMode
,crate::ColorFilter
,crate::ImageFilter
, and so on; orNone
pub fn peek_pixels(&mut self) -> Option<Pixmap<'_>>
Sourcepub fn read_pixels_to_pixmap(
&mut self,
dst: &Pixmap<'_>,
src: impl Into<IPoint>,
) -> bool
pub fn read_pixels_to_pixmap( &mut self, dst: &Pixmap<'_>, src: impl Into<IPoint>, ) -> bool
Copies crate::Rect
of pixels to dst.
Source crate::Rect
corners are (src.x
, src.y
) and Surface
(width(), height())
.
Destination crate::Rect
corners are (0, 0)
and (dst.width(), dst.height())
.
Copies each readable pixel intersecting both rectangles, without scaling,
converting to dst_color_type()
and dst_alpha_type()
if required.
Pixels are readable when Surface
is raster, or backed by a Ganesh GPU backend. Graphite
has deprecated this API in favor of the equivalent asynchronous API on
skgpu::graphite::Context
(with an optional explicit synchonization).
The destination pixel storage must be allocated by the caller.
Pixel values are converted only if crate::ColorType
and crate::AlphaType
do not match. Only pixels within both source and destination rectangles
are copied. dst contents outside crate::Rect
intersection are unchanged.
Pass negative values for src.x
or src.y
to offset pixels across or down destination.
Does not copy, and returns false
if:
- Source and destination rectangles do not intersect.
Pixmap
pixels could not be allocated.dst.row_bytes()
is too small to contain one row of pixels.
dst
- storage for pixels copied fromSurface
src_x
- offset into readable pixels on x-axis; may be negativesrc_y
- offset into readable pixels on y-axis; may be negative
Returns: true
if pixels were copied
Sourcepub fn read_pixels(
&mut self,
dst_info: &ImageInfo,
dst_pixels: &mut [u8],
dst_row_bytes: usize,
src: impl Into<IPoint>,
) -> bool
pub fn read_pixels( &mut self, dst_info: &ImageInfo, dst_pixels: &mut [u8], dst_row_bytes: usize, src: impl Into<IPoint>, ) -> bool
Copies crate::Rect
of pixels from Canvas
into dst_pixels
.
Source crate::Rect
corners are (src.x
, src.y
) and Surface
(width(), height()).
Destination crate::Rect
corners are (0, 0) and (dst_info
.width(), dst_info
.height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to dst_info_color_type()
and dst_info_alpha_type()
if required.
Pixels are readable when Surface
is raster, or backed by a Ganesh GPU backend. Graphite
has deprecated this API in favor of the equivalent asynchronous API on
skgpu::graphite::Context
(with an optional explicit synchonization).
The destination pixel storage must be allocated by the caller.
Pixel values are converted only if crate::ColorType
and crate::AlphaType
do not match. Only pixels within both source and destination rectangles
are copied. dst_pixels
contents outside crate::Rect
intersection are unchanged.
Pass negative values for src.x
or src.y
to offset pixels across or down destination.
Does not copy, and returns false
if:
- Source and destination rectangles do not intersect.
Surface
pixels could not be converted todst_info.color_type()
ordst_info.alpha_type()
.dst_row_bytes
is too small to contain one row of pixels.
dst_info
- width, height,crate::ColorType
, andcrate::AlphaType
ofdst_pixels
dst_pixels
- storage for pixels;dst_info.height()
timesdst_row_bytes
, or largerdst_row_bytes
- size of one destination row;dst_info.width()
times pixel size, or largersrc.x
- offset into readable pixels on x-axis; may be negativesrc.y
- offset into readable pixels on y-axis; may be negative
Returns: true
if pixels were copied
Sourcepub fn read_pixels_to_bitmap(
&mut self,
bitmap: &Bitmap,
src: impl Into<IPoint>,
) -> bool
pub fn read_pixels_to_bitmap( &mut self, bitmap: &Bitmap, src: impl Into<IPoint>, ) -> bool
Copies crate::Rect
of pixels from Surface
into bitmap.
Source crate::Rect
corners are (src.x
, src.y
) and Surface
(width(), height()).
Destination crate::Rect
corners are (0, 0)
and (bitmap.width(), bitmap.height())
.
Copies each readable pixel intersecting both rectangles, without scaling,
converting to bitmap.color_type()
and bitmap.alpha_type()
if required.
Pixels are readable when Surface
is raster, or backed by a Ganesh GPU backend. Graphite
has deprecated this API in favor of the equivalent asynchronous API on
skgpu::graphite::Context
(with an optional explicit synchonization).
The destination pixel storage must be allocated by the caller.
Pixel values are converted only if crate::ColorType
and crate::AlphaType
do not match. Only pixels within both source and destination rectangles
are copied. dst contents outside crate::Rect
intersection are unchanged.
Pass negative values for src.x
or src.y
to offset pixels across or down destination.
Does not copy, and returns false
if:
- Source and destination rectangles do not intersect.
Surface
pixels could not be converted todst.color_type()
ordst.alpha_type()
.- dst pixels could not be allocated.
dst.row_bytes()
is too small to contain one row of pixels.
dst
- storage for pixels copied fromSurface
src.x
- offset into readable pixels on x-axis; may be negativesrc.y
- offset into readable pixels on y-axis; may be negative
Returns: true
if pixels were copied
Sourcepub fn write_pixels_from_pixmap(
&mut self,
src: &Pixmap<'_>,
dst: impl Into<IPoint>,
)
pub fn write_pixels_from_pixmap( &mut self, src: &Pixmap<'_>, dst: impl Into<IPoint>, )
Copies crate::Rect
of pixels from the src Pixmap
to the Surface
.
Source crate::Rect
corners are (0, 0)
and (src.width(), src.height())
.
Destination crate::Rect
corners are (
dst.x,
dst.y)
and
(dst.x
+ Surface width(), dst.y
+ Surface height()).
Copies each readable pixel intersecting both rectangles, without scaling,
converting to Surface
color_type()
and Surface
alpha_type()
if required.
Sourcepub fn write_pixels_from_bitmap(
&mut self,
bitmap: &Bitmap,
dst: impl Into<IPoint>,
)
pub fn write_pixels_from_bitmap( &mut self, bitmap: &Bitmap, dst: impl Into<IPoint>, )
Copies crate::Rect
of pixels from the src Bitmap
to the Surface
.
Source crate::Rect
corners are (0, 0)
and (src.width(), src.height())
.
Destination crate::Rect
corners are (
dst.x,
dst.y)
and
(
dst.x+ Surface width(),
dst.y + Surface height())
.
Copies each readable pixel intersecting both rectangles, without scaling,
converting to Surface
color_type()
and Surface
alpha_type()
if required.
Sourcepub fn props(&self) -> &SurfaceProps
pub fn props(&self) -> &SurfaceProps
Returns SurfaceProps
for surface.
Returns: LCD striping orientation and setting for device independent fonts
Source§impl RCHandle<SkSurface>
impl RCHandle<SkSurface>
Sourcepub fn resolve_msaa(&mut self)
👎Deprecated since 0.65.0: Use gpu::surfaces::resolve_msaa
pub fn resolve_msaa(&mut self)
If a surface is GPU texture backed, is being drawn with MSAA, and there is a resolve
texture, this call will insert a resolve command into the stream of gpu commands. In order
for the resolve to actually have an effect, the work still needs to be flushed and submitted
to the GPU after recording the resolve command. If a resolve is not supported or the
Surface
has no dirty work to resolve, then this call is a no-op.
This call is most useful when the Surface
is created by wrapping a single sampled gpu
texture, but asking Skia to render with MSAA. If the client wants to use the wrapped texture
outside of Skia, the only way to trigger a resolve is either to call this command or use
Self::flush()
.
Source§impl RCHandle<SkTextBlob>
impl RCHandle<SkTextBlob>
pub fn new(str: impl AsRef<str>, font: &Font) -> Option<Self>
pub fn bounds(&self) -> &Rect
pub fn unique_id(&self) -> u32
pub fn get_intercepts( &self, bounds: [scalar; 2], paint: Option<&Paint>, ) -> Vec<scalar>
pub fn from_str(str: impl AsRef<str>, font: &Font) -> Option<TextBlob>
pub fn from_text(text: impl EncodedText, font: &Font) -> Option<TextBlob>
pub fn from_pos_text_h( text: impl EncodedText, x_pos: &[scalar], const_y: scalar, font: &Font, ) -> Option<TextBlob>
pub fn from_pos_text( text: impl EncodedText, pos: &[Point], font: &Font, ) -> Option<TextBlob>
pub fn from_rsxform( text: impl EncodedText, xform: &[RSXform], font: &Font, ) -> Option<TextBlob>
Source§impl RCHandle<SkTypeface>
impl RCHandle<SkTypeface>
pub fn font_style(&self) -> FontStyle
pub fn is_bold(&self) -> bool
pub fn is_italic(&self) -> bool
pub fn is_fixed_pitch(&self) -> bool
pub fn variation_design_position(&self) -> Option<Vec<Coordinate>>
pub fn variation_design_parameters(&self) -> Option<Vec<VariationAxis>>
pub fn unique_id(&self) -> TypefaceId
pub fn equal(face_a: impl AsRef<Typeface>, face_b: impl AsRef<Typeface>) -> bool
pub fn clone_with_arguments( &self, arguments: &FontArguments<'_, '_>, ) -> Option<Typeface>
pub fn serialize_stream(&self, write: impl Write, behavior: SerializeBehavior)
pub fn serialize(&self, behavior: SerializeBehavior) -> Data
pub fn make_deserialize( data: impl Read, last_resort_mgr: impl Into<Option<FontMgr>>, ) -> Option<Typeface>
pub fn unichars_to_glyphs(&self, uni: &[Unichar], glyphs: &mut [GlyphId])
pub fn str_to_glyphs( &self, str: impl AsRef<str>, glyphs: &mut [GlyphId], ) -> usize
pub fn text_to_glyphs( &self, text: impl EncodedText, glyphs: &mut [GlyphId], ) -> usize
pub fn unichar_to_glyph(&self, unichar: Unichar) -> GlyphId
pub fn count_glyphs(&self) -> usize
pub fn count_tables(&self) -> usize
pub fn get_table_size(&self, tag: FontTableTag) -> Option<usize>
pub fn get_table_data(&self, tag: FontTableTag, data: &mut [u8]) -> usize
pub fn copy_table_data(&self, tag: FontTableTag) -> Option<Data>
pub fn units_per_em(&self) -> Option<i32>
pub fn get_kerning_pair_adjustments( &self, glyphs: &[GlyphId], adjustments: &mut [i32], ) -> bool
pub fn new_family_name_iterator(&self) -> impl Iterator<Item = LocalizedString>
pub fn family_name(&self) -> String
pub fn post_script_name(&self) -> Option<String>
pub fn to_font_data(&self) -> Option<(Vec<u8>, usize)>
pub fn bounds(&self) -> Rect
Source§impl RCHandle<SkVertices>
impl RCHandle<SkVertices>
pub const MAX_CUSTOM_ATTRIBUTES: usize = 8usize
pub fn new_copy( mode: VertexMode, positions: &[Point], texs: &[Point], colors: &[Color], indices: Option<&[u16]>, ) -> Vertices
pub fn unique_id(&self) -> u32
pub fn mode(&self) -> VertexMode
pub fn bounds(&self) -> &Rect
pub fn has_colors(&self) -> bool
pub fn has_tex_coords(&self) -> bool
pub fn has_bones(&self) -> bool
pub fn has_indices(&self) -> bool
pub fn vertex_count(&self) -> usize
pub fn index_count(&self) -> usize
pub fn positions(&self) -> &[Point]
pub fn tex_coords(&self) -> Option<&[Point]>
pub fn colors(&self) -> Option<&[Color]>
pub fn bone_indices(&self) -> Option<&[BoneIndices]>
pub fn bone_weights(&self) -> Option<&[BoneWeights]>
pub fn indices(&self) -> Option<&[u16]>
pub fn is_volatile(&self) -> bool
pub fn apply_bones(&self, _bones: &[Bone]) -> !
pub fn approximate_size(&self) -> usize
pub fn decode(_buffer: &[u8]) -> !
pub fn encode(&self) -> !
Source§impl RCHandle<SkShader>
impl RCHandle<SkShader>
pub fn fractal_perlin_noise( base_frequency: (scalar, scalar), num_octaves: usize, seed: scalar, tile_size: impl Into<Option<ISize>>, ) -> Option<Self>
pub fn turbulence_perlin_noise( base_frequency: (scalar, scalar), num_octaves: usize, seed: scalar, tile_size: impl Into<Option<ISize>>, ) -> Option<Self>
Source§impl RCHandle<SkShader>
impl RCHandle<SkShader>
pub fn linear_gradient<'a>( points: (impl Into<Point>, impl Into<Point>), colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>
pub fn linear_gradient_with_interpolation<'a>( points: (impl Into<Point>, impl Into<Point>), colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>
pub fn radial_gradient<'a>( center: impl Into<Point>, radius: scalar, colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>
pub fn radial_gradient_with_interpolation<'a>( center_and_radius: (impl Into<Point>, scalar), colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>
pub fn two_point_conical_gradient<'a>( start: impl Into<Point>, start_radius: scalar, end: impl Into<Point>, end_radius: scalar, colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>
pub fn two_point_conical_gradient_with_interpolation<'a>( start_and_radius: (impl Into<Point>, scalar), end_and_radius: (impl Into<Point>, scalar), colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>
pub fn sweep_gradient<'a>( center: impl Into<Point>, colors: impl Into<GradientShaderColors<'a>>, pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, angles: impl Into<Option<(scalar, scalar)>>, flags: impl Into<Option<Flags>>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Self>
pub fn sweep_gradient_with_interpolation<'a>( center: impl Into<Point>, colors: (&[Color4f], impl Into<Option<ColorSpace>>), pos: impl Into<Option<&'a [scalar]>>, mode: TileMode, angles: impl Into<Option<(scalar, scalar)>>, interpolation: impl Into<Interpolation>, local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>
Source§impl RCHandle<SkColorFilter>
impl RCHandle<SkColorFilter>
pub fn high_contrast(config: &HighContrastConfig) -> Option<Self>
Source§impl RCHandle<SkImageFilter>
impl RCHandle<SkImageFilter>
Sourcepub fn arithmetic<'a>(
inputs: impl Into<ArithmeticFPInputs>,
background: impl Into<Option<Self>>,
foreground: impl Into<Option<Self>>,
crop_rect: impl Into<Option<&'a IRect>>,
) -> Option<Self>
pub fn arithmetic<'a>( inputs: impl Into<ArithmeticFPInputs>, background: impl Into<Option<Self>>, foreground: impl Into<Option<Self>>, crop_rect: impl Into<Option<&'a IRect>>, ) -> Option<Self>
Sourcepub fn blur<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
sigma: (scalar, scalar),
tile_mode: impl Into<Option<TileMode>>,
) -> Option<Self>
pub fn blur<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, sigma: (scalar, scalar), tile_mode: impl Into<Option<TileMode>>, ) -> Option<Self>
Sourcepub fn color_filter<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
cf: impl Into<ColorFilter>,
) -> Option<Self>
pub fn color_filter<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, cf: impl Into<ColorFilter>, ) -> Option<Self>
Sourcepub fn compose(
outer: impl Into<ImageFilter>,
inner: impl Into<ImageFilter>,
) -> Option<Self>
pub fn compose( outer: impl Into<ImageFilter>, inner: impl Into<ImageFilter>, ) -> Option<Self>
Sourcepub fn crop(
rect: impl AsRef<Rect>,
tile_mode: impl Into<Option<TileMode>>,
input: impl Into<Option<ImageFilter>>,
) -> Option<ImageFilter>
pub fn crop( rect: impl AsRef<Rect>, tile_mode: impl Into<Option<TileMode>>, input: impl Into<Option<ImageFilter>>, ) -> Option<ImageFilter>
Sourcepub fn displacement_map_effect<'a>(
channel_selectors: (ColorChannel, ColorChannel),
scale: scalar,
displacement: impl Into<Option<ImageFilter>>,
color: impl Into<Option<ImageFilter>>,
crop_rect: impl Into<Option<&'a IRect>>,
) -> Option<Self>
pub fn displacement_map_effect<'a>( channel_selectors: (ColorChannel, ColorChannel), scale: scalar, displacement: impl Into<Option<ImageFilter>>, color: impl Into<Option<ImageFilter>>, crop_rect: impl Into<Option<&'a IRect>>, ) -> Option<Self>
Sourcepub fn distant_lit_diffuse_lighting<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
direction: impl Into<Point3>,
light_color: impl Into<Color>,
surface_scale: scalar,
kd: scalar,
) -> Option<Self>
pub fn distant_lit_diffuse_lighting<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, direction: impl Into<Point3>, light_color: impl Into<Color>, surface_scale: scalar, kd: scalar, ) -> Option<Self>
Sourcepub fn point_lit_diffuse_lighting<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
location: impl Into<Point3>,
light_color: impl Into<Color>,
surface_scale: scalar,
kd: scalar,
) -> Option<Self>
pub fn point_lit_diffuse_lighting<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, location: impl Into<Point3>, light_color: impl Into<Color>, surface_scale: scalar, kd: scalar, ) -> Option<Self>
Sourcepub fn spot_lit_diffuse_lighting<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
location: impl Into<Point3>,
target: impl Into<Point3>,
specular_exponent: scalar,
cutoff_angle: scalar,
light_color: impl Into<Color>,
surface_scale: scalar,
kd: scalar,
) -> Option<Self>
pub fn spot_lit_diffuse_lighting<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, location: impl Into<Point3>, target: impl Into<Point3>, specular_exponent: scalar, cutoff_angle: scalar, light_color: impl Into<Color>, surface_scale: scalar, kd: scalar, ) -> Option<Self>
Sourcepub fn distant_lit_specular_lighting<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
direction: impl Into<Point3>,
light_color: impl Into<Color>,
surface_scale: scalar,
ks: scalar,
shininess: scalar,
) -> Option<Self>
pub fn distant_lit_specular_lighting<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, direction: impl Into<Point3>, light_color: impl Into<Color>, surface_scale: scalar, ks: scalar, shininess: scalar, ) -> Option<Self>
Sourcepub fn point_lit_specular_lighting<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
location: impl Into<Point3>,
light_color: impl Into<Color>,
surface_scale: scalar,
ks: scalar,
shininess: scalar,
) -> Option<Self>
pub fn point_lit_specular_lighting<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, location: impl Into<Point3>, light_color: impl Into<Color>, surface_scale: scalar, ks: scalar, shininess: scalar, ) -> Option<Self>
Sourcepub fn spot_lit_specular_lighting<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
location: impl Into<Point3>,
target: impl Into<Point3>,
specular_exponent: scalar,
cutoff_angle: scalar,
light_color: impl Into<Color>,
surface_scale: scalar,
ks: scalar,
shininess: scalar,
) -> Option<Self>
pub fn spot_lit_specular_lighting<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, location: impl Into<Point3>, target: impl Into<Point3>, specular_exponent: scalar, cutoff_angle: scalar, light_color: impl Into<Color>, surface_scale: scalar, ks: scalar, shininess: scalar, ) -> Option<Self>
Sourcepub fn magnifier<'a>(
self,
lens_bounds: impl AsRef<Rect>,
zoom_amount: scalar,
inset: scalar,
sampling_options: SamplingOptions,
crop_rect: impl Into<Option<&'a IRect>>,
) -> Option<Self>
pub fn magnifier<'a>( self, lens_bounds: impl AsRef<Rect>, zoom_amount: scalar, inset: scalar, sampling_options: SamplingOptions, crop_rect: impl Into<Option<&'a IRect>>, ) -> Option<Self>
Sourcepub fn matrix_convolution<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
kernel_size: impl Into<ISize>,
kernel: &[scalar],
gain: scalar,
bias: scalar,
kernel_offset: impl Into<IPoint>,
tile_mode: TileMode,
convolve_alpha: bool,
) -> Option<Self>
pub fn matrix_convolution<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, kernel_size: impl Into<ISize>, kernel: &[scalar], gain: scalar, bias: scalar, kernel_offset: impl Into<IPoint>, tile_mode: TileMode, convolve_alpha: bool, ) -> Option<Self>
Sourcepub fn merge<'a>(
filters: impl IntoIterator<Item = Option<Self>>,
crop_rect: impl Into<Option<&'a IRect>>,
) -> Option<Self>
pub fn merge<'a>( filters: impl IntoIterator<Item = Option<Self>>, crop_rect: impl Into<Option<&'a IRect>>, ) -> Option<Self>
Sourcepub fn dilate<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
radii: (scalar, scalar),
) -> Option<Self>
pub fn dilate<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, radii: (scalar, scalar), ) -> Option<Self>
Sourcepub fn erode<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
radii: (scalar, scalar),
) -> Option<Self>
pub fn erode<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, radii: (scalar, scalar), ) -> Option<Self>
Sourcepub fn offset<'a>(
self,
crop_rect: impl Into<Option<&'a IRect>>,
delta: impl Into<Vector>,
) -> Option<Self>
pub fn offset<'a>( self, crop_rect: impl Into<Option<&'a IRect>>, delta: impl Into<Vector>, ) -> Option<Self>
Source§impl RCHandle<SkPicture>
impl RCHandle<SkPicture>
pub fn as_image_filter<'a>( &self, crop_rect: impl Into<Option<&'a Rect>>, ) -> Option<ImageFilter>
pub fn into_image_filter<'a>( self, crop_rect: impl Into<Option<&'a Rect>>, ) -> Option<ImageFilter>
Source§impl RCHandle<SkRuntimeEffect>
impl RCHandle<SkRuntimeEffect>
pub fn make_for_color_filer<'a>( sksl: impl AsRef<str>, options: impl Into<Option<&'a Options>>, ) -> Result<RuntimeEffect, String>
pub fn make_for_shader<'a>( sksl: impl AsRef<str>, options: impl Into<Option<&'a Options>>, ) -> Result<RuntimeEffect, String>
pub fn make_for_blender<'a>( sksl: impl AsRef<str>, options: impl Into<Option<&'a Options>>, ) -> Result<RuntimeEffect, String>
pub fn make_shader<'a>( &self, uniforms: impl Into<Data>, children: &[ChildPtr], local_matrix: impl Into<Option<&'a Matrix>>, ) -> Option<Shader>
pub fn make_color_filter<'a>( &self, inputs: impl Into<Data>, children: impl Into<Option<&'a [ChildPtr]>>, ) -> Option<ColorFilter>
pub fn make_blender<'a>( &self, uniforms: impl Into<Data>, children: impl Into<Option<&'a [ChildPtr]>>, ) -> Option<Blender>
pub fn source(&self) -> &str
pub fn input_size(&self) -> usize
pub fn uniform_size(&self) -> usize
pub fn inputs(&self) -> &[Uniform]
pub fn uniforms(&self) -> &[Uniform]
pub fn children(&self) -> &[Child]
pub fn find_input(&self, name: impl AsRef<str>) -> Option<&Uniform>
pub fn find_uniform(&self, name: impl AsRef<str>) -> Option<&Uniform>
pub fn find_child(&self, name: impl AsRef<str>) -> Option<&Child>
pub fn allow_shader(&self) -> bool
pub fn allow_color_filter(&self) -> bool
pub fn allow_blender(&self) -> bool
Source§impl RCHandle<SkMaskFilter>
impl RCHandle<SkMaskFilter>
pub fn from_shader(shader: impl Into<Shader>) -> MaskFilter
Source§impl RCHandle<SkColorFilter>
impl RCHandle<SkColorFilter>
pub fn from_table(table: &[u8; 256]) -> Self
pub fn from_argb( table_a: Option<&[u8; 256]>, table_r: Option<&[u8; 256]>, table_g: Option<&[u8; 256]>, table_b: Option<&[u8; 256]>, ) -> Self
Source§impl RCHandle<SkMaskFilter>
impl RCHandle<SkMaskFilter>
pub fn table(table: &[u8; 256]) -> MaskFilter
pub fn gamma(gamma: scalar) -> MaskFilter
pub fn clip(min: u8, max: u8) -> MaskFilter
Source§impl RCHandle<GrDirectContext>
impl RCHandle<GrDirectContext>
pub fn new_gl<'a>( interface: impl Into<Interface>, options: impl Into<Option<&'a ContextOptions>>, ) -> Option<DirectContext>
pub fn new_vulkan<'a>( backend_context: &BackendContext<'_>, options: impl Into<Option<&'a ContextOptions>>, ) -> Option<DirectContext>
pub fn new_metal<'a>( backend_context: &BackendContext, options: impl Into<Option<&'a ContextOptions>>, ) -> Option<DirectContext>
pub fn reset(&mut self, backend_state: Option<u32>) -> &mut Self
pub fn reset_gl_texture_bindings(&mut self) -> &mut Self
pub fn abandon(&mut self) -> &mut Self
pub fn is_device_lost(&mut self) -> bool
pub fn oomed(&mut self) -> bool
pub fn release_resources_and_abandon(&mut self) -> &mut Self
pub fn resource_cache_limit(&self) -> usize
pub fn resource_cache_usage(&self) -> ResourceCacheUsage
pub fn resource_cache_purgeable_bytes(&self) -> usize
pub fn set_resource_cache_limits(&mut self, limits: ResourceCacheLimits)
pub fn set_resource_cache_limit(&mut self, max_resource_bytes: usize)
pub fn free_gpu_resources(&mut self) -> &mut Self
pub fn perform_deferred_cleanup( &mut self, not_used: Duration, opts: impl Into<Option<PurgeResourceOptions>>, ) -> &mut Self
pub fn purge_unlocked_resource_bytes( &mut self, bytes_to_purge: usize, prefer_scratch_resources: bool, ) -> &mut Self
pub fn purge_unlocked_resources( &mut self, opts: PurgeResourceOptions, ) -> &mut Self
pub fn flush_and_submit(&mut self) -> &mut Self
pub fn flush_submit_and_sync_cpu(&mut self) -> &mut Self
pub fn flush_with_info(&mut self, info: &FlushInfo) -> SemaphoresSubmitted
pub fn flush<'a>( &mut self, info: impl Into<Option<&'a FlushInfo>>, ) -> SemaphoresSubmitted
pub fn flush_image_with_info( &mut self, image: &Image, info: &FlushInfo, ) -> SemaphoresSubmitted
pub fn flush_image(&mut self, image: &Image)
pub fn flush_and_submit_image(&mut self, image: &Image)
pub fn flush_surface_with_access( &mut self, surface: &mut Surface, access: BackendSurfaceAccess, info: &FlushInfo, ) -> SemaphoresSubmitted
pub fn flush_surface_with_texture_state( &mut self, surface: &mut Surface, info: &FlushInfo, new_state: Option<&MutableTextureState>, ) -> SemaphoresSubmitted
pub fn flush_and_submit_surface( &mut self, surface: &mut Surface, sync_cpu: impl Into<Option<SyncCpu>>, )
pub fn flush_surface(&mut self, surface: &mut Surface)
pub fn submit(&mut self, submit_info: impl Into<SubmitInfo>) -> bool
pub fn check_async_work_completion(&mut self)
pub fn supports_distance_field_text(&self) -> bool
pub fn store_vk_pipeline_cache_data(&mut self) -> &mut Self
pub fn compressed_backend_format( &self, compression: TextureCompressionType, ) -> BackendFormat
pub fn set_backend_texture_state( &mut self, backend_texture: &BackendTexture, state: &MutableTextureState, ) -> bool
pub fn set_backend_texture_state_and_return_previous( &mut self, backend_texture: &BackendTexture, state: &MutableTextureState, ) -> Option<MutableTextureState>
pub fn set_backend_render_target_state( &mut self, target: &BackendRenderTarget, state: &MutableTextureState, ) -> bool
pub fn set_backend_render_target_state_and_return_previous( &mut self, target: &BackendRenderTarget, state: &MutableTextureState, ) -> Option<MutableTextureState>
pub fn delete_backend_texture(&mut self, texture: &BackendTexture)
pub fn precompile_shader(&mut self, key: &Data, data: &Data) -> bool
pub fn id(&self) -> DirectContextId
Source§impl RCHandle<GrGLInterface>
impl RCHandle<GrGLInterface>
pub fn new_native() -> Option<Self>
pub fn new_load_with<F>(load_fn: F) -> Option<Self>
pub fn new_load_with_cstr<F>(load_fn: F) -> Option<Self>
pub fn validate(&self) -> bool
pub fn extensions(&self) -> &Extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
pub fn has_extension(&self, extension: impl AsRef<str>) -> bool
Source§impl RCHandle<GrRecordingContext>
impl RCHandle<GrRecordingContext>
pub fn as_direct_context(&mut self) -> Option<DirectContext>
pub fn backend(&self) -> BackendAPI
pub fn default_backend_format( &self, ct: ColorType, renderable: Renderable, ) -> BackendFormat
pub fn compressed_backend_format( &self, compression_type: TextureCompressionType, ) -> BackendFormat
pub fn abandoned(&mut self) -> bool
pub fn color_type_supported_as_surface(&self, color_type: ColorType) -> bool
pub fn max_texture_size(&self) -> i32
pub fn max_render_target_size(&self) -> i32
pub fn color_type_supported_as_image(&self, color_type: ColorType) -> bool
pub fn supports_protected_content(&self) -> bool
pub fn max_surface_sample_count_for_color_type( &self, color_type: ColorType, ) -> usize
Source§impl RCHandle<skgpu_MutableTextureState>
impl RCHandle<skgpu_MutableTextureState>
pub fn copied(&self) -> Self
pub fn new_vk(layout: ImageLayout, queue_family_index: u32) -> Self
pub fn vk_image_layout(&self) -> VkImageLayout
pub fn queue_family_index(&self) -> u32
pub fn backend(&self) -> BackendApi
Source§impl RCHandle<skia_textlayout_FontCollection>
impl RCHandle<skia_textlayout_FontCollection>
pub fn new() -> Self
pub fn font_managers_count(&self) -> usize
pub fn set_asset_font_manager( &mut self, font_manager: impl Into<Option<FontMgr>>, )
pub fn set_dynamic_font_manager( &mut self, font_manager: impl Into<Option<FontMgr>>, )
pub fn set_test_font_manager( &mut self, font_manager: impl Into<Option<FontMgr>>, )
pub fn set_default_font_manager<'a>( &mut self, font_manager: impl Into<Option<FontMgr>>, default_family_name: impl Into<Option<&'a str>>, )
pub fn set_default_font_manager_and_family_names( &mut self, font_manager: impl Into<Option<FontMgr>>, family_names: &[impl AsRef<str>], )
pub fn fallback_manager(&self) -> Option<FontMgr>
pub fn find_typefaces( &mut self, family_names: &[impl AsRef<str>], font_style: FontStyle, ) -> Vec<Typeface>
pub fn find_typefaces_with_font_arguments<'fa>( &mut self, family_names: &[impl AsRef<str>], font_style: FontStyle, font_args: impl Into<Option<&'fa FontArguments>>, ) -> Vec<Typeface>
pub fn default_fallback_char( &mut self, unicode: Unichar, font_style: FontStyle, locale: impl AsRef<str>, ) -> Option<Typeface>
pub fn default_fallback(&mut self) -> Option<Typeface>
pub fn default_emoji_fallback( &mut self, emoji_start: Unichar, font_style: FontStyle, locale: impl AsRef<str>, ) -> Option<Typeface>
pub fn disable_font_fallback(&mut self)
pub fn enable_font_fallback(&mut self)
pub fn font_fallback_enabled(&self) -> bool
pub fn paragraph_cache(&self) -> &ParagraphCache
pub fn paragraph_cache_mut(&mut self) -> &mut ParagraphCache
pub fn clear_caches(&mut self)
Source§impl RCHandle<SkSVGClipPath>
impl RCHandle<SkSVGClipPath>
pub fn clip_path_units(&self) -> &BoundingBoxUnits
pub fn set_clip_path_units(&mut self, value: BoundingBoxUnits)
Source§impl RCHandle<SkSVGFeColorMatrix>
impl RCHandle<SkSVGFeColorMatrix>
pub fn kind(&self) -> &ColorMatrixKind
pub fn set_kind(&mut self, value: ColorMatrixKind)
pub fn values(&self) -> &[scalar]
Source§impl RCHandle<SkSVGFeFunc>
impl RCHandle<SkSVGFeFunc>
pub fn func_a() -> Self
pub fn func_r() -> Self
pub fn func_g() -> Self
pub fn func_b() -> Self
pub fn table_values(&self) -> &[scalar]
pub fn amplitude(&self) -> scalar
pub fn set_amplitude(&mut self, value: scalar)
pub fn exponent(&self) -> scalar
pub fn set_exponent(&mut self, value: scalar)
pub fn intercept(&self) -> scalar
pub fn set_intercept(&mut self, value: scalar)
pub fn offset(&self) -> scalar
pub fn set_offset(&mut self, value: scalar)
pub fn slope(&self) -> scalar
pub fn set_slope(&mut self, value: scalar)
pub fn kind(&self) -> &FuncKind
pub fn set_kind(&mut self, value: FuncKind)
Source§impl RCHandle<SkSVGFeComposite>
impl RCHandle<SkSVGFeComposite>
pub fn input2(&self) -> &Input
pub fn set_input2(&mut self, value: Input)
pub fn k1(&self) -> scalar
pub fn set_k1(&mut self, value: scalar)
pub fn k2(&self) -> scalar
pub fn set_k2(&mut self, value: scalar)
pub fn k3(&self) -> scalar
pub fn set_k3(&mut self, value: scalar)
pub fn k4(&self) -> scalar
pub fn set_k4(&mut self, value: scalar)
pub fn operator(&self) -> &CompositeOperator
pub fn set_operator(&mut self, value: CompositeOperator)
Source§impl RCHandle<SkSVGFeDisplacementMap>
impl RCHandle<SkSVGFeDisplacementMap>
pub fn input2(&self) -> &Input
pub fn set_input2(&mut self, value: Input)
pub fn x_channel_selector(&self) -> &ChannelSelector
pub fn set_x_channel_selector(&mut self, value: ChannelSelector)
pub fn y_channel_selector(&self) -> &ChannelSelector
pub fn set_y_channel_selector(&mut self, value: ChannelSelector)
pub fn scale(&self) -> &scalar
pub fn set_scale(&mut self, value: scalar)
Source§impl RCHandle<SkSVGFeGaussianBlur>
impl RCHandle<SkSVGFeGaussianBlur>
pub fn std_deviation(&self) -> &StdDeviation
pub fn set_std_deviation(&mut self, value: StdDeviation)
Source§impl RCHandle<SkSVGFeImage>
impl RCHandle<SkSVGFeImage>
pub fn href(&self) -> &Iri
pub fn set_href(&mut self, value: Iri)
pub fn preserve_aspect_ratio(&self) -> &PreserveAspectRatio
pub fn set_preserve_aspect_ratio(&mut self, value: PreserveAspectRatio)
Source§impl RCHandle<SkSVGFeSpotLight>
impl RCHandle<SkSVGFeSpotLight>
pub fn x(&self) -> scalar
pub fn set_x(&mut self, value: scalar)
pub fn y(&self) -> scalar
pub fn set_y(&mut self, value: scalar)
pub fn z(&self) -> scalar
pub fn set_z(&mut self, value: scalar)
pub fn points_at_x(&self) -> scalar
pub fn set_points_at_x(&mut self, value: scalar)
pub fn points_at_y(&self) -> scalar
pub fn set_points_at_y(&mut self, value: scalar)
pub fn points_at_z(&self) -> scalar
pub fn set_points_at_z(&mut self, value: scalar)
pub fn specular_exponent(&self) -> scalar
pub fn set_specular_exponent(&mut self, value: scalar)
pub fn limiting_cone_angle(&self) -> Option<scalar>
pub fn set_limiting_cone_angle(&mut self, value: scalar)
Source§impl RCHandle<SkSVGFeLighting>
impl RCHandle<SkSVGFeLighting>
pub fn surface_scale(&self) -> scalar
pub fn set_surface_scale(&mut self, value: scalar)
pub fn kernel_unit_length(&self) -> Option<KernelUnitLength>
pub fn set_kernel_unit_length(&mut self, value: KernelUnitLength)
Source§impl RCHandle<SkSVGFeSpecularLighting>
impl RCHandle<SkSVGFeSpecularLighting>
pub fn specular_constant(&self) -> scalar
pub fn set_specular_constant(&mut self, value: scalar)
pub fn specular_exponent(&self) -> scalar
pub fn set_specular_exponent(&mut self, value: scalar)
Source§impl RCHandle<SkSVGFeDiffuseLighting>
impl RCHandle<SkSVGFeDiffuseLighting>
pub fn diffuse_constant(&self) -> scalar
pub fn set_diffuse_constant(&mut self, value: scalar)
Source§impl RCHandle<SkSVGFeTurbulence>
impl RCHandle<SkSVGFeTurbulence>
pub fn base_frequency(&self) -> &TurbulenceBaseFrequency
pub fn set_base_frequency(&mut self, value: TurbulenceBaseFrequency)
pub fn num_octaves(&self) -> i32
pub fn set_num_octaves(&mut self, value: i32)
pub fn seed(&self) -> scalar
pub fn set_seed(&mut self, value: scalar)
pub fn turbulence_type(&self) -> &TurbulenceType
pub fn set_turbulence_type(&mut self, value: TurbulenceType)
Source§impl RCHandle<SkSVGFe>
impl RCHandle<SkSVGFe>
pub fn input(&self) -> &Input
pub fn set_input(&mut self, value: Input)
pub fn result(&self) -> &Handle<SkString>
pub fn set_result(&mut self, value: Handle<SkString>)
pub fn x(&self) -> Option<&Length>
pub fn set_x(&mut self, value: Length)
pub fn y(&self) -> Option<&Length>
pub fn set_y(&mut self, value: Length)
pub fn width(&self) -> Option<&Length>
pub fn set_width(&mut self, value: Length)
pub fn height(&self) -> Option<&Length>
pub fn set_height(&mut self, value: Length)
Source§impl RCHandle<SkSVGFilter>
impl RCHandle<SkSVGFilter>
pub fn x(&self) -> &Length
pub fn set_x(&mut self, value: Length)
pub fn y(&self) -> &Length
pub fn set_y(&mut self, value: Length)
pub fn width(&self) -> &Length
pub fn set_width(&mut self, value: Length)
pub fn height(&self) -> &Length
pub fn set_height(&mut self, value: Length)
pub fn filter_units(&self) -> &BoundingBoxUnits
pub fn set_filter_units(&mut self, value: BoundingBoxUnits)
pub fn primitive_units(&self) -> &BoundingBoxUnits
pub fn set_primitive_units(&mut self, value: BoundingBoxUnits)
Source§impl RCHandle<SkSVGLinearGradient>
impl RCHandle<SkSVGLinearGradient>
pub fn x1(&self) -> &Length
pub fn set_x1(&mut self, value: Length)
pub fn y1(&self) -> &Length
pub fn set_y1(&mut self, value: Length)
pub fn x2(&self) -> &Length
pub fn set_x2(&mut self, value: Length)
pub fn y2(&self) -> &Length
pub fn set_y2(&mut self, value: Length)
Source§impl RCHandle<SkSVGRadialGradient>
impl RCHandle<SkSVGRadialGradient>
pub fn cx(&self) -> &Length
pub fn set_cx(&mut self, value: Length)
pub fn cy(&self) -> &Length
pub fn set_cy(&mut self, value: Length)
pub fn r(&self) -> &Length
pub fn set_r(&mut self, value: Length)
pub fn fx(&self) -> Option<&Length>
pub fn set_fx(&mut self, value: Length)
pub fn fy(&self) -> Option<&Length>
pub fn set_fy(&mut self, value: Length)
Source§impl RCHandle<SkSVGGradient>
impl RCHandle<SkSVGGradient>
pub fn href(&self) -> &Iri
pub fn set_href(&mut self, value: Iri)
pub fn gradient_transform(&self) -> &Matrix
pub fn set_gradient_transform(&mut self, value: Matrix)
pub fn spread_method(&self) -> &SpreadMethod
pub fn set_spread_method(&mut self, value: SpreadMethod)
pub fn gradient_units(&self) -> &BoundingBoxUnits
pub fn set_gradient_units(&mut self, value: BoundingBoxUnits)
Source§impl RCHandle<SkSVGImage>
impl RCHandle<SkSVGImage>
pub fn x(&self) -> &Length
pub fn set_x(&mut self, value: Length)
pub fn y(&self) -> &Length
pub fn set_y(&mut self, value: Length)
pub fn width(&self) -> &Length
pub fn set_width(&mut self, value: Length)
pub fn height(&self) -> &Length
pub fn set_height(&mut self, value: Length)
pub fn href(&self) -> &Iri
pub fn set_href(&mut self, value: Iri)
pub fn preserve_aspect_ratio(&self) -> &PreserveAspectRatio
pub fn set_preserve_aspect_ratio(&mut self, value: PreserveAspectRatio)
Source§impl RCHandle<SkSVGMask>
impl RCHandle<SkSVGMask>
pub fn x(&self) -> &Length
pub fn set_x(&mut self, value: Length)
pub fn y(&self) -> &Length
pub fn set_y(&mut self, value: Length)
pub fn width(&self) -> &Length
pub fn set_width(&mut self, value: Length)
pub fn height(&self) -> &Length
pub fn set_height(&mut self, value: Length)
pub fn mask_units(&self) -> &BoundingBoxUnits
pub fn set_mask_units(&mut self, value: BoundingBoxUnits)
pub fn mask_content_units(&self) -> &BoundingBoxUnits
pub fn set_mask_content_units(&mut self, value: BoundingBoxUnits)
Source§impl RCHandle<SkSVGNode>
impl RCHandle<SkSVGNode>
pub fn tag(&self) -> NodeTag
pub fn typed(self) -> TypedNode
pub fn clip_rule(&self) -> Option<&FillRule>
pub fn set_clip_rule(&mut self, value: FillRule)
pub fn color_interpolation(&self) -> Option<&ColorSpace>
pub fn set_color_interpolation(&mut self, value: ColorSpace)
pub fn color_interpolation_filters(&self) -> Option<&ColorSpace>
pub fn set_color_interpolation_filters(&mut self, value: ColorSpace)
pub fn color(&self) -> Option<&Color>
pub fn set_color(&mut self, value: Color)
pub fn fill_rule(&self) -> Option<&FillRule>
pub fn set_fill_rule(&mut self, value: FillRule)
pub fn fill(&self) -> Option<&Paint>
pub fn set_fill(&mut self, value: Paint)
pub fn fill_opacity(&self) -> Option<scalar>
pub fn set_fill_opacity(&mut self, value: scalar)
pub fn font_family(&self) -> Option<&FontFamily>
pub fn set_font_family(&mut self, value: FontFamily)
pub fn font_size(&self) -> Option<&FontSize>
pub fn set_font_size(&mut self, value: FontSize)
pub fn font_style(&self) -> Option<&FontStyle>
pub fn set_font_style(&mut self, value: FontStyle)
pub fn font_weight(&self) -> Option<&FontWeight>
pub fn set_font_weight(&mut self, value: FontWeight)
pub fn stroke(&self) -> Option<&Paint>
pub fn set_stroke(&mut self, value: Paint)
pub fn stroke_line_cap(&self) -> Option<&LineCap>
pub fn set_stroke_line_cap(&mut self, value: LineCap)
pub fn stroke_line_join(&self) -> Option<&LineJoin>
pub fn set_stroke_line_join(&mut self, value: LineJoin)
pub fn stroke_miter_limit(&self) -> Option<scalar>
pub fn set_stroke_miter_limit(&mut self, value: scalar)
pub fn stroke_opacity(&self) -> Option<scalar>
pub fn set_stroke_opacity(&mut self, value: scalar)
pub fn stroke_width(&self) -> Option<&Length>
pub fn set_stroke_width(&mut self, value: Length)
pub fn text_anchor(&self) -> Option<&TextAnchor>
pub fn set_text_anchor(&mut self, value: TextAnchor)
pub fn visibility(&self) -> Option<&Visibility>
pub fn set_visibility(&mut self, value: Visibility)
pub fn clip_path(&self) -> Option<&IriFunc>
pub fn set_clip_path(&mut self, value: IriFunc)
pub fn display(&self) -> Option<&Display>
pub fn set_display(&mut self, value: Display)
pub fn mask(&self) -> Option<&IriFunc>
pub fn set_mask(&mut self, value: IriFunc)
pub fn filter(&self) -> Option<&IriFunc>
pub fn set_filter(&mut self, value: IriFunc)
pub fn opacity(&self) -> Option<scalar>
pub fn set_opacity(&mut self, value: scalar)
pub fn stop_color(&self) -> Option<&Fill>
pub fn set_stop_color(&mut self, value: Fill)
pub fn stop_opacity(&self) -> Option<scalar>
pub fn set_stop_opacity(&mut self, value: scalar)
pub fn flood_color(&self) -> Option<&Fill>
pub fn set_flood_color(&mut self, value: Fill)
pub fn flood_opacity(&self) -> Option<scalar>
pub fn set_flood_opacity(&mut self, value: scalar)
pub fn lighting_color(&self) -> Option<&Fill>
pub fn set_lighting_color(&mut self, value: Fill)
Source§impl<T: NativeRefCounted + NodeSubtype> RCHandle<T>
impl<T: NativeRefCounted + NodeSubtype> RCHandle<T>
Source§impl RCHandle<SkSVGPattern>
impl RCHandle<SkSVGPattern>
pub fn href(&self) -> &Iri
pub fn set_href(&mut self, value: Iri)
pub fn x(&self) -> Option<&Length>
pub fn set_x(&mut self, value: Length)
pub fn y(&self) -> Option<&Length>
pub fn set_y(&mut self, value: Length)
pub fn width(&self) -> Option<&Length>
pub fn set_width(&mut self, value: Length)
pub fn height(&self) -> Option<&Length>
pub fn set_height(&mut self, value: Length)
pub fn pattern_transform(&self) -> Option<&Matrix>
pub fn set_pattern_transform(&mut self, value: Matrix)
Source§impl RCHandle<SkSVGEllipse>
impl RCHandle<SkSVGEllipse>
pub fn cx(&self) -> &Length
pub fn set_cx(&mut self, value: Length)
pub fn cy(&self) -> &Length
pub fn set_cy(&mut self, value: Length)
pub fn rx(&self) -> Option<&Length>
pub fn set_rx(&mut self, value: Length)
pub fn ry(&self) -> Option<&Length>
pub fn set_ry(&mut self, value: Length)
Source§impl RCHandle<SkSVGLine>
impl RCHandle<SkSVGLine>
pub fn x1(&self) -> &Length
pub fn set_x1(&mut self, value: Length)
pub fn y1(&self) -> &Length
pub fn set_y1(&mut self, value: Length)
pub fn x2(&self) -> &Length
pub fn set_x2(&mut self, value: Length)
pub fn y2(&self) -> &Length
pub fn set_y2(&mut self, value: Length)
Source§impl RCHandle<SkSVGRect>
impl RCHandle<SkSVGRect>
pub fn x(&self) -> &Length
pub fn set_x(&mut self, value: Length)
pub fn y(&self) -> &Length
pub fn set_y(&mut self, value: Length)
pub fn width(&self) -> &Length
pub fn set_width(&mut self, value: Length)
pub fn height(&self) -> &Length
pub fn set_height(&mut self, value: Length)
pub fn rx(&self) -> Option<&Length>
pub fn set_rx(&mut self, value: Length)
pub fn ry(&self) -> Option<&Length>
pub fn set_ry(&mut self, value: Length)
Source§impl RCHandle<SkSVGSVG>
impl RCHandle<SkSVGSVG>
pub fn new(kind: SvgKind) -> Self
pub fn x(&self) -> &Length
pub fn set_x(&mut self, value: Length)
pub fn y(&self) -> &Length
pub fn set_y(&mut self, value: Length)
pub fn width(&self) -> &Length
pub fn set_width(&mut self, value: Length)
pub fn height(&self) -> &Length
pub fn set_height(&mut self, value: Length)
pub fn preserve_aspect_ratio(&self) -> &PreserveAspectRatio
pub fn set_preserve_aspect_ratio(&mut self, value: PreserveAspectRatio)
pub fn view_box(&self) -> Option<&Rect>
pub fn set_view_box(&mut self, value: Rect)
pub fn intrinsic_size(&self) -> Size
Source§impl RCHandle<SkSVGDOM>
impl RCHandle<SkSVGDOM>
This type represents an SVG as a node-based data structure.
To convert an SVG to a Dom
, a NativeResourceProvider
is required.
§Creating a Resource Provider
To create a resource provider, a crate::FontMgr
is required at a minimum.
- If you don’t need font support, pass
crate::FontMgr::new_empty()
as the resource provider. - To use the installed fonts on your system, pass
crate::FontMgr::default()
as the resource provider.
When you pass a crate::FontMgr
as the resource provider, a
crate::resources::LocalResourceProvider
is created behind the scenes. This provider, in
addition to supporting typefaces, also adds support for data:
URLs.
§Supporting External Resources
To support http://
or https://
external resources, enable the ureq
feature and create a
crate::resources::UReqResourceProvider
.
§Custom Resource Providers
If you need more customization, you can implement the trait crate::resources::ResourceProvider
.
pub fn read<R: Read>( reader: R, resource_provider: impl Into<NativeResourceProvider>, ) -> Result<Self, LoadError>
pub fn from_str( svg: impl AsRef<str>, resource_provider: impl Into<NativeResourceProvider>, ) -> Result<Self, LoadError>
pub fn from_bytes( svg: &[u8], resource_provider: impl Into<NativeResourceProvider>, ) -> Result<Self, LoadError>
pub fn root(&self) -> Svg
pub fn render(&self, canvas: &Canvas)
pub fn set_container_size(&mut self, size: impl Into<Size>)
Trait Implementations§
Source§impl<H: NativeRefCountedBase> ConditionallySend for RCHandle<H>
impl<H: NativeRefCountedBase> ConditionallySend for RCHandle<H>
RCHandle<H>
is conditionally Send and can be sent to
another thread when its reference count is 1.
Source§impl<N: NativeRefCounted> Debug for RCHandle<N>where
Self: DebugAttributes,
impl<N: NativeRefCounted> Debug for RCHandle<N>where
Self: DebugAttributes,
Source§impl DebugAttributes for RCHandle<SkSVGPattern>
impl DebugAttributes for RCHandle<SkSVGPattern>
Source§impl DebugAttributes for RCHandle<SkSVGTextContainer>
impl DebugAttributes for RCHandle<SkSVGTextContainer>
Source§impl<T: NativeRefCounted + NodeSubtype> DerefMut for RCHandle<T>
impl<T: NativeRefCounted + NodeSubtype> DerefMut for RCHandle<T>
Source§impl<N> Flattenable for RCHandle<N>where
N: NativeFlattenable + NativeRefCountedBase,
impl<N> Flattenable for RCHandle<N>where
N: NativeFlattenable + NativeRefCountedBase,
Source§impl<N: NativeRefCounted> From<&RCHandle<N>> for RCHandle<N>
impl<N: NativeRefCounted> From<&RCHandle<N>> for RCHandle<N>
A reference counted handle is cheap to clone, so we do support a conversion from a reference to a ref counter to an owned handle.
Source§impl From<RCHandle<GrDirectContext>> for RecordingContext
impl From<RCHandle<GrDirectContext>> for RecordingContext
Source§fn from(direct_context: DirectContext) -> Self
fn from(direct_context: DirectContext) -> Self
Source§impl From<RCHandle<SkColorFilter>> for ChildPtr
impl From<RCHandle<SkColorFilter>> for ChildPtr
Source§fn from(color_filter: ColorFilter) -> Self
fn from(color_filter: ColorFilter) -> Self
Source§impl From<RCHandle<SkFontMgr>> for NativeResourceProvider
impl From<RCHandle<SkFontMgr>> for NativeResourceProvider
Support a direct conversion from a FontMgr
into a local native resource provider.