forked from slint-ui/slint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwasm_backend.rs
103 lines (88 loc) · 2.77 KB
/
wasm_backend.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT
use plotters_backend::*;
pub struct BackendWithoutText<ForwardedBackend: DrawingBackend> {
pub backend: ForwardedBackend,
}
impl<ForwardedBackend: DrawingBackend> DrawingBackend for BackendWithoutText<ForwardedBackend> {
type ErrorType = ForwardedBackend::ErrorType;
fn get_size(&self) -> (u32, u32) {
self.backend.get_size()
}
fn ensure_prepared(&mut self) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.ensure_prepared()
}
fn present(&mut self) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.present()
}
fn draw_pixel(
&mut self,
point: BackendCoord,
color: BackendColor,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.draw_pixel(point, color)
}
fn draw_line<S: BackendStyle>(
&mut self,
from: BackendCoord,
to: BackendCoord,
style: &S,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.draw_line(from, to, style)
}
fn draw_rect<S: BackendStyle>(
&mut self,
upper_left: BackendCoord,
bottom_right: BackendCoord,
style: &S,
fill: bool,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.draw_rect(upper_left, bottom_right, style, fill)
}
fn draw_path<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
&mut self,
path: I,
style: &S,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.draw_path(path, style)
}
fn draw_circle<S: BackendStyle>(
&mut self,
center: BackendCoord,
radius: u32,
style: &S,
fill: bool,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.draw_circle(center, radius, style, fill)
}
fn fill_polygon<S: BackendStyle, I: IntoIterator<Item = BackendCoord>>(
&mut self,
vert: I,
style: &S,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.fill_polygon(vert, style)
}
fn draw_text<TStyle: BackendTextStyle>(
&mut self,
_text: &str,
_style: &TStyle,
_pos: BackendCoord,
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
Ok(())
}
fn estimate_text_size<TStyle: BackendTextStyle>(
&self,
_text: &str,
_style: &TStyle,
) -> Result<(u32, u32), DrawingErrorKind<Self::ErrorType>> {
Ok((0, 0))
}
fn blit_bitmap<'b>(
&mut self,
pos: BackendCoord,
(iw, ih): (u32, u32),
src: &'b [u8],
) -> Result<(), DrawingErrorKind<Self::ErrorType>> {
self.backend.blit_bitmap(pos, (iw, ih), src)
}
}