Kaynağa Gözat

app: gfx RenderApi rename method_req/method_rep to method_send/method_recv since it no longer replies anything (just unidirectional pipe)

darkfi 1 yıl önce
ebeveyn
işleme
b6c9e446d2
3 değiştirilmiş dosya ile 20 ekleme ve 20 silme
  1. 1 1
      bin/app/src/app/schema/chat.rs
  2. 15 15
      bin/app/src/gfx/mod.rs
  3. 4 4
      bin/app/src/main.rs

+ 1 - 1
bin/app/src/app/schema/chat.rs

@@ -747,7 +747,7 @@ pub async fn make(
     }
     node.set_property_u32(atom, Role::App, "z_index", 6).unwrap();
     node.set_property_u32(atom, Role::App, "priority", 3).unwrap();
-    node.set_property_bool(atom, Role::App, "debug", true).unwrap();
+    //node.set_property_bool(atom, Role::App, "debug", true).unwrap();
 
     let editz_text = PropertyStr::wrap(&node, Role::App, "text", 0).unwrap();
     let editz_select_text = node.get_property("select_text").unwrap();

+ 15 - 15
bin/app/src/gfx/mod.rs

@@ -152,14 +152,14 @@ pub type EpochIndex = u32;
 #[derive(Clone)]
 pub struct RenderApi {
     /// We are abusing async_channel since it's cloneable whereas std::sync::mpsc is shit.
-    method_req: async_channel::Sender<(EpochIndex, GraphicsMethod)>,
+    method_send: async_channel::Sender<(EpochIndex, GraphicsMethod)>,
     /// Keep track of the current UI epoch
     epoch: Arc<AtomicU32>,
 }
 
 impl RenderApi {
-    pub fn new(method_req: async_channel::Sender<(EpochIndex, GraphicsMethod)>) -> Self {
-        Self { method_req, epoch: Arc::new(AtomicU32::new(0)) }
+    pub fn new(method_send: async_channel::Sender<(EpochIndex, GraphicsMethod)>) -> Self {
+        Self { method_send, epoch: Arc::new(AtomicU32::new(0)) }
     }
 
     fn next_epoch(&self) -> EpochIndex {
@@ -172,7 +172,7 @@ impl RenderApi {
         epoch
     }
     fn send_with_epoch(&self, method: GraphicsMethod, epoch: EpochIndex) {
-        let _ = self.method_req.try_send((epoch, method)).unwrap();
+        let _ = self.method_send.try_send((epoch, method)).unwrap();
     }
 
     fn new_unmanaged_texture(
@@ -799,7 +799,7 @@ struct Stage {
     buffers: HashMap<GfxBufferId, miniquad::BufferId>,
 
     epoch: EpochIndex,
-    method_rep: async_channel::Receiver<(EpochIndex, GraphicsMethod)>,
+    method_recv: async_channel::Receiver<(EpochIndex, GraphicsMethod)>,
     event_pub: GraphicsEventPublisherPtr,
 
     pruner: PruneMethodHeap,
@@ -819,7 +819,7 @@ impl Stage {
         // This will start the app to start. Needed since we cannot get window size for init
         // until window is created.
         god.start_app(epoch);
-        let method_rep = god.method_rep.clone();
+        let method_recv = god.method_recv.clone();
         let event_pub = god.event_pub.clone();
 
         let white_texture = ctx.new_texture_from_rgba8(1, 1, &[255, 255, 255, 255]);
@@ -877,7 +877,7 @@ impl Stage {
             buffers: HashMap::new(),
 
             epoch,
-            method_rep,
+            method_recv,
             event_pub,
 
             pruner: PruneMethodHeap::new(epoch),
@@ -901,7 +901,7 @@ impl Stage {
             GraphicsMethod::DeleteBuffer((gbuff_id, _, _)) => self.method_delete_buffer(*gbuff_id),
             GraphicsMethod::ReplaceDrawCalls { timest, dcs } => {
                 let dcs = std::mem::take(dcs);
-                self.method_replace_draw_calls(*timest, dcs)
+                self.method_recvlace_draw_calls(*timest, dcs)
             }
         };
         if let Err(err) = res {
@@ -1029,7 +1029,7 @@ impl Stage {
         }
         Ok(())
     }
-    fn method_replace_draw_calls(
+    fn method_recvlace_draw_calls(
         &mut self,
         timest: Timestamp,
         dcs: Vec<(DcId, GfxDrawCall)>,
@@ -1129,9 +1129,9 @@ impl PruneMethodHeap {
         }
     }
 
-    fn drain(&mut self, method_rep: &async_channel::Receiver<(EpochIndex, GraphicsMethod)>) {
+    fn drain(&mut self, method_recv: &async_channel::Receiver<(EpochIndex, GraphicsMethod)>) {
         // Process as many methods as we can
-        while let Ok((epoch, method)) = method_rep.try_recv() {
+        while let Ok((epoch, method)) = method_recv.try_recv() {
             if epoch < self.epoch {
                 // Discard old rubbish
                 trace!(target: "gfx::pruner", "Discard method with old epoch: {epoch} curr: {} [method={method:?}]", self.epoch);
@@ -1164,12 +1164,12 @@ impl PruneMethodHeap {
                 }
             }
             GraphicsMethod::ReplaceDrawCalls { timest, dcs } => {
-                self.method_replace_draw_calls(timest, dcs)
+                self.method_recvlace_draw_calls(timest, dcs)
             }
         }
     }
 
-    fn method_replace_draw_calls(&mut self, timest: Timestamp, dcs: Vec<(DcId, GfxDrawCall)>) {
+    fn method_recvlace_draw_calls(&mut self, timest: Timestamp, dcs: Vec<(DcId, GfxDrawCall)>) {
         for (key, val) in dcs {
             match self.dcs.get_mut(&key) {
                 Some(old_val) => {
@@ -1208,7 +1208,7 @@ impl EventHandler for Stage {
     fn update(&mut self) {
         if self.egl_ctx_is_disabled() {
             // Screen is off so collect all methods into the pruner
-            self.pruner.drain(&self.method_rep);
+            self.pruner.drain(&self.method_recv);
             self.screen_was_off = true;
             return
         }
@@ -1234,7 +1234,7 @@ impl EventHandler for Stage {
         }
 
         // Process as many methods as we can
-        while let Ok((epoch, method)) = self.method_rep.try_recv() {
+        while let Ok((epoch, method)) = self.method_recv.try_recv() {
             if DEBUG_TRAX {
                 self.trax_method(epoch, &method);
             }

+ 4 - 4
bin/app/src/main.rs

@@ -113,7 +113,7 @@ struct God {
     /// We have a ref here so the gfx subsystem can increment the epoch counter.
     render_api: gfx::RenderApi,
     /// This is how the gfx subsystem receives messages from the render API.
-    method_rep: async_channel::Receiver<(gfx::EpochIndex, gfx::GraphicsMethod)>,
+    method_recv: async_channel::Receiver<(gfx::EpochIndex, gfx::GraphicsMethod)>,
     /// Publisher to send input and window events to subscribers.
     event_pub: gfx::GraphicsEventPublisherPtr,
 }
@@ -163,10 +163,10 @@ impl God {
 
         let fg_runtime = AsyncRuntime::new(fg_ex.clone(), "fg");
 
-        let (method_req, method_rep) = async_channel::unbounded();
+        let (method_send, method_recv) = async_channel::unbounded();
         // The UI actually needs to be running for this to reply back.
         // Otherwise calls will just hang.
-        let render_api = gfx::RenderApi::new(method_req);
+        let render_api = gfx::RenderApi::new(method_send);
         let event_pub = gfx::GraphicsEventPublisher::new();
 
         let text_shaper = TextShaper::new();
@@ -205,7 +205,7 @@ impl God {
             app,
 
             render_api,
-            method_rep,
+            method_recv,
             event_pub,
         }
     }