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

wallet: delete RenderApiPtr, since mpsc::Sender is Cloneable, we can just use RenderApi directly

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

+ 3 - 3
bin/darkwallet/src/app/mod.rs

@@ -32,7 +32,7 @@ use crate::{
     darkirc::DarkIrcBackendPtr,
     error::Error,
     expr::Op,
-    gfx::{GraphicsEventPublisherPtr, RenderApiPtr, Vertex},
+    gfx::{GraphicsEventPublisherPtr, RenderApi, Vertex},
     prop::{Property, PropertyBool, PropertyStr, PropertySubType, PropertyType, Role},
     scene::{Pimpl, SceneNode as SceneNode3, SceneNodePtr, SceneNodeType as SceneNodeType3},
     text::TextShaperPtr,
@@ -118,7 +118,7 @@ pub type AppPtr = Arc<App>;
 
 pub struct App {
     pub sg_root: SceneNodePtr,
-    pub render_api: RenderApiPtr,
+    pub render_api: RenderApi,
     pub event_pub: GraphicsEventPublisherPtr,
     pub text_shaper: TextShaperPtr,
     pub darkirc_evgr: SyncMutex<Option<DarkIrcBackendPtr>>,
@@ -129,7 +129,7 @@ pub struct App {
 impl App {
     pub fn new(
         sg_root: SceneNodePtr,
-        render_api: RenderApiPtr,
+        render_api: RenderApi,
         event_pub: GraphicsEventPublisherPtr,
         text_shaper: TextShaperPtr,
         ex: ExecutorPtr,

+ 1 - 1
bin/darkwallet/src/app/node.rs

@@ -19,7 +19,7 @@
 use crate::{
     error::Error,
     expr::Op,
-    gfx::{GraphicsEventPublisherPtr, RenderApiPtr, Vertex},
+    gfx::{GraphicsEventPublisherPtr, Vertex},
     prop::{Property, PropertyBool, PropertyStr, PropertySubType, PropertyType, Role},
     scene::{CallArgType, SceneNode, SceneNodeType, Slot},
     text::TextShaperPtr,

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

@@ -21,7 +21,7 @@ use sled_overlay::sled;
 use crate::{
     error::Error,
     expr::{self, Compiler, Op},
-    gfx::{GraphicsEventPublisherPtr, Rectangle, RenderApiPtr, Vertex},
+    gfx::{GraphicsEventPublisherPtr, Rectangle, RenderApi, Vertex},
     mesh::{Color, MeshBuilder},
     prop::{
         Property, PropertyBool, PropertyFloat32, PropertyStr, PropertySubType, PropertyType, Role,

+ 3 - 4
bin/darkwallet/src/gfx/mod.rs

@@ -68,15 +68,14 @@ impl Vertex {
     }
 }
 
-pub type RenderApiPtr = Arc<RenderApi>;
-
+#[derive(Clone)]
 pub struct RenderApi {
     method_req: mpsc::Sender<GraphicsMethod>,
 }
 
 impl RenderApi {
-    pub fn new(method_req: mpsc::Sender<GraphicsMethod>) -> Arc<Self> {
-        Arc::new(Self { method_req })
+    pub fn new(method_req: mpsc::Sender<GraphicsMethod>) -> Self {
+        Self { method_req }
     }
 
     pub fn new_texture(&self, width: u16, height: u16, data: Vec<u8>) -> GfxTextureId {

+ 1 - 1
bin/darkwallet/src/text/old_atlas.rs

@@ -2,7 +2,7 @@ use miniquad::TextureId;
 
 use crate::{
     error::Result,
-    gfx::{Rectangle, RenderApi, RenderApiPtr},
+    gfx::{Rectangle, RenderApi},
     util::ansi_texture,
 };
 

+ 3 - 3
bin/darkwallet/src/ui/chatview/mod.rs

@@ -41,7 +41,7 @@ use page::MessageBuffer;
 use crate::{
     gfx::{
         GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GraphicsEventPublisherPtr, Point, Rectangle,
-        RenderApi, RenderApiPtr,
+        RenderApi,
     },
     mesh::{Color, MeshBuilder, COLOR_BLUE, COLOR_GREEN},
     prop::{
@@ -151,7 +151,7 @@ pub struct ChatView {
     node: SceneNodeWeak,
     #[allow(dead_code)]
     tasks: Vec<smol::Task<()>>,
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
     text_shaper: TextShaperPtr,
 
     tree: sled::Tree,
@@ -190,7 +190,7 @@ impl ChatView {
         node: SceneNodeWeak,
         tree: sled::Tree,
         window_scale: PropertyFloat32,
-        render_api: RenderApiPtr,
+        render_api: RenderApi,
         text_shaper: TextShaperPtr,
         ex: ExecutorPtr,
     ) -> Pimpl {

+ 3 - 3
bin/darkwallet/src/ui/chatview/page.rs

@@ -32,7 +32,7 @@ use super::{max, MessageId, Timestamp};
 use crate::{
     gfx::{
         GfxBufferId, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GfxTextureId,
-        GraphicsEventPublisherPtr, Point, Rectangle, RenderApi, RenderApiPtr,
+        GraphicsEventPublisherPtr, Point, Rectangle, RenderApi,
     },
     mesh::{Color, MeshBuilder, COLOR_BLUE, COLOR_GREEN, COLOR_PINK},
     prop::{PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyUint32, Role},
@@ -636,7 +636,7 @@ pub struct MessageBuffer {
     /// If it does then we must reload the glyphs too.
     old_window_scale: f32,
 
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
     text_shaper: TextShaperPtr,
 }
 
@@ -655,7 +655,7 @@ impl MessageBuffer {
         hi_bg_color: PropertyColor,
         debug: PropertyBool,
         window_scale: PropertyFloat32,
-        render_api: RenderApiPtr,
+        render_api: RenderApi,
         text_shaper: TextShaperPtr,
     ) -> Self {
         let old_window_scale = window_scale.get();

+ 3 - 3
bin/darkwallet/src/ui/editbox.rs

@@ -35,7 +35,7 @@ use crate::{
     error::Result,
     gfx::{
         GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GfxTextureId, GraphicsEventPublisherPtr,
-        Point, Rectangle, RenderApiPtr,
+        Point, Rectangle, RenderApi,
     },
     mesh::{MeshBuilder, MeshInfo, COLOR_BLUE, COLOR_WHITE},
     prop::{
@@ -261,7 +261,7 @@ pub struct EditBox {
     node: SceneNodeWeak,
     #[allow(dead_code)]
     tasks: Vec<smol::Task<()>>,
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
     text_shaper: TextShaperPtr,
     key_repeat: SyncMutex<PressedKeysSmoothRepeat>,
 
@@ -307,7 +307,7 @@ impl EditBox {
     pub async fn new(
         node: SceneNodeWeak,
         window_scale: PropertyFloat32,
-        render_api: RenderApiPtr,
+        render_api: RenderApi,
         text_shaper: TextShaperPtr,
         ex: ExecutorPtr,
     ) -> Pimpl {

+ 3 - 3
bin/darkwallet/src/ui/image.rs

@@ -25,7 +25,7 @@ use std::{
 };
 
 use crate::{
-    gfx::{GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GfxTextureId, Rectangle, RenderApiPtr},
+    gfx::{GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GfxTextureId, Rectangle, RenderApi},
     mesh::{MeshBuilder, MeshInfo, COLOR_WHITE},
     prop::{PropertyPtr, PropertyRect, PropertyStr, PropertyUint32, Role},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
@@ -38,7 +38,7 @@ pub type ImagePtr = Arc<Image>;
 
 pub struct Image {
     node: SceneNodeWeak,
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
     #[allow(dead_code)]
     tasks: Vec<smol::Task<()>>,
 
@@ -55,7 +55,7 @@ pub struct Image {
 }
 
 impl Image {
-    pub async fn new(node: SceneNodeWeak, render_api: RenderApiPtr, ex: ExecutorPtr) -> Pimpl {
+    pub async fn new(node: SceneNodeWeak, render_api: RenderApi, ex: ExecutorPtr) -> Pimpl {
         debug!(target: "ui::image", "Image::new()");
 
         let node_ref = &node.upgrade().unwrap();

+ 3 - 3
bin/darkwallet/src/ui/layer.rs

@@ -24,7 +24,7 @@ use rand::{rngs::OsRng, Rng};
 use std::sync::{atomic::Ordering, Arc, Mutex as SyncMutex, Weak};
 
 use crate::{
-    gfx::{GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApiPtr},
+    gfx::{GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApi},
     prop::{PropertyBool, PropertyFloat32, PropertyPtr, PropertyRect, PropertyUint32, Role},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     ExecutorPtr,
@@ -36,7 +36,7 @@ pub type LayerPtr = Arc<Layer>;
 
 pub struct Layer {
     node: SceneNodeWeak,
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
     _tasks: Vec<smol::Task<()>>,
     dc_key: u64,
 
@@ -48,7 +48,7 @@ pub struct Layer {
 }
 
 impl Layer {
-    pub async fn new(node: SceneNodeWeak, render_api: RenderApiPtr, ex: ExecutorPtr) -> Pimpl {
+    pub async fn new(node: SceneNodeWeak, render_api: RenderApi, ex: ExecutorPtr) -> Pimpl {
         debug!(target: "ui::layer", "Layer::new()");
 
         let node_ref = &node.upgrade().unwrap();

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

@@ -21,10 +21,7 @@ use rand::{rngs::OsRng, Rng};
 use std::sync::{Arc, Mutex as SyncMutex, Weak};
 
 use crate::{
-    gfx::{
-        GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GfxTextureId, Rectangle, RenderApi,
-        RenderApiPtr,
-    },
+    gfx::{GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GfxTextureId, Rectangle, RenderApi},
     mesh::{Color, MeshBuilder, MeshInfo, COLOR_BLUE, COLOR_WHITE},
     prop::{
         PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr, PropertyRect, PropertyStr,
@@ -47,7 +44,7 @@ struct TextRenderInfo {
 
 pub struct Text {
     node: SceneNodeWeak,
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
     text_shaper: TextShaperPtr,
     _tasks: Vec<smol::Task<()>>,
 
@@ -70,7 +67,7 @@ impl Text {
     pub async fn new(
         node: SceneNodeWeak,
         window_scale: PropertyFloat32,
-        render_api: RenderApiPtr,
+        render_api: RenderApi,
         text_shaper: TextShaperPtr,
         ex: ExecutorPtr,
     ) -> Pimpl {

+ 3 - 3
bin/darkwallet/src/ui/vector_art/mod.rs

@@ -24,7 +24,7 @@ use crate::{
     error::{Error, Result},
     expr::{Op, SExprCode, SExprMachine, SExprVal},
     gfx::{
-        GfxBufferId, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Rectangle, RenderApiPtr, Vertex,
+        GfxBufferId, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Rectangle, RenderApi, Vertex,
     },
     mesh::Color,
     prop::{PropertyFloat32, PropertyPtr, PropertyRect, PropertyUint32, Role},
@@ -42,7 +42,7 @@ pub type VectorArtPtr = Arc<VectorArt>;
 
 pub struct VectorArt {
     node: SceneNodeWeak,
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
     _tasks: Vec<smol::Task<()>>,
 
     shape: VectorShape,
@@ -59,7 +59,7 @@ impl VectorArt {
     pub async fn new(
         node: SceneNodeWeak,
         shape: VectorShape,
-        render_api: RenderApiPtr,
+        render_api: RenderApi,
         ex: ExecutorPtr,
     ) -> Pimpl {
         debug!(target: "ui::vector_art", "VectorArt::new()");

+ 1 - 3
bin/darkwallet/src/ui/vector_art/shape.rs

@@ -19,9 +19,7 @@
 use crate::{
     error::{Error, Result},
     expr::{Op, SExprCode, SExprMachine, SExprVal},
-    gfx::{
-        GfxBufferId, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Rectangle, RenderApiPtr, Vertex,
-    },
+    gfx::{GfxBufferId, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Rectangle, Vertex},
     mesh::Color,
     prop::{PropertyPtr, PropertyUint32, Role},
     util::enumerate,

+ 3 - 3
bin/darkwallet/src/ui/win.rs

@@ -21,7 +21,7 @@ use std::sync::{Arc, Weak};
 
 use crate::{
     gfx::{
-        GfxDrawCall, GfxDrawInstruction, GraphicsEventPublisherPtr, Point, Rectangle, RenderApiPtr,
+        GfxDrawCall, GfxDrawInstruction, GraphicsEventPublisherPtr, Point, Rectangle, RenderApi,
     },
     prop::{PropertyDimension, PropertyFloat32, PropertyPtr, Role},
     pubsub::Subscription,
@@ -41,13 +41,13 @@ pub struct Window {
     tasks: Vec<smol::Task<()>>,
     screen_size: PropertyDimension,
     scale: PropertyFloat32,
-    render_api: RenderApiPtr,
+    render_api: RenderApi,
 }
 
 impl Window {
     pub async fn new(
         node: SceneNodeWeak,
-        render_api: RenderApiPtr,
+        render_api: RenderApi,
         event_pub: GraphicsEventPublisherPtr,
         ex: ExecutorPtr,
     ) -> Pimpl {