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