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 svg;
30pub mod wrapper;
31pub mod utils;
33
34#[macro_use]
35extern crate bitflags;
36
37pub use crate::prelude::{Borrows, ConditionallySend, Handle, RCHandle, RefHandle, Sendable};
39
40pub use crate::core::*;
42#[cfg(feature = "pdf")]
43pub use docs::*;
44pub use effects::*;
45pub use encode_::*;
46#[allow(unused_imports)]
47pub use modules::*;
48pub use pathops::*;
49
50#[allow(unknown_lints, clippy::uninhabited_references)]
52#[cfg(not(feature = "gpu"))]
53pub mod gpu {
54 use std::{
55 ops::{Deref, DerefMut},
56 ptr,
57 };
58
59 use crate::prelude::*;
60
61 #[derive(Debug)]
62 pub enum RecordingContext {}
63
64 impl NativePointerOrNullMut for Option<&mut RecordingContext> {
65 type Native = skia_bindings::GrRecordingContext;
66
67 fn native_ptr_or_null_mut(&mut self) -> *mut skia_bindings::GrRecordingContext {
68 ptr::null_mut()
69 }
70 }
71
72 #[derive(Debug)]
73 pub enum DirectContext {}
74
75 impl Deref for DirectContext {
76 type Target = RecordingContext;
77
78 fn deref(&self) -> &Self::Target {
79 unsafe { transmute_ref(self) }
80 }
81 }
82
83 impl DerefMut for DirectContext {
84 fn deref_mut(&mut self) -> &mut Self::Target {
85 unsafe { transmute_ref_mut(self) }
86 }
87 }
88
89 impl NativePointerOrNullMut for Option<&mut DirectContext> {
90 type Native = skia_bindings::GrDirectContext;
91
92 fn native_ptr_or_null_mut(&mut self) -> *mut skia_bindings::GrDirectContext {
93 ptr::null_mut()
94 }
95 }
96}
97
98#[cfg(test)]
99mod transmutation_tests {
100 use crate::{prelude::NativeTransmutableSliceAccess, Point};
101 use skia_bindings::SkPoint;
102
103 #[test]
104 #[allow(clippy::float_cmp)]
105 fn test_transmutation_of_fixed_size_arrays_to_slice() {
106 let mut points = [Point::default(); 4];
107
108 let points_native = points.native_mut();
109 let native_point = SkPoint { fX: 10.0, fY: 11.0 };
110 points_native[1] = native_point;
111
112 assert_eq!(points[1].x, native_point.fX);
113 assert_eq!(points[1].y, native_point.fY);
114 }
115}