skia_safe/
core.rs

1// Unsupported, not used in any public APIs.
2// mod executor;
3// Unsupported, because it's not used in publicly exposed APIs:
4// mod font_lcd_config;
5
6mod alpha_type;
7mod annotation;
8pub mod arc;
9mod bbh_factory;
10mod bitmap;
11mod blend_mode;
12mod blender;
13mod blur_types;
14pub mod canvas;
15mod clip_op;
16mod color;
17pub mod color_filter;
18mod color_space;
19mod color_table;
20mod color_type;
21pub mod contour_measure;
22mod coverage_mode;
23mod cubic_map;
24mod data;
25mod data_table;
26pub mod document;
27pub mod drawable;
28mod flattenable;
29pub mod font;
30pub mod font_arguments;
31pub mod font_metrics;
32mod font_mgr;
33pub mod font_parameters;
34mod font_scanner;
35pub mod font_style;
36mod font_types;
37mod four_byte_tag;
38pub mod graphics;
39pub mod image;
40pub mod image_filter;
41mod image_generator;
42mod image_info;
43mod m44;
44mod mask_filter;
45pub mod matrix;
46mod mesh;
47mod milestone;
48pub mod paint;
49pub mod path;
50mod path_builder;
51pub mod path_effect;
52pub mod path_measure;
53pub mod path_types;
54pub mod path_utils;
55mod picture;
56pub mod picture_recorder;
57mod pixel_ref;
58mod pixmap;
59mod point;
60mod point3;
61mod raster_handle_allocator;
62mod rect;
63pub mod region;
64pub mod rrect;
65mod rsxform;
66pub mod sampling_options;
67mod scalar_;
68pub mod shader;
69mod size;
70pub mod stroke_rec;
71pub mod surface;
72mod surface_props;
73mod swizzle;
74mod text_blob;
75mod texture_compression_type;
76mod tile_mode;
77pub mod tiled_image_utils;
78mod time;
79mod trace_memory_dump;
80pub mod typeface;
81mod types;
82mod un_pre_multiply;
83pub mod vertices;
84pub mod yuva_info;
85pub mod yuva_pixmaps;
86
87pub use alpha_type::*;
88pub use annotation::annotate;
89pub use bbh_factory::*;
90pub use bitmap::*;
91pub use blend_mode::*;
92pub use blender::*;
93pub use blur_types::*;
94pub use canvas::{AutoCanvasRestore, Canvas, OwnedCanvas};
95pub use clip_op::*;
96pub use color::*;
97pub use color_filter::{color_filters, ColorFilter};
98pub use color_space::*;
99pub use color_table::*;
100pub use color_type::*;
101pub use contour_measure::{ContourMeasure, ContourMeasureIter};
102pub use coverage_mode::*;
103pub use cubic_map::*;
104pub use data::*;
105pub use data_table::*;
106pub use document::Document;
107pub use drawable::Drawable;
108pub use flattenable::*;
109pub use font::Font;
110pub use font_arguments::FontArguments;
111pub use font_metrics::FontMetrics;
112pub use font_mgr::*;
113pub use font_style::FontStyle;
114pub use font_types::*;
115pub use four_byte_tag::*;
116pub use image::{images, Image};
117pub use image_filter::ImageFilter;
118pub use image_generator::*;
119pub use image_info::*;
120pub use m44::*;
121pub use mask_filter::*;
122pub use matrix::Matrix;
123pub use milestone::*;
124pub use paint::Paint;
125pub use tile_mode::*;
126// We keep these around for the time being.
127pub use arc::Arc;
128pub use paint::Cap as PaintCap;
129pub use paint::Join as PaintJoin;
130pub use paint::Style as PaintStyle;
131pub use path::Path;
132pub use path_builder::PathBuilder;
133pub use path_effect::PathEffect;
134pub use path_measure::PathMeasure;
135pub use path_types::*;
136pub use picture::*;
137pub use picture_recorder::PictureRecorder;
138pub use pixel_ref::*;
139pub use pixmap::*;
140pub use point::*;
141pub use point3::*;
142#[allow(unused)]
143pub use raster_handle_allocator::*;
144pub use rect::*;
145pub use region::Region;
146pub use rrect::RRect;
147pub use rsxform::*;
148#[allow(deprecated)]
149pub use sampling_options::{
150    CubicResampler, FilterMode, FilterOptions, MipmapMode, SamplingMode, SamplingOptions,
151};
152pub use scalar_::*;
153pub use shader::Shader;
154pub use size::*;
155pub use stroke_rec::StrokeRec;
156pub use surface::{surfaces, Surface};
157pub use surface_props::*;
158pub use swizzle::*;
159pub use text_blob::*;
160pub use texture_compression_type::*;
161pub use time::*;
162#[allow(unused)]
163pub use trace_memory_dump::*;
164pub use typeface::Typeface;
165pub use types::*;
166#[allow(unused)]
167pub use un_pre_multiply::*;
168pub use vertices::Vertices;
169pub use yuva_info::YUVAInfo;
170pub use yuva_pixmaps::{yuva_pixmap_info, YUVAPixmapInfo, YUVAPixmaps};
171
172//
173// Skia specific traits used for overloading functions.
174//
175
176pub trait Contains<T> {
177    fn contains(&self, other: T) -> bool;
178}
179
180pub trait QuickReject<T> {
181    fn quick_reject(&self, other: &T) -> bool;
182}
183
184pub mod shaders {
185    pub use super::shader::shaders::*;
186    use crate::{prelude::*, scalar, ISize, Shader};
187    use skia_bindings as sb;
188
189    impl Shader {
190        pub fn fractal_perlin_noise(
191            base_frequency: (scalar, scalar),
192            num_octaves: usize,
193            seed: scalar,
194            tile_size: impl Into<Option<ISize>>,
195        ) -> Option<Self> {
196            fractal_noise(base_frequency, num_octaves, seed, tile_size)
197        }
198
199        pub fn turbulence_perlin_noise(
200            base_frequency: (scalar, scalar),
201            num_octaves: usize,
202            seed: scalar,
203            tile_size: impl Into<Option<ISize>>,
204        ) -> Option<Self> {
205            turbulence(base_frequency, num_octaves, seed, tile_size)
206        }
207    }
208
209    pub fn fractal_noise(
210        base_frequency: (scalar, scalar),
211        num_octaves: usize,
212        seed: scalar,
213        tile_size: impl Into<Option<ISize>>,
214    ) -> Option<Shader> {
215        Shader::from_ptr(unsafe {
216            sb::C_SkShaders_MakeFractalNoise(
217                base_frequency.0,
218                base_frequency.1,
219                num_octaves.try_into().unwrap(),
220                seed,
221                tile_size.into().native().as_ptr_or_null(),
222            )
223        })
224    }
225
226    pub fn turbulence(
227        base_frequency: (scalar, scalar),
228        num_octaves: usize,
229        seed: scalar,
230        tile_size: impl Into<Option<ISize>>,
231    ) -> Option<Shader> {
232        Shader::from_ptr(unsafe {
233            sb::C_SkShaders_MakeTurbulence(
234                base_frequency.0,
235                base_frequency.1,
236                num_octaves.try_into().unwrap(),
237                seed,
238                tile_size.into().native().as_ptr_or_null(),
239            )
240        })
241    }
242}