Skip to content

Commit 11b2c3b

Browse files
committed
Reuse text buffers independently of color in iced_wgpu
1 parent 368cadd commit 11b2c3b

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

wgpu/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ path = "../graphics"
6060
[dependencies.glyphon]
6161
version = "0.2"
6262
git = "https://github.com/hecrj/glyphon.git"
63-
rev = "65b481d758f50fd13fc21af2cc5ef62ddee64955"
63+
rev = "810bc979f9005e2bd343b72b980e57e46174283f"
6464

6565
[dependencies.tracing]
6666
version = "0.1.6"

wgpu/src/text.rs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub use iced_native::text::Hit;
22

33
use iced_graphics::layer::Text;
44
use iced_native::alignment;
5-
use iced_native::{Color, Font, Rectangle, Size};
5+
use iced_native::{Font, Rectangle, Size};
66

77
use rustc_hash::{FxHashMap, FxHashSet};
88
use std::borrow::Cow;
@@ -110,7 +110,6 @@ impl Pipeline {
110110
height: (section.bounds.height * scale_factor)
111111
.ceil(),
112112
},
113-
color: section.color,
114113
},
115114
);
116115

@@ -162,6 +161,16 @@ impl Pipeline {
162161
left: left as i32,
163162
top: top as i32,
164163
bounds,
164+
default_color: {
165+
let [r, g, b, a] = section.color.into_linear();
166+
167+
glyphon::Color::rgba(
168+
(r * 255.0) as u8,
169+
(g * 255.0) as u8,
170+
(b * 255.0) as u8,
171+
(a * 255.0) as u8,
172+
)
173+
},
165174
}
166175
});
167176

@@ -174,7 +183,6 @@ impl Pipeline {
174183
height: target_size.height,
175184
},
176185
text_areas,
177-
glyphon::Color::rgb(0, 0, 0),
178186
&mut glyphon::SwashCache::new(fields.fonts),
179187
);
180188

@@ -249,7 +257,6 @@ impl Pipeline {
249257
size,
250258
font,
251259
bounds,
252-
color: Color::BLACK,
253260
},
254261
);
255262

@@ -283,7 +290,6 @@ impl Pipeline {
283290
size,
284291
font,
285292
bounds,
286-
color: Color::BLACK,
287293
},
288294
);
289295

@@ -354,7 +360,6 @@ impl<'a> Cache<'a> {
354360
key.font.hash(&mut hasher);
355361
key.bounds.width.to_bits().hash(&mut hasher);
356362
key.bounds.height.to_bits().hash(&mut hasher);
357-
key.color.into_rgba8().hash(&mut hasher);
358363

359364
hasher.finish()
360365
};
@@ -371,16 +376,6 @@ impl<'a> Cache<'a> {
371376
key.content,
372377
glyphon::Attrs::new()
373378
.family(to_family(key.font))
374-
.color({
375-
let [r, g, b, a] = key.color.into_linear();
376-
377-
glyphon::Color::rgba(
378-
(r * 255.0) as u8,
379-
(g * 255.0) as u8,
380-
(b * 255.0) as u8,
381-
(a * 255.0) as u8,
382-
)
383-
})
384379
.monospaced(matches!(key.font, Font::Monospace)),
385380
);
386381

@@ -412,7 +407,6 @@ struct Key<'a> {
412407
size: f32,
413408
font: Font,
414409
bounds: Size,
415-
color: Color,
416410
}
417411

418412
type KeyHash = u64;

0 commit comments

Comments
 (0)