1#![macro_use]
2#![allow(clippy::upper_case_acronyms)]
3#![allow(clippy::non_send_fields_in_send_ty)]
4#![allow(unknown_lints)]
6#![allow(clippy::too_long_first_doc_paragraph)]
7#![allow(clippy::doc_overindented_list_items)]
8#![allow(mismatched_lifetime_syntaxes)]
9
10mod macros;
11
12pub mod codec;
13#[deprecated(since = "0.33.1", note = "use codec::Result")]
14pub use codec::Result as CodecResult;
15pub use codec::{codecs, Codec, EncodedImageFormat, EncodedOrigin};
16
17mod core;
18#[cfg(feature = "pdf")]
19mod docs;
20mod effects;
21mod encode_;
22#[cfg(feature = "gpu")]
23pub mod gpu;
24mod interop;
25mod modules;
26mod pathops;
27mod prelude;
28pub(crate) mod private;
29pub mod skottie;
30pub mod svg;
31pub mod wrapper;
32pub mod utils;
34
35#[macro_use]
36extern crate bitflags;
37
38pub use crate::prelude::{Borrows, ConditionallySend, Handle, RCHandle, RefHandle, Sendable};
40
41pub use crate::core::*;
43#[cfg(feature = "pdf")]
44pub use docs::*;
45pub use effects::*;
46pub use encode_::*;
47#[allow(unused_imports)]
48pub use modules::*;
49pub use pathops::*;
50
51#[allow(unknown_lints, clippy::uninhabited_references)]
53#[cfg(not(feature = "gpu"))]
54pub mod gpu {
55 use std::{
56 ops::{Deref, DerefMut},
57 ptr,
58 };
59
60 use crate::prelude::*;
61
62 #[derive(Debug)]
63 pub enum RecordingContext {}
64
65 impl NativePointerOrNullMut for Option<&mut RecordingContext> {
66 type Native = skia_bindings::GrRecordingContext;
67
68 fn native_ptr_or_null_mut(&mut self) -> *mut skia_bindings::GrRecordingContext {
69 ptr::null_mut()
70 }
71 }
72
73 #[derive(Debug)]
74 pub enum DirectContext {}
75
76 impl Deref for DirectContext {
77 type Target = RecordingContext;
78
79 fn deref(&self) -> &Self::Target {
80 unsafe { transmute_ref(self) }
81 }
82 }
83
84 impl DerefMut for DirectContext {
85 fn deref_mut(&mut self) -> &mut Self::Target {
86 unsafe { transmute_ref_mut(self) }
87 }
88 }
89
90 impl NativePointerOrNullMut for Option<&mut DirectContext> {
91 type Native = skia_bindings::GrDirectContext;
92
93 fn native_ptr_or_null_mut(&mut self) -> *mut skia_bindings::GrDirectContext {
94 ptr::null_mut()
95 }
96 }
97}
98
99#[cfg(test)]
100mod transmutation_tests {
101 use crate::{prelude::NativeTransmutableSliceAccess, Point};
102 use skia_bindings::SkPoint;
103
104 #[test]
105 #[allow(clippy::float_cmp)]
106 fn test_transmutation_of_fixed_size_arrays_to_slice() {
107 let mut points = [Point::default(); 4];
108
109 let points_native = points.native_mut();
110 let native_point = SkPoint { fX: 10.0, fY: 11.0 };
111 points_native[1] = native_point;
112
113 assert_eq!(points[1].x, native_point.fX);
114 assert_eq!(points[1].y, native_point.fY);
115 }
116}