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