Skip to main content

skia_safe/
lib.rs

1#![allow(clippy::upper_case_acronyms)]
2#![allow(clippy::non_send_fields_in_send_ty)]
3// https://github.com/rust-lang/rust/issues/93367
4#![allow(unknown_lints)]
5#![allow(clippy::too_long_first_doc_paragraph)]
6#![allow(clippy::doc_overindented_list_items)]
7#![allow(mismatched_lifetime_syntaxes)]
8
9#[cfg(feature = "gpu")]
10compile_error!(
11    "feature `gpu` has been renamed to `ganesh`; replace `gpu` with `ganesh`. The `vulkan` and `metal` features require either `ganesh` or `graphite`."
12);
13
14#[cfg(all(
15    any(feature = "vulkan", feature = "metal"),
16    not(any(feature = "ganesh", feature = "graphite"))
17))]
18compile_error!(
19    "the `vulkan` and `metal` features require at least one rendering engine: `ganesh` or `graphite`"
20);
21
22mod macros;
23
24pub mod codec;
25#[deprecated(since = "0.33.1", note = "use codec::Result")]
26pub use codec::Result as CodecResult;
27pub use codec::{Codec, EncodedImageFormat, EncodedOrigin, codecs};
28
29mod core;
30#[cfg(feature = "pdf")]
31mod docs;
32mod effects;
33mod encode_;
34pub mod gpu;
35mod interop;
36mod modules;
37mod pathops;
38mod prelude;
39pub(crate) mod private;
40pub mod skottie;
41pub mod svg;
42pub mod wrapper;
43// TODO: We don't export utils/* into the crate's root yet. Should we?
44pub mod utils;
45
46#[macro_use]
47extern crate bitflags;
48
49// Prelude re-exports
50pub use crate::prelude::{Borrows, ConditionallySend, Handle, RCHandle, RefHandle, Sendable};
51
52// All Sk* types are accessible via skia_safe::
53pub use crate::core::*;
54#[cfg(feature = "pdf")]
55pub use docs::*;
56pub use effects::*;
57pub use encode_::*;
58#[allow(unused_imports)]
59pub use modules::*;
60pub use pathops::*;
61
62#[cfg(test)]
63mod transmutation_tests {
64    use crate::{Point, prelude::NativeTransmutableSliceAccess};
65    use skia_bindings::SkPoint;
66
67    #[test]
68    #[allow(clippy::float_cmp)]
69    fn test_transmutation_of_fixed_size_arrays_to_slice() {
70        let mut points = [Point::default(); 4];
71
72        let points_native = points.native_mut();
73        let native_point = SkPoint { fX: 10.0, fY: 11.0 };
74        points_native[1] = native_point;
75
76        assert_eq!(points[1].x, native_point.fX);
77        assert_eq!(points[1].y, native_point.fY);
78    }
79}