1use std::{
7 sync::Arc,
8 time::{Duration, Instant},
9};
10
11use nsh_core::{
12 animation::AnimationValue,
13 geometry::{Points, Size},
14 shader::{ShaderInput, ShaderLayer},
15};
16
17#[cfg(windows)]
18pub use crate::shader_frame::SharedTexture;
19pub use crate::shader_frame::{Frame, MAX_SIDE, PixelFormat};
20
21pub const LINKED: bool = false;
24
25pub(crate) fn no_gpu() -> bool {
27 false
28}
29
30pub struct Renderer {
32 format: PixelFormat,
33}
34
35impl Renderer {
36 pub fn new(_format: PixelFormat) -> Option<Renderer> {
38 static WARNED: std::sync::Once = std::sync::Once::new();
39 WARNED.call_once(|| {
40 log::warn!(
41 "a shader view draws nothing: this runtime was built without the NSH platform crate's feature `shader`"
42 )
43 });
44 None
45 }
46
47 pub fn open(_format: PixelFormat, done: impl FnOnce(Option<Renderer>) + Send + 'static) {
49 done(None);
50 }
51
52 pub fn on_pipeline_ready(&self, f: impl Fn() + Send + Sync + 'static) {
54 drop(f);
55 }
56
57 pub fn compiling(&self) -> bool {
59 false
60 }
61
62 pub fn wait_for_pipelines(&self, _timeout: Duration) -> bool {
64 true
65 }
66
67 pub fn format(&self) -> PixelFormat {
69 self.format
70 }
71
72 pub fn when_done(&self, f: impl FnOnce() + Send + 'static) -> bool {
74 drop(f);
75 false
76 }
77}
78
79#[derive(Default)]
81pub struct ShaderView {
82 layer: Option<Arc<ShaderLayer>>,
83 frame: Frame,
84}
85
86impl ShaderView {
87 pub fn set_layer(&mut self, layer: Option<Arc<ShaderLayer>>) {
89 self.layer = layer;
90 }
91
92 pub fn set_input(
94 &mut self,
95 _renderer: &Renderer,
96 _input: ShaderInput,
97 _picture: Option<(&[u8], u32, u32, u32)>,
98 ) {
99 }
100
101 pub fn set_input_from_frame(&mut self, _renderer: &Renderer, _input: ShaderInput) -> bool {
103 false
104 }
105
106 pub fn has_input(&self, _input: ShaderInput) -> bool {
108 false
109 }
110
111 pub fn start_transition(&mut self, _duration: Duration, _now: Instant) {}
113
114 pub fn start_transition_backwards(&mut self, _duration: Duration, _now: Instant) {}
116
117 pub fn transitioning(&mut self, _now: Instant) -> bool {
119 false
120 }
121
122 pub fn replaces_children(&mut self, _now: Instant) -> bool {
124 false
125 }
126
127 pub fn overflow(&self) -> Points {
129 Points(0.0)
130 }
131
132 pub fn layer(&self) -> Option<&Arc<ShaderLayer>> {
134 self.layer.as_ref()
135 }
136
137 pub fn set_slot(&mut self, _slot: u16, _value: AnimationValue) {}
139
140 pub fn set_size(&mut self, _size: Size<Points>, _scale: f32) {}
142
143 pub fn wants_frame(&self) -> bool {
145 false
146 }
147
148 pub fn compiling(&self) -> bool {
150 false
151 }
152
153 pub fn pending(&self) -> bool {
155 false
156 }
157
158 pub fn due(&self) -> bool {
160 false
161 }
162
163 pub fn animates(&self) -> bool {
165 false
166 }
167
168 pub fn frame(&self) -> &Frame {
170 &self.frame
171 }
172
173 #[cfg(any(target_vendor = "apple", windows))]
175 pub fn show_on_surfaces(&mut self, _on: bool) {}
176
177 #[cfg(windows)]
179 pub fn surface(&self) -> Option<SharedTexture> {
180 None
181 }
182
183 #[cfg(target_vendor = "apple")]
185 pub fn surface(&self) -> Option<&objc2_io_surface::IOSurfaceRef> {
186 None
187 }
188
189 pub fn collect_frame(&mut self, _renderer: &Renderer) -> bool {
191 false
192 }
193
194 pub fn render(&mut self, _renderer: &Renderer, _now: Instant) -> bool {
196 false
197 }
198}