1use std::sync::Arc;
6
7use nsh_core::{
8 JsonValue, NodeId,
9 animation::AnimatedPropValue,
10 geometry::{Points, Size},
11 gpu::GpuSource,
12};
13
14#[cfg(windows)]
15use crate::shader_frame::SharedTexture;
16use crate::shader_frame::{Frame, PixelFormat};
17
18pub struct GpuViews {
20 warned: bool,
21}
22
23impl GpuViews {
24 pub fn new(format: PixelFormat) -> Self {
26 let _ = format;
27 Self { warned: false }
28 }
29
30 pub fn on_ready(&self, f: impl Fn() + Send + Sync + 'static) {
32 drop(f);
33 }
34
35 pub fn set(&mut self, id: NodeId, source: Option<GpuSource>) {
37 if source.is_some() && !std::mem::replace(&mut self.warned, true) {
38 log::warn!(
39 "GPU view {id}: this build has no GPU renderer (feature `shader`); GPU views draw nothing"
40 );
41 }
42 }
43
44 pub fn set_props(&mut self, id: NodeId, props: &[(Arc<str>, Option<JsonValue>)]) {
46 let _ = (id, props);
47 }
48
49 pub fn set_animated(&mut self, id: NodeId, name: &str, value: AnimatedPropValue) {
51 let _ = (id, name, value);
52 }
53
54 pub fn has(&self, id: NodeId) -> bool {
56 let _ = id;
57 false
58 }
59
60 pub fn set_hidden(&mut self, id: NodeId, hidden: bool) {
62 let _ = (id, hidden);
63 }
64
65 pub fn set_size(&mut self, id: NodeId, size: Size<Points>, scale: f32) {
67 let _ = (id, size, scale);
68 }
69
70 #[cfg(any(target_vendor = "apple", windows))]
72 pub fn show_on_surfaces(&mut self, id: NodeId, on: bool) {
73 let _ = (id, on);
74 }
75
76 pub fn remove(&mut self, id: NodeId) {
78 let _ = id;
79 }
80
81 pub fn wants_frame(&self) -> bool {
83 false
84 }
85
86 pub fn tick(&mut self, f: impl FnMut(NodeId)) {
88 drop(f);
89 }
90
91 pub fn take_events(&mut self) -> Vec<(NodeId, Arc<str>, JsonValue)> {
93 Vec::new()
94 }
95
96 pub fn with_frame<T>(&self, id: NodeId, f: impl FnOnce(&Frame) -> T) -> Option<T> {
98 let _ = (id, f);
99 None
100 }
101
102 #[cfg(windows)]
104 pub fn surface(&self, id: NodeId) -> Option<SharedTexture> {
105 let _ = id;
106 None
107 }
108
109 #[cfg(target_vendor = "apple")]
111 pub fn with_surface<T>(
112 &self,
113 id: NodeId,
114 f: impl FnOnce(&objc2_io_surface::IOSurfaceRef) -> T,
115 ) -> Option<T> {
116 let _ = (id, f);
117 None
118 }
119}