Просмотр исходного кода

wallet: draw calls now all share the same AtomicGuard

darkfi 1 год назад
Родитель
Сommit
f38bc410fa

+ 7 - 2
bin/darkwallet/src/ui/button.rs

@@ -25,7 +25,7 @@ use std::sync::{
 
 
 use crate::{
 use crate::{
     gfx::{GraphicsEventPublisherPtr, Point, Rectangle},
     gfx::{GraphicsEventPublisherPtr, Point, Rectangle},
-    prop::{PropertyBool, PropertyPtr, PropertyRect, PropertyUint32, Role},
+    prop::{PropertyAtomicGuard, PropertyBool, PropertyPtr, PropertyRect, PropertyUint32, Role},
     pubsub::Subscription,
     pubsub::Subscription,
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     ExecutorPtr,
     ExecutorPtr,
@@ -78,7 +78,12 @@ impl UIObject for Button {
         self.priority.get()
         self.priority.get()
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         let _ = self.rect.eval(&parent_rect);
         let _ = self.rect.eval(&parent_rect);
         None
         None
     }
     }

+ 6 - 2
bin/darkwallet/src/ui/chatedit.rs

@@ -1964,9 +1964,13 @@ impl UIObject for ChatEdit {
         self.tasks.set(tasks);
         self.tasks.set(tasks);
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("ChatEdit::draw({:?}, {trace_id})", self.node.upgrade().unwrap());
         t!("ChatEdit::draw({:?}, {trace_id})", self.node.upgrade().unwrap());
-        let atom = &mut PropertyAtomicGuard::new();
         *self.parent_rect.lock() = Some(parent_rect);
         *self.parent_rect.lock() = Some(parent_rect);
 
 
         self.make_draw_calls(trace_id, atom)
         self.make_draw_calls(trace_id, atom)

+ 6 - 2
bin/darkwallet/src/ui/chatview/mod.rs

@@ -809,9 +809,13 @@ impl UIObject for ChatView {
         self.tasks.set(tasks);
         self.tasks.set(tasks);
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("ChatView::draw({:?}, {trace_id})", self.node.upgrade().unwrap());
         t!("ChatView::draw({:?}, {trace_id})", self.node.upgrade().unwrap());
-        let atom = &mut PropertyAtomicGuard::new();
 
 
         *self.parent_rect.lock().unwrap() = Some(parent_rect.clone());
         *self.parent_rect.lock().unwrap() = Some(parent_rect.clone());
         self.rect.eval(&parent_rect).ok()?;
         self.rect.eval(&parent_rect).ok()?;

+ 6 - 2
bin/darkwallet/src/ui/editbox/mod.rs

@@ -1332,9 +1332,13 @@ impl UIObject for EditBox {
         self.tasks.set(tasks);
         self.tasks.set(tasks);
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("EditBox::draw() [trace_id={trace_id}]");
         t!("EditBox::draw() [trace_id={trace_id}]");
-        let atom = &mut PropertyAtomicGuard::new();
 
 
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         self.rect.eval(&parent_rect).ok()?;
         self.rect.eval(&parent_rect).ok()?;

+ 6 - 2
bin/darkwallet/src/ui/emoji_picker/mod.rs

@@ -340,9 +340,13 @@ impl UIObject for EmojiPicker {
         self.tasks.set(on_modify.tasks);
         self.tasks.set(on_modify.tasks);
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("EmojiPicker::draw({parent_rect:?}, {trace_id})");
         t!("EmojiPicker::draw({parent_rect:?}, {trace_id})");
-        let atom = &mut PropertyAtomicGuard::new();
 
 
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         self.get_draw_calls(parent_rect, trace_id, atom)
         self.get_draw_calls(parent_rect, trace_id, atom)

+ 7 - 2
bin/darkwallet/src/ui/image.rs

@@ -30,7 +30,7 @@ use crate::{
         RenderApi,
         RenderApi,
     },
     },
     mesh::{MeshBuilder, MeshInfo, COLOR_WHITE},
     mesh::{MeshBuilder, MeshInfo, COLOR_WHITE},
-    prop::{PropertyPtr, PropertyRect, PropertyStr, PropertyUint32, Role},
+    prop::{PropertyAtomicGuard, PropertyPtr, PropertyRect, PropertyStr, PropertyUint32, Role},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     util::unixtime,
     util::unixtime,
     ExecutorPtr,
     ExecutorPtr,
@@ -204,7 +204,12 @@ impl UIObject for Image {
         self.tasks.set(on_modify.tasks);
         self.tasks.set(on_modify.tasks);
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("Image::draw() [trace_id={trace_id}]");
         t!("Image::draw() [trace_id={trace_id}]");
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         self.get_draw_calls(parent_rect, trace_id).await
         self.get_draw_calls(parent_rect, trace_id).await

+ 20 - 6
bin/darkwallet/src/ui/layer.rs

@@ -25,7 +25,10 @@ use std::sync::{atomic::Ordering, Arc, Mutex as SyncMutex, OnceLock, Weak};
 
 
 use crate::{
 use crate::{
     gfx::{GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApi},
     gfx::{GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApi},
-    prop::{PropertyBool, PropertyFloat32, PropertyPtr, PropertyRect, PropertyUint32, Role},
+    prop::{
+        PropertyAtomicGuard, PropertyBool, PropertyFloat32, PropertyPtr, PropertyRect,
+        PropertyUint32, Role,
+    },
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     util::unixtime,
     util::unixtime,
     ExecutorPtr,
     ExecutorPtr,
@@ -89,12 +92,13 @@ impl Layer {
     }
     }
 
 
     async fn redraw(self: Arc<Self>) {
     async fn redraw(self: Arc<Self>) {
+        let atom = &mut PropertyAtomicGuard::new();
         let trace_id = rand::random();
         let trace_id = rand::random();
         let timest = unixtime();
         let timest = unixtime();
         t!("Layer::redraw({:?}) [trace_id={trace_id}]", self.node.upgrade().unwrap());
         t!("Layer::redraw({:?}) [trace_id={trace_id}]", self.node.upgrade().unwrap());
         let Some(parent_rect) = self.parent_rect.lock().unwrap().clone() else { return };
         let Some(parent_rect) = self.parent_rect.lock().unwrap().clone() else { return };
 
 
-        let Some(draw_update) = self.get_draw_calls(parent_rect, trace_id).await else {
+        let Some(draw_update) = self.get_draw_calls(parent_rect, trace_id, atom).await else {
             error!(target: "ui::layer", "Layer failed to draw [trace_id={trace_id}]");
             error!(target: "ui::layer", "Layer failed to draw [trace_id={trace_id}]");
             return;
             return;
         };
         };
@@ -105,7 +109,12 @@ impl Layer {
         );
         );
     }
     }
 
 
-    async fn get_draw_calls(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn get_draw_calls(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         self.rect.eval(&parent_rect).ok()?;
         self.rect.eval(&parent_rect).ok()?;
         let rect = self.rect.get();
         let rect = self.rect.get();
         t!("Layer::get_draw_calls() [rect={rect:?}, dc={}, trace_id={trace_id}]", self.dc_key);
         t!("Layer::get_draw_calls() [rect={rect:?}, dc={}, trace_id={trace_id}]", self.dc_key);
@@ -120,7 +129,7 @@ impl Layer {
         if self.is_visible.get() {
         if self.is_visible.get() {
             for child in self.get_children() {
             for child in self.get_children() {
                 let obj = get_ui_object3(&child);
                 let obj = get_ui_object3(&child);
-                let Some(mut draw_update) = obj.draw(rect, trace_id).await else {
+                let Some(mut draw_update) = obj.draw(rect, trace_id, atom).await else {
                     t!("Skipped draw for {child:?} [trace_id={trace_id}]");
                     t!("Skipped draw for {child:?} [trace_id={trace_id}]");
                     continue
                     continue
                 };
                 };
@@ -162,7 +171,12 @@ impl UIObject for Layer {
         }
         }
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("Layer::draw({:?}) [trace_id={trace_id}]", self.node.upgrade().unwrap());
         t!("Layer::draw({:?}) [trace_id={trace_id}]", self.node.upgrade().unwrap());
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
 
 
@@ -177,7 +191,7 @@ impl UIObject for Layer {
         }
         }
         */
         */
 
 
-        let update = self.get_draw_calls(parent_rect, trace_id).await;
+        let update = self.get_draw_calls(parent_rect, trace_id, atom).await;
         t!("Layer::draw({:?}) DONE [trace_id={trace_id}]", self.node.upgrade().unwrap());
         t!("Layer::draw({:?}) DONE [trace_id={trace_id}]", self.node.upgrade().unwrap());
         update
         update
     }
     }

+ 7 - 2
bin/darkwallet/src/ui/mod.rs

@@ -29,7 +29,7 @@ use crate::{
     error::{Error, Result},
     error::{Error, Result},
     expr::{SExprMachine, SExprVal},
     expr::{SExprMachine, SExprVal},
     gfx::{GfxBufferId, GfxDrawCall, GfxDrawMesh, GfxTextureId, Point, Rectangle},
     gfx::{GfxBufferId, GfxDrawCall, GfxDrawMesh, GfxTextureId, Point, Rectangle},
-    prop::{ModifyAction, PropertyPtr, Role},
+    prop::{ModifyAction, PropertyAtomicGuard, PropertyPtr, Role},
     scene::{Pimpl, SceneNode as SceneNode3, SceneNodeId, SceneNodePtr, SceneNodeWeak},
     scene::{Pimpl, SceneNode as SceneNode3, SceneNodeId, SceneNodePtr, SceneNodeWeak},
     ExecutorPtr,
     ExecutorPtr,
 };
 };
@@ -69,7 +69,12 @@ pub trait UIObject: Sync {
 
 
     async fn start(self: Arc<Self>, ex: ExecutorPtr) {}
     async fn start(self: Arc<Self>, ex: ExecutorPtr) {}
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         None
         None
     }
     }
 
 

+ 8 - 3
bin/darkwallet/src/ui/text.rs

@@ -27,8 +27,8 @@ use crate::{
     },
     },
     mesh::{Color, MeshBuilder, MeshInfo, COLOR_BLUE, COLOR_RED, COLOR_WHITE},
     mesh::{Color, MeshBuilder, MeshInfo, COLOR_BLUE, COLOR_RED, COLOR_WHITE},
     prop::{
     prop::{
-        PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyRect, PropertyStr,
-        PropertyUint32, Role,
+        PropertyAtomicGuard, PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr,
+        PropertyRect, PropertyStr, PropertyUint32, Role,
     },
     },
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     text::{self, GlyphPositionIter, TextShaper, TextShaperPtr},
     text::{self, GlyphPositionIter, TextShaper, TextShaperPtr},
@@ -221,7 +221,12 @@ impl UIObject for Text {
         self.tasks.set(on_modify.tasks);
         self.tasks.set(on_modify.tasks);
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("Text::draw({:?}) [trace_id={trace_id}]", self.node.upgrade().unwrap());
         t!("Text::draw({:?}) [trace_id={trace_id}]", self.node.upgrade().unwrap());
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         self.get_draw_calls(parent_rect, trace_id).await
         self.get_draw_calls(parent_rect, trace_id).await

+ 10 - 2
bin/darkwallet/src/ui/vector_art/mod.rs

@@ -27,7 +27,10 @@ use crate::{
         GfxBufferId, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Rectangle, RenderApi, Vertex,
         GfxBufferId, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Rectangle, RenderApi, Vertex,
     },
     },
     mesh::Color,
     mesh::Color,
-    prop::{PropertyBool, PropertyFloat32, PropertyPtr, PropertyRect, PropertyUint32, Role},
+    prop::{
+        PropertyAtomicGuard, PropertyBool, PropertyFloat32, PropertyPtr, PropertyRect,
+        PropertyUint32, Role,
+    },
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     util::{enumerate, unixtime},
     util::{enumerate, unixtime},
     ExecutorPtr,
     ExecutorPtr,
@@ -168,7 +171,12 @@ impl UIObject for VectorArt {
         self.tasks.set(on_modify.tasks);
         self.tasks.set(on_modify.tasks);
     }
     }
 
 
-    async fn draw(&self, parent_rect: Rectangle, trace_id: u32) -> Option<DrawUpdate> {
+    async fn draw(
+        &self,
+        parent_rect: Rectangle,
+        trace_id: u32,
+        atom: &mut PropertyAtomicGuard,
+    ) -> Option<DrawUpdate> {
         t!("VectorArt::draw({}) [trace_id={trace_id}]", self.node_path());
         t!("VectorArt::draw({}) [trace_id={trace_id}]", self.node_path());
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         *self.parent_rect.lock().unwrap() = Some(parent_rect);
         self.get_draw_calls(parent_rect, trace_id).await
         self.get_draw_calls(parent_rect, trace_id).await

+ 2 - 1
bin/darkwallet/src/ui/win.rs

@@ -441,6 +441,7 @@ impl Window {
     }
     }
 
 
     pub async fn draw(&self) {
     pub async fn draw(&self) {
+        let atom = &mut PropertyAtomicGuard::new();
         let trace_id = rand::random();
         let trace_id = rand::random();
         let timest = unixtime();
         let timest = unixtime();
 
 
@@ -453,7 +454,7 @@ impl Window {
 
 
         for child in self.get_children() {
         for child in self.get_children() {
             let obj = get_ui_object3(&child);
             let obj = get_ui_object3(&child);
-            let Some(mut draw_update) = obj.draw(rect, trace_id).await else {
+            let Some(mut draw_update) = obj.draw(rect, trace_id, atom).await else {
                 error!(target: "ui::layer", "draw() of {child:?} failed [trace_id={trace_id}]");
                 error!(target: "ui::layer", "draw() of {child:?} failed [trace_id={trace_id}]");
                 continue
                 continue
             };
             };