Skip to main content

skia_bindings/
defaults.rs

1//! This file contains Default trait implementations for types that are re-exported from skia-safe.
2#![allow(clippy::derivable_impls)]
3
4#[cfg(feature = "pdf")]
5use crate::SkPDF_Metadata_CompressionLevel;
6use crate::{
7    SkArc_Type, SkBlendMode, SkBlurStyle, SkCanvas_Lattice_RectType, SkClipOp, SkPaint_Cap,
8    SkPaint_Join, SkParsePath_PathEncoding, SkPathDirection, SkPathFillType, SkTileMode,
9    SkYUVColorSpace,
10};
11
12impl Default for SkArc_Type {
13    fn default() -> Self {
14        Self::Arc
15    }
16}
17
18impl Default for SkBlendMode {
19    fn default() -> Self {
20        SkBlendMode::SrcOver
21    }
22}
23
24impl Default for SkBlurStyle {
25    fn default() -> Self {
26        SkBlurStyle::Normal
27    }
28}
29
30impl Default for SkCanvas_Lattice_RectType {
31    fn default() -> Self {
32        SkCanvas_Lattice_RectType::Default
33    }
34}
35
36// This is the default for the canvas's clip functions.
37impl Default for SkClipOp {
38    fn default() -> Self {
39        SkClipOp::Intersect
40    }
41}
42
43impl Default for SkPaint_Cap {
44    fn default() -> Self {
45        SkPaint_Cap::Default
46    }
47}
48
49impl Default for SkPaint_Join {
50    fn default() -> Self {
51        SkPaint_Join::Default
52    }
53}
54
55impl Default for SkPathFillType {
56    fn default() -> Self {
57        SkPathFillType::Default
58    }
59}
60
61impl Default for SkPathDirection {
62    fn default() -> Self {
63        SkPathDirection::Default
64    }
65}
66
67impl Default for SkParsePath_PathEncoding {
68    fn default() -> Self {
69        SkParsePath_PathEncoding::Absolute
70    }
71}
72
73#[cfg(feature = "pdf")]
74impl Default for SkPDF_Metadata_CompressionLevel {
75    fn default() -> Self {
76        SkPDF_Metadata_CompressionLevel::Default
77    }
78}
79
80impl Default for SkTileMode {
81    fn default() -> Self {
82        SkTileMode::Clamp
83    }
84}
85
86impl Default for SkYUVColorSpace {
87    fn default() -> Self {
88        SkYUVColorSpace::Identity
89    }
90}
91
92#[cfg(feature = "textlayout")]
93pub mod textlayout {
94    impl Default for crate::skia_textlayout_Affinity {
95        fn default() -> Self {
96            Self::Upstream
97        }
98    }
99
100    impl Default for crate::skia_textlayout_TextAlign {
101        fn default() -> Self {
102            Self::Left
103        }
104    }
105
106    // TODO: Remove as soon we are building with Rust stable >= 1.57
107    #[allow(unknown_lints)]
108    #[allow(clippy::derivable_impls)]
109    impl Default for crate::skia_textlayout_PositionWithAffinity {
110        fn default() -> Self {
111            Self {
112                position: 0,
113                affinity: Default::default(),
114            }
115        }
116    }
117
118    impl Default for crate::skia_textlayout_TextBaseline {
119        fn default() -> Self {
120            Self::Alphabetic
121        }
122    }
123
124    impl Default for crate::skia_textlayout_TextDecorationStyle {
125        fn default() -> Self {
126            Self::Solid
127        }
128    }
129
130    impl Default for crate::skia_textlayout_TextDecorationMode {
131        fn default() -> Self {
132            Self::Gaps
133        }
134    }
135
136    impl Default for crate::skia_textlayout_StyleType {
137        fn default() -> Self {
138            Self::AllAttributes
139        }
140    }
141}