فهرست منبع

app/gfx: use Gfx prefix for internal identifiers, swapping place with external identifiers that currently use it

darkfi 11 ماه پیش
والد
کامیت
5a261ceb83

+ 0 - 3
bin/app/src/error.rs

@@ -107,9 +107,6 @@ pub enum Error {
     #[error("S-expr global not found")]
     SExprGlobalNotFound = 32,
 
-    #[error("Graphics window closed")]
-    GfxWindowClosed = 33,
-
     #[error("Publisher was destroyed")]
     PublisherDestroyed = 34,
 

+ 30 - 30
bin/app/src/gfx/anim.rs

@@ -28,16 +28,16 @@ use std::{
     },
 };
 
-use super::{DrawCall, GfxBufferId, GfxDrawCall, GfxTextureId};
+use super::{BufferId, DrawCall, GfxDrawCall, TextureId};
 
 // This can be in instruction but also implement encodable
 // maybe just remove trax?
 
 /*
-type GfxFrameOpt = Arc<RwLock<Option<GfxSequenceAnimationFrame>>>;
+type FrameOpt = Arc<RwLock<Option<SequenceAnimationFrame>>>;
 
 pub struct SequenceAnimBuffer {
-    frames: Vec<GfxFrameOpt>
+    frames: Vec<FrameOpt>
 }
 
 impl SequenceAnimBuffer {
@@ -47,48 +47,48 @@ impl SequenceAnimBuffer {
 */
 
 #[derive(Debug, Clone, SerialEncodable)]
-pub struct GfxSequenceAnimation {
+pub struct SequenceAnimation {
     oneshot: bool,
-    frames: Vec<GfxSequenceAnimationFrame>,
+    frames: Vec<SequenceAnimationFrame>,
 }
 
-impl GfxSequenceAnimation {
-    pub fn new(oneshot: bool, frames: Vec<GfxSequenceAnimationFrame>) -> Self {
+impl SequenceAnimation {
+    pub fn new(oneshot: bool, frames: Vec<SequenceAnimationFrame>) -> Self {
         //let frames = frames.into_iter().map(|f| Arc::new(RwLock::new(
         Self { oneshot, frames }
     }
 
     pub(super) fn compile(
         self: Self,
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
-    ) -> SequenceAnimation {
+        textures: &HashMap<TextureId, miniquad::TextureId>,
+        buffers: &HashMap<BufferId, miniquad::BufferId>,
+    ) -> GfxSequenceAnimation {
         let mut frames = Vec::with_capacity(self.frames.len());
         for gfxframe in self.frames {
             let duration = std::time::Duration::from_millis(gfxframe.duration as u64);
             let dc = gfxframe.dc.compile(textures, buffers, 0).unwrap();
-            frames.push(SequenceAnimationFrame { duration, dc });
+            frames.push(GfxGfxSequenceAnimationFrame { duration, dc });
         }
-        SequenceAnimation::new(self.oneshot, frames)
+        GfxSequenceAnimation::new(self.oneshot, frames)
     }
 }
 
 #[derive(Debug, Clone)]
-pub struct GfxSequenceAnimationFrame {
+pub struct SequenceAnimationFrame {
     /// Duration of this frame in ms
     duration: u32,
-    dc: GfxDrawCall,
+    dc: DrawCall,
 }
 
-impl GfxSequenceAnimationFrame {
-    pub fn new(duration: u32, dc: GfxDrawCall) -> Self {
+impl SequenceAnimationFrame {
+    pub fn new(duration: u32, dc: DrawCall) -> Self {
         Self { duration, dc }
     }
 }
 
 /// We have to implement this manually due to macro autism.
-/// Since it contains GfxDrawCall that contains Instruction that can contain this.
-impl Encodable for GfxSequenceAnimationFrame {
+/// Since it contains DrawCall that contains Instruction that can contain this.
+impl Encodable for SequenceAnimationFrame {
     fn encode<S: Write>(&self, s: &mut S) -> std::result::Result<usize, std::io::Error> {
         let mut len = 0;
         len += self.duration.encode(s)?;
@@ -97,7 +97,7 @@ impl Encodable for GfxSequenceAnimationFrame {
     }
 }
 #[async_trait]
-impl AsyncEncodable for GfxSequenceAnimationFrame {
+impl AsyncEncodable for SequenceAnimationFrame {
     async fn encode_async<W: AsyncWrite + Unpin + Send>(
         &self,
         w: &mut W,
@@ -110,23 +110,23 @@ impl AsyncEncodable for GfxSequenceAnimationFrame {
 }
 
 #[derive(Debug, Clone)]
-pub(super) struct SequenceAnimation {
+pub(super) struct GfxSequenceAnimation {
     oneshot: bool,
-    frames: Vec<SequenceAnimationFrame>,
-    //incoming_frames: Vec<Arc<RwLock<Option<GfxSequenceAnimationFrame>>>>,
-    state: RefCell<SequenceAnimationState>,
+    frames: Vec<GfxGfxSequenceAnimationFrame>,
+    //incoming_frames: Vec<Arc<RwLock<Option<SequenceAnimationFrame>>>>,
+    state: RefCell<GfxSequenceAnimationState>,
 }
 
-impl SequenceAnimation {
-    fn new(oneshot: bool, frames: Vec<SequenceAnimationFrame>) -> Self {
+impl GfxSequenceAnimation {
+    fn new(oneshot: bool, frames: Vec<GfxGfxSequenceAnimationFrame>) -> Self {
         Self {
             oneshot,
             frames,
-            state: RefCell::new(SequenceAnimationState { timer: None, current_idx: 0 }),
+            state: RefCell::new(GfxSequenceAnimationState { timer: None, current_idx: 0 }),
         }
     }
 
-    pub fn tick(&self) -> DrawCall {
+    pub fn tick(&self) -> GfxDrawCall {
         let mut state = self.state.borrow_mut();
 
         let elapsed = state.timer.get_or_insert_with(|| std::time::Instant::now()).elapsed();
@@ -140,13 +140,13 @@ impl SequenceAnimation {
 }
 
 #[derive(Debug, Clone)]
-struct SequenceAnimationFrame {
+struct GfxGfxSequenceAnimationFrame {
     duration: std::time::Duration,
-    dc: DrawCall,
+    dc: GfxDrawCall,
 }
 
 #[derive(Debug, Clone)]
-struct SequenceAnimationState {
+struct GfxSequenceAnimationState {
     /// Timer between frames
     timer: Option<std::time::Instant>,
     current_idx: usize,

+ 93 - 95
bin/app/src/gfx/mod.rs

@@ -100,8 +100,8 @@ impl Vertex {
     }
 }
 
-pub type GfxTextureId = u32;
-pub type GfxBufferId = u32;
+pub type TextureId = u32;
+pub type BufferId = u32;
 
 static NEXT_BUFFER_ID: AtomicU32 = AtomicU32::new(0);
 static NEXT_TEXTURE_ID: AtomicU32 = AtomicU32::new(0);
@@ -111,7 +111,7 @@ pub type ManagedTexturePtr = Arc<ManagedTexture>;
 /// Auto-deletes texture on drop
 #[derive(Clone)]
 pub struct ManagedTexture {
-    id: GfxTextureId,
+    id: TextureId,
     epoch: u32,
     render_api: RenderApi,
     tag: DebugTag,
@@ -134,7 +134,7 @@ pub type ManagedBufferPtr = Arc<ManagedBuffer>;
 /// Auto-deletes buffer on drop
 #[derive(Clone)]
 pub struct ManagedBuffer {
-    id: GfxBufferId,
+    id: BufferId,
     epoch: u32,
     render_api: RenderApi,
     tag: DebugTag,
@@ -187,7 +187,7 @@ impl RenderApi {
         height: u16,
         data: Vec<u8>,
         tag: DebugTag,
-    ) -> (GfxTextureId, EpochIndex) {
+    ) -> (TextureId, EpochIndex) {
         let gfx_texture_id = NEXT_TEXTURE_ID.fetch_add(1, Ordering::Relaxed);
 
         let method = GraphicsMethod::NewTexture((width, height, data, gfx_texture_id, tag));
@@ -207,7 +207,7 @@ impl RenderApi {
         Arc::new(ManagedTexture { id, epoch, render_api: self.clone(), tag })
     }
 
-    fn delete_unmanaged_texture(&self, texture: GfxTextureId, epoch: EpochIndex, tag: DebugTag) {
+    fn delete_unmanaged_texture(&self, texture: TextureId, epoch: EpochIndex, tag: DebugTag) {
         let method = GraphicsMethod::DeleteTexture((texture, tag));
         self.send_with_epoch(method, epoch);
     }
@@ -216,7 +216,7 @@ impl RenderApi {
         &self,
         verts: Vec<Vertex>,
         tag: DebugTag,
-    ) -> (GfxBufferId, EpochIndex) {
+    ) -> (BufferId, EpochIndex) {
         let gfx_buffer_id = NEXT_BUFFER_ID.fetch_add(1, Ordering::Relaxed);
 
         let method = GraphicsMethod::NewVertexBuffer((verts, gfx_buffer_id, tag));
@@ -229,7 +229,7 @@ impl RenderApi {
         &self,
         indices: Vec<u16>,
         tag: DebugTag,
-    ) -> (GfxBufferId, EpochIndex) {
+    ) -> (BufferId, EpochIndex) {
         let gfx_buffer_id = NEXT_BUFFER_ID.fetch_add(1, Ordering::Relaxed);
 
         let method = GraphicsMethod::NewIndexBuffer((indices, gfx_buffer_id, tag));
@@ -249,7 +249,7 @@ impl RenderApi {
 
     fn delete_unmanaged_buffer(
         &self,
-        buffer: GfxBufferId,
+        buffer: BufferId,
         epoch: EpochIndex,
         tag: DebugTag,
         buftype: u8,
@@ -262,9 +262,9 @@ impl RenderApi {
         &self,
         batch_id: BatchGuardId,
         timest: Timestamp,
-        dcs: Vec<(DcId, GfxDrawCall)>,
+        dcs: Vec<(DcId, DrawCall)>,
     ) {
-        let method = GraphicsMethod::ReplaceDrawCalls { batch_id, timest, dcs };
+        let method = GraphicsMethod::ReplaceGfxDrawCalls { batch_id, timest, dcs };
         self.send(method);
     }
 
@@ -287,20 +287,20 @@ impl RenderApi {
 }
 
 #[derive(Clone, Debug)]
-pub struct GfxDrawMesh {
+pub struct DrawMesh {
     pub vertex_buffer: ManagedBufferPtr,
     pub index_buffer: ManagedBufferPtr,
     pub texture: Option<ManagedTexturePtr>,
     pub num_elements: i32,
 }
 
-impl GfxDrawMesh {
+impl DrawMesh {
     fn compile(
         self,
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
+        textures: &HashMap<TextureId, miniquad::TextureId>,
+        buffers: &HashMap<BufferId, miniquad::BufferId>,
         debug_str: &'static str,
-    ) -> Option<DrawMesh> {
+    ) -> Option<GfxDrawMesh> {
         let vertex_buffer_id = self.vertex_buffer.id;
         let index_buffer_id = self.index_buffer.id;
         let _buffers_keep_alive = [self.vertex_buffer, self.index_buffer];
@@ -308,7 +308,7 @@ impl GfxDrawMesh {
             Some(gfx_texture) => Self::try_get_texture(textures, gfx_texture, debug_str),
             None => None,
         };
-        Some(DrawMesh {
+        Some(GfxDrawMesh {
             vertex_buffer: Self::try_get_buffer(buffers, vertex_buffer_id, debug_str)?,
             index_buffer: Self::try_get_buffer(buffers, index_buffer_id, debug_str)?,
             _buffers_keep_alive,
@@ -318,7 +318,7 @@ impl GfxDrawMesh {
     }
 
     fn try_get_texture(
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
+        textures: &HashMap<TextureId, miniquad::TextureId>,
         gfx_texture: ManagedTexturePtr,
         debug_str: &'static str,
     ) -> Option<(ManagedTexturePtr, miniquad::TextureId)> {
@@ -338,8 +338,8 @@ impl GfxDrawMesh {
     }
 
     fn try_get_buffer(
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
-        gfx_buffer_id: GfxBufferId,
+        buffers: &HashMap<BufferId, miniquad::BufferId>,
+        gfx_buffer_id: BufferId,
         debug_str: &'static str,
     ) -> Option<miniquad::BufferId> {
         let Some(mq_buffer_id) = buffers.get(&gfx_buffer_id) else {
@@ -355,7 +355,7 @@ impl GfxDrawMesh {
     }
 }
 
-impl Encodable for GfxDrawMesh {
+impl Encodable for DrawMesh {
     fn encode<S: Write>(&self, s: &mut S) -> std::result::Result<usize, std::io::Error> {
         let mut len = 0;
         len += self.vertex_buffer.id.encode(s)?;
@@ -383,7 +383,7 @@ impl Encodable for GfxDrawMesh {
 }
 
 #[async_trait]
-impl AsyncEncodable for GfxDrawMesh {
+impl AsyncEncodable for DrawMesh {
     async fn encode_async<W: AsyncWrite + Unpin + Send>(
         &self,
         _: &mut W,
@@ -393,47 +393,49 @@ impl AsyncEncodable for GfxDrawMesh {
 }
 
 #[derive(Debug, Clone, SerialEncodable)]
-pub enum GfxDrawInstruction {
+pub enum DrawInstruction {
     SetScale(f32),
     Move(Point),
     SetPos(Point),
     ApplyView(Rectangle),
-    Draw(GfxDrawMesh),
-    Animation(GfxSequenceAnimation),
+    Draw(DrawMesh),
+    Animation(SequenceAnimation),
     EnableDebug,
 }
 
-impl GfxDrawInstruction {
+impl DrawInstruction {
     fn compile(
         self,
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
+        textures: &HashMap<TextureId, miniquad::TextureId>,
+        buffers: &HashMap<BufferId, miniquad::BufferId>,
         debug_str: &'static str,
-    ) -> Option<DrawInstruction> {
+    ) -> Option<GfxDrawInstruction> {
         let instr = match self {
-            Self::SetScale(scale) => DrawInstruction::SetScale(scale),
-            Self::Move(off) => DrawInstruction::Move(off),
-            Self::SetPos(pos) => DrawInstruction::SetPos(pos),
-            Self::ApplyView(view) => DrawInstruction::ApplyView(view),
-            Self::Draw(mesh) => DrawInstruction::Draw(mesh.compile(textures, buffers, debug_str)?),
-            Self::Animation(anim) => DrawInstruction::Animation(anim.compile(textures, buffers)),
-            Self::EnableDebug => DrawInstruction::EnableDebug,
+            Self::SetScale(scale) => GfxDrawInstruction::SetScale(scale),
+            Self::Move(off) => GfxDrawInstruction::Move(off),
+            Self::SetPos(pos) => GfxDrawInstruction::SetPos(pos),
+            Self::ApplyView(view) => GfxDrawInstruction::ApplyView(view),
+            Self::Draw(mesh) => {
+                GfxDrawInstruction::Draw(mesh.compile(textures, buffers, debug_str)?)
+            }
+            Self::Animation(anim) => GfxDrawInstruction::Animation(anim.compile(textures, buffers)),
+            Self::EnableDebug => GfxDrawInstruction::EnableDebug,
         };
         Some(instr)
     }
 }
 
 #[derive(Clone, Debug, Default, SerialEncodable)]
-pub struct GfxDrawCall {
-    pub instrs: Vec<GfxDrawInstruction>,
+pub struct DrawCall {
+    pub instrs: Vec<DrawInstruction>,
     pub dcs: Vec<DcId>,
     pub z_index: u32,
     pub debug_str: &'static str,
 }
 
-impl GfxDrawCall {
+impl DrawCall {
     pub fn new(
-        instrs: Vec<GfxDrawInstruction>,
+        instrs: Vec<DrawInstruction>,
         dcs: Vec<DcId>,
         z_index: u32,
         debug_str: &'static str,
@@ -443,11 +445,11 @@ impl GfxDrawCall {
 
     fn compile(
         self,
-        textures: &HashMap<GfxTextureId, miniquad::TextureId>,
-        buffers: &HashMap<GfxBufferId, miniquad::BufferId>,
+        textures: &HashMap<TextureId, miniquad::TextureId>,
+        buffers: &HashMap<BufferId, miniquad::BufferId>,
         timest: Timestamp,
-    ) -> Option<DrawCall> {
-        Some(DrawCall {
+    ) -> Option<GfxDrawCall> {
+        Some(GfxDrawCall {
             instrs: self
                 .instrs
                 .into_iter()
@@ -461,7 +463,7 @@ impl GfxDrawCall {
 }
 
 #[derive(Clone, Debug)]
-struct DrawMesh {
+struct GfxDrawMesh {
     vertex_buffer: miniquad::BufferId,
     index_buffer: miniquad::BufferId,
     /// Keeps the buffers alive for the duration of this draw call
@@ -471,19 +473,19 @@ struct DrawMesh {
 }
 
 #[derive(Debug, Clone)]
-enum DrawInstruction {
+enum GfxDrawInstruction {
     SetScale(f32),
     Move(Point),
     SetPos(Point),
     ApplyView(Rectangle),
-    Draw(DrawMesh),
-    Animation(SequenceAnimation),
+    Draw(GfxDrawMesh),
+    Animation(GfxSequenceAnimation),
     EnableDebug,
 }
 
 #[derive(Clone, Debug)]
-struct DrawCall {
-    instrs: Vec<DrawInstruction>,
+struct GfxDrawCall {
+    instrs: Vec<GfxDrawInstruction>,
     dcs: Vec<DcId>,
     z_index: u32,
     timest: Timestamp,
@@ -491,7 +493,7 @@ struct DrawCall {
 
 struct RenderContext<'a> {
     ctx: &'a mut Box<dyn RenderingBackend>,
-    draw_calls: &'a HashMap<DcId, DrawCall>,
+    draw_calls: &'a HashMap<DcId, GfxDrawCall>,
     uniforms_data: [u8; 128],
     white_texture: miniquad::TextureId,
 
@@ -552,7 +554,7 @@ impl<'a> RenderContext<'a> {
         self.ctx.apply_uniforms_from_bytes(self.uniforms_data.as_ptr(), self.uniforms_data.len());
     }
 
-    fn draw_call(&mut self, draw_call: &DrawCall, mut indent: u32, mut is_debug: bool) {
+    fn draw_call(&mut self, draw_call: &GfxDrawCall, mut indent: u32, mut is_debug: bool) {
         let ws = if is_debug { " ".repeat(indent as usize * 4) } else { String::new() };
 
         let old_scale = self.scale;
@@ -564,7 +566,7 @@ impl<'a> RenderContext<'a> {
                 get_trax().lock().set_instr(idx);
             }
             match instr {
-                DrawInstruction::SetScale(scale) => {
+                GfxDrawInstruction::SetScale(scale) => {
                     self.scale = *scale;
                     self.view.w /= self.scale;
                     self.view.h /= self.scale;
@@ -572,7 +574,7 @@ impl<'a> RenderContext<'a> {
                         debug!(target: "gfx", "{ws}set_scale({scale})");
                     }
                 }
-                DrawInstruction::Move(off) => {
+                GfxDrawInstruction::Move(off) => {
                     self.cursor += *off;
                     if is_debug {
                         debug!(target: "gfx",
@@ -582,7 +584,7 @@ impl<'a> RenderContext<'a> {
                     }
                     self.apply_model();
                 }
-                DrawInstruction::SetPos(pos) => {
+                GfxDrawInstruction::SetPos(pos) => {
                     self.cursor = old_cursor + *pos;
                     if is_debug {
                         debug!(target: "gfx",
@@ -592,7 +594,7 @@ impl<'a> RenderContext<'a> {
                     }
                     self.apply_model();
                 }
-                DrawInstruction::ApplyView(view) => {
+                GfxDrawInstruction::ApplyView(view) => {
                     // Adjust view relative to cursor
                     self.view = *view + self.cursor;
 
@@ -614,7 +616,7 @@ impl<'a> RenderContext<'a> {
                     self.apply_view();
                     self.apply_model();
                 }
-                DrawInstruction::Draw(mesh) => {
+                GfxDrawInstruction::Draw(mesh) => {
                     if is_debug {
                         debug!(target: "gfx", "{ws}draw({mesh:?})");
                     }
@@ -630,11 +632,11 @@ impl<'a> RenderContext<'a> {
                     self.ctx.apply_bindings(&bindings);
                     self.ctx.draw(0, mesh.num_elements, 1);
                 }
-                DrawInstruction::Animation(anim) => {
+                GfxDrawInstruction::Animation(anim) => {
                     let dc = anim.tick();
                     self.draw_call(&dc, indent + 1, is_debug);
                 }
-                DrawInstruction::EnableDebug => {
+                GfxDrawInstruction::EnableDebug => {
                     if !is_debug {
                         indent = 0;
                     }
@@ -677,12 +679,12 @@ type DcId = u64;
 
 #[derive(Clone)]
 pub enum GraphicsMethod {
-    NewTexture((u16, u16, Vec<u8>, GfxTextureId, DebugTag)),
-    DeleteTexture((GfxTextureId, DebugTag)),
-    NewVertexBuffer((Vec<Vertex>, GfxBufferId, DebugTag)),
-    NewIndexBuffer((Vec<u16>, GfxBufferId, DebugTag)),
-    DeleteBuffer((GfxBufferId, DebugTag, u8)),
-    ReplaceDrawCalls { batch_id: BatchGuardId, timest: Timestamp, dcs: Vec<(DcId, GfxDrawCall)> },
+    NewTexture((u16, u16, Vec<u8>, TextureId, DebugTag)),
+    DeleteTexture((TextureId, DebugTag)),
+    NewVertexBuffer((Vec<Vertex>, BufferId, DebugTag)),
+    NewIndexBuffer((Vec<u16>, BufferId, DebugTag)),
+    DeleteBuffer((BufferId, DebugTag, u8)),
+    ReplaceGfxDrawCalls { batch_id: BatchGuardId, timest: Timestamp, dcs: Vec<(DcId, DrawCall)> },
     StartBatch((BatchGuardId, Option<&'static str>)),
     EndBatch(BatchGuardId),
 }
@@ -695,8 +697,8 @@ impl std::fmt::Debug for GraphicsMethod {
             Self::NewVertexBuffer(_) => write!(f, "NewVertexBuffer"),
             Self::NewIndexBuffer(_) => write!(f, "NewIndexBuffer"),
             Self::DeleteBuffer(_) => write!(f, "DeleteBuffer"),
-            Self::ReplaceDrawCalls { batch_id: bid, timest: _, dcs: _ } => {
-                write!(f, "ReplaceDrawCalls({bid})")
+            Self::ReplaceGfxDrawCalls { batch_id: bid, timest: _, dcs: _ } => {
+                write!(f, "ReplaceGfxDrawCalls({bid})")
             }
             Self::StartBatch((bid, debug_str)) => write!(f, "StartBatch({bid}, {debug_str:?})"),
             Self::EndBatch(bid) => write!(f, "EndBatch({bid})"),
@@ -833,11 +835,11 @@ struct Stage {
     libegl: egl::LibEgl,
     pipeline: Pipeline,
     white_texture: miniquad::TextureId,
-    draw_calls: HashMap<DcId, DrawCall>,
+    draw_calls: HashMap<DcId, GfxDrawCall>,
     batches: HashMap<BatchGuardId, Vec<GraphicsMethod>>,
 
-    textures: HashMap<GfxTextureId, miniquad::TextureId>,
-    buffers: HashMap<GfxBufferId, miniquad::BufferId>,
+    textures: HashMap<TextureId, miniquad::TextureId>,
+    buffers: HashMap<BufferId, miniquad::BufferId>,
 
     epoch: EpochIndex,
     method_queue: Arc<SyncMutex<Vec<(EpochIndex, GraphicsMethod)>>>,
@@ -868,10 +870,10 @@ impl Stage {
         let sink_task = god.fg_ex.spawn(async move {
             // Pull from render_api
             while let Ok((epoch, method)) = method_recv.recv().await {
-                let is_replace_dc = matches!(method, GraphicsMethod::ReplaceDrawCalls { .. });
+                let is_replace_dc = matches!(method, GraphicsMethod::ReplaceGfxDrawCalls { .. });
                 // Append to stage data
                 method_queue2.lock().push((epoch, method));
-                // If ReplaceDrawCall then wake up miniquad
+                // If ReplaceGfxDrawCall then wake up miniquad
                 if is_replace_dc {
                     miniquad::window::schedule_update();
                 }
@@ -929,7 +931,7 @@ impl Stage {
             white_texture,
             draw_calls: HashMap::from([(
                 0,
-                DrawCall { instrs: vec![], dcs: vec![], z_index: 0, timest: 0 },
+                GfxDrawCall { instrs: vec![], dcs: vec![], z_index: 0, timest: 0 },
             )]),
             batches: HashMap::new(),
 
@@ -959,12 +961,12 @@ impl Stage {
                 self.method_new_index_buffer(indices, *gbuff_id)
             }
             GraphicsMethod::DeleteBuffer((gbuff_id, _, _)) => self.method_delete_buffer(*gbuff_id),
-            GraphicsMethod::ReplaceDrawCalls { batch_id, timest, dcs } => {
+            GraphicsMethod::ReplaceGfxDrawCalls { batch_id, timest, dcs } => {
                 //let debug_strs: Vec<_> = dcs.iter().map(|(_, dc)| dc.debug_str).collect();
                 //t!("Commit dc to {batch_id}: {debug_strs:?}");
                 let batch = self.batches.get_mut(batch_id).unwrap();
                 let dcs = std::mem::take(dcs);
-                batch.push(GraphicsMethod::ReplaceDrawCalls {
+                batch.push(GraphicsMethod::ReplaceGfxDrawCalls {
                     batch_id: *batch_id,
                     timest: *timest,
                     dcs,
@@ -989,7 +991,7 @@ impl Stage {
                 let batch = self.batches.remove(batch_id).unwrap();
                 for mut method in batch {
                     let res = match &mut method {
-                        GraphicsMethod::ReplaceDrawCalls { batch_id: _, timest, dcs } => {
+                        GraphicsMethod::ReplaceGfxDrawCalls { batch_id: _, timest, dcs } => {
                             let dcs = std::mem::take(dcs);
                             self.method_replace_draw_calls(*timest, dcs)
                         }
@@ -1014,7 +1016,7 @@ impl Stage {
         width: u16,
         height: u16,
         data: &Vec<u8>,
-        gfx_texture_id: GfxTextureId,
+        gfx_texture_id: TextureId,
     ) -> Result<()> {
         let texture = self.ctx.new_texture_from_rgba8(width, height, data);
         if DEBUG_GFXAPI {
@@ -1036,7 +1038,7 @@ impl Stage {
         }
         Ok(())
     }
-    fn method_delete_texture(&mut self, gfx_texture_id: GfxTextureId) -> Result<()> {
+    fn method_delete_texture(&mut self, gfx_texture_id: TextureId) -> Result<()> {
         let Some(texture) = self.textures.remove(&gfx_texture_id) else {
             if DEBUG_TRAX {
                 get_trax().lock().put_stat(2);
@@ -1057,7 +1059,7 @@ impl Stage {
     fn method_new_vertex_buffer(
         &mut self,
         verts: &[Vertex],
-        gfx_buffer_id: GfxBufferId,
+        gfx_buffer_id: BufferId,
     ) -> Result<()> {
         let buffer = self.ctx.new_buffer(
             BufferType::VertexBuffer,
@@ -1082,11 +1084,7 @@ impl Stage {
         }
         Ok(())
     }
-    fn method_new_index_buffer(
-        &mut self,
-        indices: &[u16],
-        gfx_buffer_id: GfxBufferId,
-    ) -> Result<()> {
+    fn method_new_index_buffer(&mut self, indices: &[u16], gfx_buffer_id: BufferId) -> Result<()> {
         let buffer = self.ctx.new_buffer(
             BufferType::IndexBuffer,
             BufferUsage::Immutable,
@@ -1110,7 +1108,7 @@ impl Stage {
         }
         Ok(())
     }
-    fn method_delete_buffer(&mut self, gfx_buffer_id: GfxBufferId) -> Result<()> {
+    fn method_delete_buffer(&mut self, gfx_buffer_id: BufferId) -> Result<()> {
         let Some(buffer) = self.buffers.remove(&gfx_buffer_id) else {
             if DEBUG_TRAX {
                 get_trax().lock().put_stat(2);
@@ -1131,7 +1129,7 @@ impl Stage {
     fn method_replace_draw_calls(
         &mut self,
         timest: Timestamp,
-        dcs: Vec<(DcId, GfxDrawCall)>,
+        dcs: Vec<(DcId, DrawCall)>,
     ) -> Result<()> {
         if DEBUG_GFXAPI {
             debug!(target: "gfx", "Invoked method: replace_draw_calls({:?})", dcs);
@@ -1189,7 +1187,7 @@ impl Stage {
             GraphicsMethod::DeleteBuffer((gbuff_id, tag, buftype)) => {
                 trax.del_buf(epoch, *gbuff_id, *tag, *buftype);
             }
-            GraphicsMethod::ReplaceDrawCalls { batch_id, timest, dcs } => {
+            GraphicsMethod::ReplaceGfxDrawCalls { batch_id, timest, dcs } => {
                 trax.put_dcs(epoch, *batch_id, *timest, dcs);
             }
             GraphicsMethod::StartBatch((batch_id, debug_str)) => {
@@ -1217,13 +1215,13 @@ impl Stage {
 /// Will drop alloc/delete pairs, and merge draw calls together.
 struct PruneMethodHeap {
     /// Newly allocated buffers while screen was off
-    new_buf: HashMap<GfxBufferId, GraphicsMethod>,
+    new_buf: HashMap<BufferId, GraphicsMethod>,
     /// Newly allocated textures while screen was off
-    new_tex: HashMap<GfxTextureId, GraphicsMethod>,
+    new_tex: HashMap<TextureId, GraphicsMethod>,
     /// Deleted objects
     del: Vec<GraphicsMethod>,
     /// Draw calls
-    dcs: HashMap<DcId, (BatchGuardId, Timestamp, GfxDrawCall)>,
+    dcs: HashMap<DcId, (BatchGuardId, Timestamp, DrawCall)>,
 
     epoch: EpochIndex,
 }
@@ -1273,7 +1271,7 @@ impl PruneMethodHeap {
                     self.del.push(method);
                 }
             }
-            GraphicsMethod::ReplaceDrawCalls { batch_id, timest, dcs } => {
+            GraphicsMethod::ReplaceGfxDrawCalls { batch_id, timest, dcs } => {
                 self.method_replace_draw_calls(batch_id, timest, dcs)
             }
             // Discard batches since we will apply everything all at once anyway
@@ -1287,7 +1285,7 @@ impl PruneMethodHeap {
         &mut self,
         batch_id: BatchGuardId,
         timest: Timestamp,
-        dcs: Vec<(DcId, GfxDrawCall)>,
+        dcs: Vec<(DcId, DrawCall)>,
     ) {
         for (key, val) in dcs {
             match self.dcs.get_mut(&key) {
@@ -1318,7 +1316,7 @@ impl PruneMethodHeap {
         meth.extend(new_tex.into_values());
         meth.append(&mut self.del);
         for (dc_id, (batch_id, timest, dc)) in std::mem::take(&mut self.dcs) {
-            meth.push(GraphicsMethod::ReplaceDrawCalls {
+            meth.push(GraphicsMethod::ReplaceGfxDrawCalls {
                 batch_id,
                 timest,
                 dcs: vec![(dc_id, dc)],
@@ -1366,9 +1364,9 @@ impl EventHandler for Stage {
                 // We discard batches here but process_method uses them so implement this
                 // workaround.
                 match method {
-                    GraphicsMethod::ReplaceDrawCalls { batch_id: _, timest, dcs } => {
+                    GraphicsMethod::ReplaceGfxDrawCalls { batch_id: _, timest, dcs } => {
                         if let Err(err) = self.method_replace_draw_calls(timest, dcs) {
-                            e!("process_method for ReplaceDrawCalls failed err: {err:?}");
+                            e!("process_method for ReplaceGfxDrawCalls failed err: {err:?}");
                             panic!("process_method failed!")
                         }
                     }

+ 7 - 7
bin/app/src/gfx/trax.rs

@@ -21,7 +21,7 @@ use log::debug;
 use parking_lot::Mutex as SyncMutex;
 use std::{fs::File, sync::OnceLock};
 
-use super::{DebugTag, GfxBufferId, GfxDrawCall, GfxTextureId, Vertex};
+use super::{BufferId, DebugTag, DrawCall, TextureId, Vertex};
 use crate::{prop::BatchGuardId, EpochIndex};
 
 macro_rules! d { ($($arg:tt)*) => { debug!(target: "gfx::trax", $($arg)*); } }
@@ -52,7 +52,7 @@ impl Trax {
         epoch: EpochIndex,
         batch_id: BatchGuardId,
         timest: u64,
-        dcs: &Vec<(u64, GfxDrawCall)>,
+        dcs: &Vec<(u64, DrawCall)>,
     ) {
         d!("put_dcs({epoch}, {batch_id}, {timest}, {dcs:?})");
         0u8.encode(&mut self.buf).unwrap();
@@ -80,7 +80,7 @@ impl Trax {
         batch_id.encode(&mut self.buf).unwrap();
     }
 
-    pub fn put_tex(&mut self, epoch: EpochIndex, tex: GfxTextureId, tag: DebugTag) {
+    pub fn put_tex(&mut self, epoch: EpochIndex, tex: TextureId, tag: DebugTag) {
         d!("put_tex({epoch}, {tex}, {tag:?})");
         3u8.encode(&mut self.buf).unwrap();
         epoch.encode(&mut self.buf).unwrap();
@@ -91,7 +91,7 @@ impl Trax {
         &mut self,
         epoch: EpochIndex,
         verts: Vec<Vertex>,
-        buf: GfxBufferId,
+        buf: BufferId,
         tag: DebugTag,
         buftype: u8,
     ) {
@@ -107,7 +107,7 @@ impl Trax {
         &mut self,
         epoch: EpochIndex,
         idxs: Vec<u16>,
-        buf: GfxBufferId,
+        buf: BufferId,
         tag: DebugTag,
         buftype: u8,
     ) {
@@ -119,14 +119,14 @@ impl Trax {
         tag.encode(&mut self.buf).unwrap();
         buftype.encode(&mut self.buf).unwrap();
     }
-    pub fn del_tex(&mut self, epoch: EpochIndex, tex: GfxTextureId, tag: DebugTag) {
+    pub fn del_tex(&mut self, epoch: EpochIndex, tex: TextureId, tag: DebugTag) {
         d!("del_tex({epoch}, {tex}, {tag:?})");
         6u8.encode(&mut self.buf).unwrap();
         epoch.encode(&mut self.buf).unwrap();
         tex.encode(&mut self.buf).unwrap();
         tag.encode(&mut self.buf).unwrap();
     }
-    pub fn del_buf(&mut self, epoch: EpochIndex, buf: GfxBufferId, tag: DebugTag, buftype: u8) {
+    pub fn del_buf(&mut self, epoch: EpochIndex, buf: BufferId, tag: DebugTag, buftype: u8) {
         d!("del_buf({epoch}, {buf}, {tag:?}, {buftype})");
         7u8.encode(&mut self.buf).unwrap();
         epoch.encode(&mut self.buf).unwrap();

+ 5 - 5
bin/app/src/mesh.rs

@@ -17,7 +17,7 @@
  */
 
 use crate::gfx::{
-    DebugTag, GfxDrawMesh, ManagedBufferPtr, ManagedTexturePtr, Point, Rectangle, RenderApi, Vertex,
+    DebugTag, DrawMesh, ManagedBufferPtr, ManagedTexturePtr, Point, Rectangle, RenderApi, Vertex,
 };
 
 pub type Color = [f32; 4];
@@ -49,8 +49,8 @@ pub struct MeshInfo {
 
 impl MeshInfo {
     /// Convenience method
-    pub fn draw_with_texture(self, texture: ManagedTexturePtr) -> GfxDrawMesh {
-        GfxDrawMesh {
+    pub fn draw_with_texture(self, texture: ManagedTexturePtr) -> DrawMesh {
+        DrawMesh {
             vertex_buffer: self.vertex_buffer,
             index_buffer: self.index_buffer,
             texture: Some(texture),
@@ -58,8 +58,8 @@ impl MeshInfo {
         }
     }
     /// Convenience method
-    pub fn draw_untextured(self) -> GfxDrawMesh {
-        GfxDrawMesh {
+    pub fn draw_untextured(self) -> DrawMesh {
+        DrawMesh {
             vertex_buffer: self.vertex_buffer,
             index_buffer: self.index_buffer,
             texture: None,

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

@@ -28,7 +28,7 @@ use super::{Glyph, Sprite};
 
 pub struct RenderedAtlas {
     pub uv_rects: Vec<Rectangle>,
-    pub texture_id: TextureId,
+    pub texture_id: GfxTextureId,
 }
 
 const ATLAS_GAP: usize = 2;

+ 5 - 5
bin/app/src/text2/render.rs

@@ -17,7 +17,7 @@
  */
 
 use crate::{
-    gfx::{DebugTag, GfxDrawInstruction, GfxDrawMesh, Point, Rectangle, RenderApi},
+    gfx::{DebugTag, DrawInstruction, DrawMesh, Point, Rectangle, RenderApi},
     mesh::{Color, MeshBuilder, COLOR_WHITE},
 };
 
@@ -53,7 +53,7 @@ pub fn render_layout(
     layout: &parley::Layout<Color>,
     render_api: &RenderApi,
     tag: DebugTag,
-) -> Vec<GfxDrawInstruction> {
+) -> Vec<DrawInstruction> {
     render_layout_with_opts(layout, DebugRenderOptions::OFF, render_api, tag)
 }
 
@@ -62,7 +62,7 @@ pub fn render_layout_with_opts(
     opts: DebugRenderOptions,
     render_api: &RenderApi,
     tag: DebugTag,
-) -> Vec<GfxDrawInstruction> {
+) -> Vec<DrawInstruction> {
     let mut scale_cx = swash::scale::ScaleContext::new();
     let mut run_idx = 0;
     let mut instrs = vec![];
@@ -72,7 +72,7 @@ pub fn render_layout_with_opts(
                 parley::PositionedLayoutItem::GlyphRun(glyph_run) => {
                     let mesh =
                         render_glyph_run(&mut scale_cx, &glyph_run, run_idx, opts, render_api, tag);
-                    instrs.push(GfxDrawInstruction::Draw(mesh));
+                    instrs.push(DrawInstruction::Draw(mesh));
                     run_idx += 1;
                 }
                 parley::PositionedLayoutItem::InlineBox(_) => {}
@@ -89,7 +89,7 @@ fn render_glyph_run(
     opts: DebugRenderOptions,
     render_api: &RenderApi,
     tag: DebugTag,
-) -> GfxDrawMesh {
+) -> DrawMesh {
     let mut run_x = glyph_run.offset();
     let run_y = glyph_run.baseline();
     let style = glyph_run.style();

+ 31 - 37
bin/app/src/ui/chatedit.rs

@@ -35,9 +35,7 @@ use std::{
 #[cfg(target_os = "android")]
 use crate::AndroidSuggestEvent;
 use crate::{
-    gfx::{
-        gfxtag, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Point, Rectangle, RenderApi, Vertex,
-    },
+    gfx::{gfxtag, DrawCall, DrawInstruction, DrawMesh, Point, Rectangle, RenderApi, Vertex},
     mesh::MeshBuilder,
     prop::{
         BatchGuardId, BatchGuardPtr, PropertyAtomicGuard, PropertyBool, PropertyColor,
@@ -203,7 +201,7 @@ pub struct ChatEdit {
     select_dc_key: u64,
     text_dc_key: u64,
     cursor_dc_key: u64,
-    cursor_mesh: SyncMutex<Option<GfxDrawMesh>>,
+    cursor_mesh: SyncMutex<Option<DrawMesh>>,
 
     is_active: PropertyBool,
     is_focused: PropertyBool,
@@ -432,7 +430,7 @@ impl ChatEdit {
         EditorHandle { guard: self.editor.lock().await }
     }
 
-    fn regen_cursor_mesh(&self) -> GfxDrawMesh {
+    fn regen_cursor_mesh(&self) -> DrawMesh {
         let cursor_width = self.cursor_width.get();
         let cursor_ascent = self.cursor_ascent.get();
         let cursor_descent = self.cursor_descent.get();
@@ -954,8 +952,8 @@ impl ChatEdit {
         let phone_sel_instrs = self.regen_phone_select_handle_mesh().await;
 
         let mut content_instrs = vec![
-            GfxDrawInstruction::ApplyView(rect.with_zero_pos()),
-            GfxDrawInstruction::Move(Point::new(0., -scroll)),
+            DrawInstruction::ApplyView(rect.with_zero_pos()),
+            DrawInstruction::Move(Point::new(0., -scroll)),
         ];
         let mut bg_instrs = self.regen_bg_mesh();
         content_instrs.append(&mut bg_instrs);
@@ -963,7 +961,7 @@ impl ChatEdit {
         let draw_main = vec![
             (
                 self.content_dc_key,
-                GfxDrawCall::new(
+                DrawCall::new(
                     content_instrs,
                     vec![self.text_dc_key, self.cursor_dc_key, self.select_dc_key],
                     0,
@@ -972,7 +970,7 @@ impl ChatEdit {
             ),
             (
                 self.phone_select_handle_dc_key,
-                GfxDrawCall::new(phone_sel_instrs, vec![], 1, "chatedit_phone_sel_scroll"),
+                DrawCall::new(phone_sel_instrs, vec![], 1, "chatedit_phone_sel_scroll"),
             ),
         ];
         self.render_api.replace_draw_calls(batch_id, timest, draw_main);
@@ -981,8 +979,7 @@ impl ChatEdit {
     async fn redraw_cursor(&self, batch_id: BatchGuardId) {
         let timest = unixtime();
         let instrs = self.get_cursor_instrs().await;
-        let draw_calls =
-            vec![(self.cursor_dc_key, GfxDrawCall::new(instrs, vec![], 2, "curs_redr"))];
+        let draw_calls = vec![(self.cursor_dc_key, DrawCall::new(instrs, vec![], 2, "curs_redr"))];
         self.render_api.replace_draw_calls(batch_id, timest, draw_calls);
     }
 
@@ -991,16 +988,16 @@ impl ChatEdit {
         let sel_instrs = self.regen_select_mesh().await;
         let phone_sel_instrs = self.regen_phone_select_handle_mesh().await;
         let draw_calls = vec![
-            (self.select_dc_key, GfxDrawCall::new(sel_instrs, vec![], 0, "chatedit_sel")),
+            (self.select_dc_key, DrawCall::new(sel_instrs, vec![], 0, "chatedit_sel")),
             (
                 self.phone_select_handle_dc_key,
-                GfxDrawCall::new(phone_sel_instrs, vec![], 1, "chatedit_phone_sel_redraw_sel"),
+                DrawCall::new(phone_sel_instrs, vec![], 1, "chatedit_phone_sel_redraw_sel"),
             ),
         ];
         self.render_api.replace_draw_calls(batch_id, timest, draw_calls);
     }
 
-    async fn get_cursor_instrs(&self) -> Vec<GfxDrawInstruction> {
+    async fn get_cursor_instrs(&self) -> Vec<DrawInstruction> {
         if !self.is_focused.get() ||
             !self.cursor_is_visible.load(Ordering::Relaxed) ||
             self.hide_cursor.load(Ordering::Relaxed)
@@ -1011,13 +1008,10 @@ impl ChatEdit {
         let cursor_mesh =
             self.cursor_mesh.lock().get_or_insert_with(|| self.regen_cursor_mesh()).clone();
 
-        vec![
-            GfxDrawInstruction::Move(self.get_cursor_pos().await),
-            GfxDrawInstruction::Draw(cursor_mesh),
-        ]
+        vec![DrawInstruction::Move(self.get_cursor_pos().await), DrawInstruction::Draw(cursor_mesh)]
     }
 
-    fn regen_bg_mesh(&self) -> Vec<GfxDrawInstruction> {
+    fn regen_bg_mesh(&self) -> Vec<DrawInstruction> {
         if !self.debug.get() {
             return vec![]
         }
@@ -1034,11 +1028,11 @@ impl ChatEdit {
         rect.h -= padding_top + padding_bottom;
         mesh.draw_outline(&rect, [0., 1., 0., 0.5], 1.);
 
-        vec![GfxDrawInstruction::Draw(mesh.alloc(&self.render_api).draw_untextured())]
+        vec![DrawInstruction::Draw(mesh.alloc(&self.render_api).draw_untextured())]
     }
 
-    async fn regen_txt_mesh(&self) -> Vec<GfxDrawInstruction> {
-        let mut instrs = vec![GfxDrawInstruction::Move(self.inner_pos())];
+    async fn regen_txt_mesh(&self) -> Vec<DrawInstruction> {
+        let mut instrs = vec![DrawInstruction::Move(self.inner_pos())];
 
         let editor = self.lock_editor().await;
         let layout = editor.layout();
@@ -1050,8 +1044,8 @@ impl ChatEdit {
         instrs
     }
 
-    async fn regen_select_mesh(&self) -> Vec<GfxDrawInstruction> {
-        let mut instrs = vec![GfxDrawInstruction::Move(self.inner_pos())];
+    async fn regen_select_mesh(&self) -> Vec<DrawInstruction> {
+        let mut instrs = vec![DrawInstruction::Move(self.inner_pos())];
 
         let editor = self.lock_editor().await;
         let layout = editor.layout();
@@ -1064,13 +1058,13 @@ impl ChatEdit {
                 mesh.draw_filled_box(&rect.into(), sel_color);
             });
 
-            instrs.push(GfxDrawInstruction::Draw(mesh.alloc(&self.render_api).draw_untextured()));
+            instrs.push(DrawInstruction::Draw(mesh.alloc(&self.render_api).draw_untextured()));
         }
 
         instrs
     }
 
-    async fn regen_phone_select_handle_mesh(&self) -> Vec<GfxDrawInstruction> {
+    async fn regen_phone_select_handle_mesh(&self) -> Vec<DrawInstruction> {
         if !self.is_phone_select.load(Ordering::Relaxed) {
             return vec![]
         }
@@ -1090,8 +1084,8 @@ impl ChatEdit {
         self.draw_phone_select_handle(&mut mesh, first, -1.);
         self.draw_phone_select_handle(&mut mesh, last, 1.);
         vec![
-            GfxDrawInstruction::Move(pos),
-            GfxDrawInstruction::Draw(mesh.alloc(&self.render_api).draw_untextured()),
+            DrawInstruction::Move(pos),
+            DrawInstruction::Draw(mesh.alloc(&self.render_api).draw_untextured()),
         ]
     }
 
@@ -1158,8 +1152,8 @@ impl ChatEdit {
         let phone_sel_instrs = self.regen_phone_select_handle_mesh().await;
 
         let mut content_instrs = vec![
-            GfxDrawInstruction::ApplyView(rect.with_zero_pos()),
-            GfxDrawInstruction::Move(Point::new(0., -scroll)),
+            DrawInstruction::ApplyView(rect.with_zero_pos()),
+            DrawInstruction::Move(Point::new(0., -scroll)),
         ];
         let mut bg_instrs = self.regen_bg_mesh();
         content_instrs.append(&mut bg_instrs);
@@ -1183,8 +1177,8 @@ impl ChatEdit {
             draw_calls: vec![
                 (
                     self.root_dc_key,
-                    GfxDrawCall::new(
-                        vec![GfxDrawInstruction::Move(rect.pos())],
+                    DrawCall::new(
+                        vec![DrawInstruction::Move(rect.pos())],
                         vec![self.content_dc_key, self.phone_select_handle_dc_key],
                         self.z_index.get(),
                         "chatedit_root",
@@ -1192,19 +1186,19 @@ impl ChatEdit {
                 ),
                 (
                     self.content_dc_key,
-                    GfxDrawCall::new(
+                    DrawCall::new(
                         content_instrs,
                         vec![self.text_dc_key, self.cursor_dc_key, self.select_dc_key],
                         0,
                         "chatedit_content",
                     ),
                 ),
-                (self.select_dc_key, GfxDrawCall::new(sel_instrs, vec![], 0, "chatedit_sel")),
-                (self.text_dc_key, GfxDrawCall::new(txt_instrs, vec![], 1, "chatedit_text")),
-                (self.cursor_dc_key, GfxDrawCall::new(cursor_instrs, vec![], 2, "chatedit_curs")),
+                (self.select_dc_key, DrawCall::new(sel_instrs, vec![], 0, "chatedit_sel")),
+                (self.text_dc_key, DrawCall::new(txt_instrs, vec![], 1, "chatedit_text")),
+                (self.cursor_dc_key, DrawCall::new(cursor_instrs, vec![], 2, "chatedit_curs")),
                 (
                     self.phone_select_handle_dc_key,
-                    GfxDrawCall::new(phone_sel_instrs, vec![], 1, "chatedit_phone_sel"),
+                    DrawCall::new(phone_sel_instrs, vec![], 1, "chatedit_phone_sel"),
                 ),
             ],
         }

+ 8 - 8
bin/app/src/ui/chatview/mod.rs

@@ -38,7 +38,7 @@ mod page;
 use page::MessageBuffer;
 
 use crate::{
-    gfx::{gfxtag, GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApi},
+    gfx::{gfxtag, DrawCall, DrawInstruction, Point, Rectangle, RenderApi},
     prop::{
         BatchGuardId, BatchGuardPtr, PropertyAtomicGuard, PropertyBool, PropertyColor,
         PropertyFloat32, PropertyRect, PropertyUint32, Role,
@@ -652,7 +652,7 @@ impl ChatView {
         &self,
         msgbuf: &mut MessageBuffer,
         rect: &Rectangle,
-    ) -> Vec<GfxDrawInstruction> {
+    ) -> Vec<DrawInstruction> {
         let scroll = self.scroll.get();
         //let total_height = msgbuf.calc_total_height().await;
 
@@ -675,8 +675,8 @@ impl ChatView {
             let off_y = scroll + start_pos - y_pos;
             let pos = Point::from([off_x, off_y]);
 
-            instrs.push(GfxDrawInstruction::SetPos(pos));
-            instrs.push(GfxDrawInstruction::Draw(mesh));
+            instrs.push(DrawInstruction::SetPos(pos));
+            instrs.push(DrawInstruction::Draw(mesh));
         }
 
         instrs
@@ -694,11 +694,11 @@ impl ChatView {
 
         let mut mesh_instrs = self.get_meshes(msgbuf, &rect).await;
 
-        let mut instrs = vec![GfxDrawInstruction::ApplyView(rect)];
+        let mut instrs = vec![DrawInstruction::ApplyView(rect)];
         instrs.append(&mut mesh_instrs);
 
         let draw_calls =
-            vec![(self.dc_key, GfxDrawCall::new(instrs, vec![], self.z_index.get(), "chatview"))];
+            vec![(self.dc_key, DrawCall::new(instrs, vec![], self.z_index.get(), "chatview"))];
 
         self.render_api.replace_draw_calls(batch_id, timest, draw_calls);
         t!("ChatView::redraw_cached() DONE [trace_id={trace_id}]");
@@ -844,14 +844,14 @@ impl UIObject for ChatView {
         let mut mesh_instrs = self.get_meshes(&mut msgbuf, &rect).await;
         drop(msgbuf);
 
-        let mut instrs = vec![GfxDrawInstruction::ApplyView(rect)];
+        let mut instrs = vec![DrawInstruction::ApplyView(rect)];
         instrs.append(&mut mesh_instrs);
 
         Some(DrawUpdate {
             key: self.dc_key,
             draw_calls: vec![(
                 self.dc_key,
-                GfxDrawCall::new(instrs, vec![], self.z_index.get(), "chatview"),
+                DrawCall::new(instrs, vec![], self.z_index.get(), "chatview"),
             )],
         })
     }

+ 7 - 7
bin/app/src/ui/chatview/page.rs

@@ -27,7 +27,7 @@ use std::{
 
 use super::{max, MessageId, Timestamp};
 use crate::{
-    gfx::{gfxtag, GfxDrawMesh, Rectangle, RenderApi},
+    gfx::{gfxtag, DrawMesh, Rectangle, RenderApi},
     mesh::{Color, MeshBuilder, COLOR_BLUE, COLOR_PINK, COLOR_WHITE},
     prop::{PropertyBool, PropertyColor, PropertyFloat32, PropertyPtr},
     text::{self, Glyph, GlyphPositionIter, TextShaper, TextShaperPtr},
@@ -64,7 +64,7 @@ pub struct PrivMessage {
     wrapped_lines: Vec<Vec<Glyph>>,
 
     atlas: text::RenderedAtlas,
-    mesh_cache: Option<GfxDrawMesh>,
+    mesh_cache: Option<DrawMesh>,
 }
 
 impl PrivMessage {
@@ -141,7 +141,7 @@ impl PrivMessage {
         hi_bg_color: Color,
         debug_render: bool,
         render_api: &RenderApi,
-    ) -> GfxDrawMesh {
+    ) -> DrawMesh {
         if let Some(mesh) = &self.mesh_cache {
             return mesh.clone()
         }
@@ -374,7 +374,7 @@ pub struct DateMessage {
     glyphs: Vec<Glyph>,
 
     atlas: text::RenderedAtlas,
-    mesh_cache: Option<GfxDrawMesh>,
+    mesh_cache: Option<DrawMesh>,
 }
 
 impl DateMessage {
@@ -449,7 +449,7 @@ impl DateMessage {
         _text_color: Color,
         debug_render: bool,
         render_api: &RenderApi,
-    ) -> GfxDrawMesh {
+    ) -> DrawMesh {
         let mut mesh = MeshBuilder::new(gfxtag!("chatview_datemsg"));
 
         let glyph_pos_iter =
@@ -557,7 +557,7 @@ impl Message {
         hi_bg_color: Color,
         debug_render: bool,
         render_api: &RenderApi,
-    ) -> GfxDrawMesh {
+    ) -> DrawMesh {
         match self {
             Self::Priv(m) => m.gen_mesh(
                 clip,
@@ -892,7 +892,7 @@ impl MessageBuffer {
     }
 
     /// Generate caches and return meshes
-    pub async fn gen_meshes(&mut self, rect: &Rectangle, scroll: f32) -> Vec<(f32, GfxDrawMesh)> {
+    pub async fn gen_meshes(&mut self, rect: &Rectangle, scroll: f32) -> Vec<(f32, DrawMesh)> {
         let line_height = self.line_height.get();
         let msg_spacing = self.msg_spacing.get();
         let baseline = self.baseline.get();

+ 12 - 12
bin/app/src/ui/editbox/mod.rs

@@ -34,7 +34,7 @@ use std::{
 use crate::{
     error::Result,
     gfx::{
-        gfxtag, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, GfxTextureId,
+        gfxtag, DrawCall, DrawInstruction, DrawMesh, TextureId,
         GraphicsEventPublisherPtr, Point, Rectangle, RenderApi, Vertex,
     },
     mesh::{MeshBuilder, MeshInfo, COLOR_BLUE, COLOR_WHITE},
@@ -152,7 +152,7 @@ pub struct EditBox {
     glyphs: SyncMutex<Vec<Glyph>>,
     /// DC key for the text
     text_dc_key: u64,
-    cursor_mesh: SyncMutex<Option<GfxDrawMesh>>,
+    cursor_mesh: SyncMutex<Option<DrawMesh>>,
     /// DC key for the cursor. Allows updating cursor independently.
     cursor_dc_key: u64,
 
@@ -316,7 +316,7 @@ impl EditBox {
     }
 
     /// Called whenever the text or any text property changes.
-    fn regen_text_mesh(&self, mut clip: Rectangle) -> GfxDrawMesh {
+    fn regen_text_mesh(&self, mut clip: Rectangle) -> DrawMesh {
         clip.x = 0.;
         clip.y = 0.;
 
@@ -388,7 +388,7 @@ impl EditBox {
         mesh.alloc(&self.render_api).draw_with_texture(atlas.texture)
     }
 
-    fn regen_cursor_mesh(&self) -> GfxDrawMesh {
+    fn regen_cursor_mesh(&self) -> DrawMesh {
         let cursor_width = self.cursor_width.get();
         let cursor_ascent = self.cursor_ascent.get();
         let cursor_descent = self.cursor_descent.get();
@@ -1191,13 +1191,13 @@ impl EditBox {
 
         let draw_calls = vec![(
             self.cursor_dc_key,
-            GfxDrawCall::new(cursor_instrs, vec![], self.z_index.get(), "editbox_curs_redr"),
+            DrawCall::new(cursor_instrs, vec![], self.z_index.get(), "editbox_curs_redr"),
         )];
 
         self.render_api.replace_draw_calls(timest, draw_calls);
     }
 
-    fn get_cursor_instrs(&self) -> Vec<GfxDrawInstruction> {
+    fn get_cursor_instrs(&self) -> Vec<DrawInstruction> {
         if !self.is_focused.get() ||
             !self.cursor_is_visible.load(Ordering::Relaxed) ||
             self.hide_cursor.load(Ordering::Relaxed)
@@ -1214,7 +1214,7 @@ impl EditBox {
         if cursor_pos.x > rect_w {
             return vec![]
         }
-        cursor_instrs.push(GfxDrawInstruction::Move(cursor_pos));
+        cursor_instrs.push(DrawInstruction::Move(cursor_pos));
 
         let cursor_mesh = {
             let mut cursor_mesh = self.cursor_mesh.lock().unwrap();
@@ -1224,7 +1224,7 @@ impl EditBox {
             cursor_mesh.clone().unwrap()
         };
 
-        cursor_instrs.push(GfxDrawInstruction::Draw(cursor_mesh));
+        cursor_instrs.push(DrawInstruction::Draw(cursor_mesh));
 
         cursor_instrs
     }
@@ -1240,10 +1240,10 @@ impl EditBox {
             draw_calls: vec![
                 (
                     self.text_dc_key,
-                    GfxDrawCall::new(
+                    DrawCall::new(
                         vec![
-                            GfxDrawInstruction::Move(rect.pos()),
-                            GfxDrawInstruction::Draw(text_mesh),
+                            DrawInstruction::Move(rect.pos()),
+                            DrawInstruction::Draw(text_mesh),
                         ],
                         vec![self.cursor_dc_key],
                         self.z_index.get(),
@@ -1252,7 +1252,7 @@ impl EditBox {
                 ),
                 (
                     self.cursor_dc_key,
-                    GfxDrawCall::new(cursor_instrs, vec![], self.z_index.get(), "editbox_curs"),
+                    DrawCall::new(cursor_instrs, vec![], self.z_index.get(), "editbox_curs"),
                 ),
             ],
         })

+ 4 - 4
bin/app/src/ui/emoji_picker/emoji.rs

@@ -25,7 +25,7 @@ use std::{
 };
 
 use crate::{
-    gfx::{gfxtag, GfxDrawMesh, Rectangle, RenderApi},
+    gfx::{gfxtag, DrawMesh, Rectangle, RenderApi},
     mesh::{MeshBuilder, COLOR_WHITE},
     text::{self, TextShaperPtr},
 };
@@ -49,7 +49,7 @@ pub struct EmojiMeshes {
     text_shaper: TextShaperPtr,
     emoji_size: f32,
     emoji_list: LazyLock<Vec<String>>,
-    meshes: Vec<GfxDrawMesh>,
+    meshes: Vec<DrawMesh>,
 }
 
 impl EmojiMeshes {
@@ -71,7 +71,7 @@ impl EmojiMeshes {
         self.meshes.clear();
     }
 
-    pub fn get(&mut self, i: usize) -> GfxDrawMesh {
+    pub fn get(&mut self, i: usize) -> DrawMesh {
         let emoji_list = self.get_list();
         assert!(i < emoji_list.len());
         self.meshes.reserve_exact(emoji_list.len());
@@ -89,7 +89,7 @@ impl EmojiMeshes {
     }
 
     /// Make mesh for this emoji centered at (0, 0)
-    fn gen_emoji_mesh(&self, emoji: &str) -> GfxDrawMesh {
+    fn gen_emoji_mesh(&self, emoji: &str) -> DrawMesh {
         //d!("rendering emoji: '{emoji}'");
         // The params here don't actually matter since we're talking about BMP fixed sizes
         let glyphs = self.text_shaper.shape(emoji.to_string(), 10., 1.);

+ 4 - 7
bin/app/src/ui/emoji_picker/mod.rs

@@ -27,7 +27,7 @@ use std::sync::{
 };
 
 use crate::{
-    gfx::{gfxtag, GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApi},
+    gfx::{gfxtag, DrawCall, DrawInstruction, Point, Rectangle, RenderApi},
     prop::{
         BatchGuardPtr, PropertyAtomicGuard, PropertyFloat32, PropertyRect, PropertyUint32, Role,
     },
@@ -216,7 +216,7 @@ impl EmojiPicker {
         }
 
         let rect = self.rect.get();
-        let mut instrs = vec![GfxDrawInstruction::ApplyView(rect)];
+        let mut instrs = vec![DrawInstruction::ApplyView(rect)];
 
         let off_x = self.calc_off_x();
         let emoji_size = self.emoji_size.get();
@@ -229,10 +229,7 @@ impl EmojiPicker {
         for i in 0..emoji_list_len {
             let pos = Point::new(x, y);
             let mesh = emoji_meshes.get(i);
-            instrs.extend_from_slice(&[
-                GfxDrawInstruction::SetPos(pos),
-                GfxDrawInstruction::Draw(mesh),
-            ]);
+            instrs.extend_from_slice(&[DrawInstruction::SetPos(pos), DrawInstruction::Draw(mesh)]);
 
             x += off_x;
             if x > rect.w {
@@ -250,7 +247,7 @@ impl EmojiPicker {
             key: self.dc_key,
             draw_calls: vec![(
                 self.dc_key,
-                GfxDrawCall::new(instrs, vec![], self.z_index.get(), "emoji"),
+                DrawCall::new(instrs, vec![], self.z_index.get(), "emoji"),
             )],
         })
     }

+ 4 - 7
bin/app/src/ui/image.rs

@@ -23,10 +23,7 @@ use rand::{rngs::OsRng, Rng};
 use std::{io::Cursor, sync::Arc};
 
 use crate::{
-    gfx::{
-        gfxtag, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, ManagedTexturePtr, Rectangle,
-        RenderApi,
-    },
+    gfx::{gfxtag, DrawCall, DrawInstruction, DrawMesh, ManagedTexturePtr, Rectangle, RenderApi},
     mesh::{MeshBuilder, MeshInfo, COLOR_WHITE},
     prop::{BatchGuardPtr, PropertyAtomicGuard, PropertyRect, PropertyStr, PropertyUint32, Role},
     scene::{Pimpl, SceneNodeWeak},
@@ -159,7 +156,7 @@ impl Image {
         let mesh = self.regen_mesh();
         let texture = self.texture.lock().clone().expect("Node missing texture_id!");
 
-        let mesh = GfxDrawMesh {
+        let mesh = DrawMesh {
             vertex_buffer: mesh.vertex_buffer,
             index_buffer: mesh.index_buffer,
             texture: Some(texture),
@@ -170,8 +167,8 @@ impl Image {
             key: self.dc_key,
             draw_calls: vec![(
                 self.dc_key,
-                GfxDrawCall::new(
-                    vec![GfxDrawInstruction::Move(rect.pos()), GfxDrawInstruction::Draw(mesh)],
+                DrawCall::new(
+                    vec![DrawInstruction::Move(rect.pos()), DrawInstruction::Draw(mesh)],
                     vec![],
                     self.z_index.get(),
                     "img",

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

@@ -23,7 +23,7 @@ use rand::{rngs::OsRng, Rng};
 use std::sync::Arc;
 
 use crate::{
-    gfx::{GfxDrawCall, GfxDrawInstruction, Point, Rectangle, RenderApi},
+    gfx::{DrawCall, DrawInstruction, Point, Rectangle, RenderApi},
     prop::{BatchGuardPtr, PropertyAtomicGuard, PropertyBool, PropertyRect, PropertyUint32, Role},
     scene::{Pimpl, SceneNodePtr, SceneNodeWeak},
     util::{i18n::I18nBabelFish, unixtime},
@@ -131,8 +131,8 @@ impl Layer {
             }
         }
 
-        let dc = GfxDrawCall::new(
-            vec![GfxDrawInstruction::ApplyView(rect)],
+        let dc = DrawCall::new(
+            vec![DrawInstruction::ApplyView(rect)],
             child_calls,
             self.z_index.get(),
             "layer",

+ 2 - 2
bin/app/src/ui/mod.rs

@@ -22,7 +22,7 @@ use miniquad::{KeyCode, KeyMods, MouseButton, TouchPhase};
 use std::sync::{Arc, Weak};
 
 use crate::{
-    gfx::{GfxDrawCall, Point, Rectangle},
+    gfx::{DrawCall, Point, Rectangle},
     prop::{BatchGuardPtr, ModifyAction, PropertyAtomicGuard, PropertyPtr, Role},
     scene::{Pimpl, SceneNode as SceneNode3, SceneNodePtr, SceneNodeWeak},
     util::i18n::I18nBabelFish,
@@ -115,7 +115,7 @@ pub trait UIObject: Sync {
 
 pub struct DrawUpdate {
     pub key: u64,
-    pub draw_calls: Vec<(u64, GfxDrawCall)>,
+    pub draw_calls: Vec<(u64, DrawCall)>,
 }
 
 pub struct OnModify<T> {

+ 4 - 4
bin/app/src/ui/text.rs

@@ -22,7 +22,7 @@ use rand::{rngs::OsRng, Rng};
 use std::sync::Arc;
 
 use crate::{
-    gfx::{gfxtag, GfxDrawCall, GfxDrawInstruction, Rectangle, RenderApi},
+    gfx::{gfxtag, DrawCall, DrawInstruction, Rectangle, RenderApi},
     prop::{
         BatchGuardPtr, PropertyAtomicGuard, PropertyBool, PropertyColor, PropertyFloat32,
         PropertyRect, PropertyStr, PropertyUint32, Role,
@@ -105,7 +105,7 @@ impl Text {
         Pimpl::Text(self_)
     }
 
-    async fn regen_mesh(&self) -> Vec<GfxDrawInstruction> {
+    async fn regen_mesh(&self) -> Vec<DrawInstruction> {
         let text = self.text.get();
         let font_size = self.font_size.get();
         let lineheight = self.lineheight.get();
@@ -159,14 +159,14 @@ impl Text {
         self.rect.eval(atom, &parent_rect).ok()?;
         let rect = self.rect.get();
 
-        let mut instrs = vec![GfxDrawInstruction::Move(rect.pos())];
+        let mut instrs = vec![DrawInstruction::Move(rect.pos())];
         instrs.append(&mut self.regen_mesh().await);
 
         Some(DrawUpdate {
             key: self.dc_key,
             draw_calls: vec![(
                 self.dc_key,
-                GfxDrawCall::new(instrs, vec![], self.z_index.get(), "text"),
+                DrawCall::new(instrs, vec![], self.z_index.get(), "text"),
             )],
         })
     }

+ 5 - 5
bin/app/src/ui/vector_art/mod.rs

@@ -22,7 +22,7 @@ use rand::{rngs::OsRng, Rng};
 use std::sync::Arc;
 
 use crate::{
-    gfx::{gfxtag, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, Rectangle, RenderApi},
+    gfx::{gfxtag, DrawCall, DrawInstruction, DrawMesh, Rectangle, RenderApi},
     prop::{BatchGuardPtr, PropertyAtomicGuard, PropertyBool, PropertyRect, PropertyUint32, Role},
     scene::{Pimpl, SceneNodeWeak},
     util::unixtime,
@@ -101,7 +101,7 @@ impl VectorArt {
         self.render_api.replace_draw_calls(batch.id, timest, draw_update.draw_calls);
     }
 
-    fn get_draw_instrs(&self) -> Vec<GfxDrawInstruction> {
+    fn get_draw_instrs(&self) -> Vec<DrawInstruction> {
         if !self.is_visible.get() {
             t!("Skipping draw for invisible {}", self.node_path());
             return vec![]
@@ -115,9 +115,9 @@ impl VectorArt {
         //debug!(target: "ui::vector_art", "vec_draw_instrs {verts:?} | {indices:?} | {num_elements}");
         let vertex_buffer = self.render_api.new_vertex_buffer(verts, gfxtag!("vectorart"));
         let index_buffer = self.render_api.new_index_buffer(indices, gfxtag!("vectorart"));
-        let mesh = GfxDrawMesh { vertex_buffer, index_buffer, texture: None, num_elements };
+        let mesh = DrawMesh { vertex_buffer, index_buffer, texture: None, num_elements };
 
-        vec![GfxDrawInstruction::Move(rect.pos()), GfxDrawInstruction::Draw(mesh)]
+        vec![DrawInstruction::Move(rect.pos()), DrawInstruction::Draw(mesh)]
     }
 
     async fn get_draw_calls(
@@ -135,7 +135,7 @@ impl VectorArt {
             key: self.dc_key,
             draw_calls: vec![(
                 self.dc_key,
-                GfxDrawCall::new(instrs, vec![], self.z_index.get(), "vecart"),
+                DrawCall::new(instrs, vec![], self.z_index.get(), "vecart"),
             )],
         })
     }

+ 9 - 10
bin/app/src/ui/video.rs

@@ -30,9 +30,8 @@ use std::{
 
 use crate::{
     gfx::{
-        anim::{GfxSequenceAnimation, GfxSequenceAnimationFrame},
-        gfxtag, GfxDrawCall, GfxDrawInstruction, GfxDrawMesh, ManagedTexturePtr, Rectangle,
-        RenderApi,
+        anim::{SequenceAnimation, SequenceAnimationFrame},
+        gfxtag, DrawCall, DrawInstruction, DrawMesh, ManagedTexturePtr, Rectangle, RenderApi,
     },
     mesh::{MeshBuilder, MeshInfo, COLOR_WHITE},
     prop::{BatchGuardPtr, PropertyAtomicGuard, PropertyRect, PropertyStr, PropertyUint32, Role},
@@ -204,28 +203,28 @@ impl Video {
 
         let mut frames = Vec::with_capacity(textures.len());
         for texture in textures {
-            let mesh = GfxDrawMesh {
+            let mesh = DrawMesh {
                 vertex_buffer: mesh.vertex_buffer.clone(),
                 index_buffer: mesh.index_buffer.clone(),
                 texture: Some(texture),
                 num_elements: mesh.num_elements,
             };
-            let dc = GfxDrawCall {
-                instrs: vec![GfxDrawInstruction::Draw(mesh)],
+            let dc = DrawCall {
+                instrs: vec![DrawInstruction::Draw(mesh)],
                 dcs: vec![],
                 z_index: 0,
                 debug_str: "video",
             };
-            frames.push(GfxSequenceAnimationFrame::new(40, dc));
+            frames.push(SequenceAnimationFrame::new(40, dc));
         }
-        let anim = GfxSequenceAnimation::new(false, frames);
+        let anim = SequenceAnimation::new(false, frames);
 
         Some(DrawUpdate {
             key: self.dc_key,
             draw_calls: vec![(
                 self.dc_key,
-                GfxDrawCall::new(
-                    vec![GfxDrawInstruction::Move(rect.pos()), GfxDrawInstruction::Animation(anim)],
+                DrawCall::new(
+                    vec![DrawInstruction::Move(rect.pos()), DrawInstruction::Animation(anim)],
                     vec![],
                     self.z_index.get(),
                     "vid",

+ 3 - 7
bin/app/src/ui/win.rs

@@ -23,7 +23,7 @@ use std::sync::{Arc, Weak};
 use crate::{
     app::locale::read_locale_ftl,
     gfx::{
-        gfxtag, GfxDrawCall, GfxDrawInstruction, GraphicsEventCharSub, GraphicsEventKeyDownSub,
+        gfxtag, DrawCall, DrawInstruction, GraphicsEventCharSub, GraphicsEventKeyDownSub,
         GraphicsEventKeyUpSub, GraphicsEventMouseButtonDownSub, GraphicsEventMouseButtonUpSub,
         GraphicsEventMouseMoveSub, GraphicsEventMouseWheelSub, GraphicsEventPublisherPtr,
         GraphicsEventTouchSub, Point, Rectangle, RenderApi,
@@ -462,12 +462,8 @@ impl Window {
             child_calls.push(draw_update.key);
         }
 
-        let dc = GfxDrawCall::new(
-            vec![GfxDrawInstruction::SetScale(self.scale.get())],
-            child_calls,
-            0,
-            "win",
-        );
+        let dc =
+            DrawCall::new(vec![DrawInstruction::SetScale(self.scale.get())], child_calls, 0, "win");
         draw_calls.push((0, dc));
         //t!("  => {:?}", draw_calls);