gardesk/garterm / 82be9c3

Browse files

fix: skip rendering backgrounds similar to terminal default

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
82be9c38fd5ce8fe5d2c974ad4c3a4b1392a7fa5
Parents
1bacf68
Tree
e9edc58

1 changed file

StatusFile+-
M garterm/src/render/mod.rs 22 10
garterm/src/render/mod.rsmodified
@@ -257,16 +257,18 @@ impl Renderer {
257257
         });
258258
 
259259
         // Create vertex/index buffers
260
+        // Size calculation: 300 cols × 100 rows × 4 quads/cell × 4 verts × 36 bytes = ~17MB
261
+        // Use 16MB for vertices and 8MB for indices to support large/high-DPI displays
260262
         let vertex_buffer = gpu.device.create_buffer(&wgpu::BufferDescriptor {
261263
             label: Some("vertex_buffer"),
262
-            size: 1024 * 1024, // 1MB
264
+            size: 16 * 1024 * 1024, // 16MB
263265
             usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::COPY_DST,
264266
             mapped_at_creation: false,
265267
         });
266268
 
267269
         let index_buffer = gpu.device.create_buffer(&wgpu::BufferDescriptor {
268270
             label: Some("index_buffer"),
269
-            size: 512 * 1024, // 512KB
271
+            size: 8 * 1024 * 1024, // 8MB
270272
             usage: wgpu::BufferUsages::INDEX | wgpu::BufferUsages::COPY_DST,
271273
             mapped_at_creation: false,
272274
         });
@@ -991,15 +993,25 @@ impl Renderer {
991993
                         bg_color,
992994
                         0.0,
993995
                     );
994
-                } else if cell.bg != CellColor::Default {
996
+                } else if cell.bg != CellColor::Default && cell.bg != CellColor::Indexed(0) {
997
+                    // Skip Default and Indexed(0) - ANSI black as background typically means
998
+                    // "use terminal background" in ncurses/TUI apps
995999
                     let bg_color = self.color_to_rgba(&cell.bg, false);
996
-                    self.add_quad(
997
-                        to_ndc_x(x), to_ndc_y(y),
998
-                        to_ndc_x(x + cell_w), to_ndc_y(y + cell_h),
999
-                        0.0, 0.0, 0.0, 0.0,
1000
-                        bg_color,
1001
-                        0.0,
1002
-                    );
1000
+                    let default_bg = self.colors.background.to_rgba();
1001
+                    // Skip if background is close to terminal default (handles editor themes
1002
+                    // that set their own "background" color)
1003
+                    let is_similar = (bg_color[0] - default_bg[0]).abs() < 0.15
1004
+                        && (bg_color[1] - default_bg[1]).abs() < 0.15
1005
+                        && (bg_color[2] - default_bg[2]).abs() < 0.15;
1006
+                    if !is_similar {
1007
+                        self.add_quad(
1008
+                            to_ndc_x(x), to_ndc_y(y),
1009
+                            to_ndc_x(x + cell_w), to_ndc_y(y + cell_h),
1010
+                            0.0, 0.0, 0.0, 0.0,
1011
+                            bg_color,
1012
+                            0.0,
1013
+                        );
1014
+                    }
10031015
                 }
10041016
 
10051017
                 // Character (if not space or null)