Skip to main content

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