Skip to content

Commit 0a23f51

Browse files
committed
Remove redundant features in iced_wgpu and iced_glow
1 parent d3b613d commit 0a23f51

8 files changed

Lines changed: 35 additions & 37 deletions

File tree

glow/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ repository = "https://github.com/iced-rs/iced"
99

1010
[features]
1111
svg = ["iced_graphics/svg"]
12-
image = ["image_rs", "iced_graphics/image", "png", "jpeg", "jpeg_rayon", "gif", "webp", "bmp"]
13-
image_rs = ["iced_graphics/image_rs"]
12+
image = ["iced_graphics/image"]
1413
png = ["iced_graphics/png"]
1514
jpeg = ["iced_graphics/jpeg"]
1615
jpeg_rayon = ["iced_graphics/jpeg_rayon"]

glow/src/backend.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[cfg(any(feature = "image_rs", feature = "svg"))]
1+
#[cfg(any(feature = "image", feature = "svg"))]
22
use crate::image;
33
use crate::quad;
44
use crate::text;
@@ -17,7 +17,7 @@ use iced_native::{Font, Size};
1717
/// [`iced`]: https://github.com/iced-rs/iced
1818
#[derive(Debug)]
1919
pub struct Backend {
20-
#[cfg(any(feature = "image_rs", feature = "svg"))]
20+
#[cfg(any(feature = "image", feature = "svg"))]
2121
image_pipeline: image::Pipeline,
2222
quad_pipeline: quad::Pipeline,
2323
text_pipeline: text::Pipeline,
@@ -36,13 +36,13 @@ impl Backend {
3636

3737
let shader_version = program::Version::new(gl);
3838

39-
#[cfg(any(feature = "image_rs", feature = "svg"))]
39+
#[cfg(any(feature = "image", feature = "svg"))]
4040
let image_pipeline = image::Pipeline::new(gl, &shader_version);
4141
let quad_pipeline = quad::Pipeline::new(gl, &shader_version);
4242
let triangle_pipeline = triangle::Pipeline::new(gl, &shader_version);
4343

4444
Self {
45-
#[cfg(any(feature = "image_rs", feature = "svg"))]
45+
#[cfg(any(feature = "image", feature = "svg"))]
4646
image_pipeline,
4747
quad_pipeline,
4848
text_pipeline,
@@ -79,7 +79,7 @@ impl Backend {
7979
);
8080
}
8181

82-
#[cfg(any(feature = "image_rs", feature = "svg"))]
82+
#[cfg(any(feature = "image", feature = "svg"))]
8383
self.image_pipeline.trim_cache(gl);
8484
}
8585

@@ -123,7 +123,7 @@ impl Backend {
123123
);
124124
}
125125

126-
#[cfg(any(feature = "image_rs", feature = "svg"))]
126+
#[cfg(any(feature = "image", feature = "svg"))]
127127
if !layer.images.is_empty() {
128128
let scaled = transformation
129129
* Transformation::scale(scale_factor, scale_factor);
@@ -256,7 +256,7 @@ impl backend::Text for Backend {
256256
}
257257
}
258258

259-
#[cfg(feature = "image_rs")]
259+
#[cfg(feature = "image")]
260260
impl backend::Image for Backend {
261261
fn dimensions(&self, handle: &iced_native::image::Handle) -> Size<u32> {
262262
self.image_pipeline.dimensions(handle)

glow/src/image.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub use iced_graphics::triangle::{Mesh2D, Vertex2D};
77
use crate::program::{self, Shader};
88
use crate::Transformation;
99

10-
#[cfg(feature = "image_rs")]
10+
#[cfg(feature = "image")]
1111
use iced_graphics::image::raster;
1212

1313
#[cfg(feature = "svg")]
@@ -27,7 +27,7 @@ pub(crate) struct Pipeline {
2727
vertex_buffer: <glow::Context as HasContext>::Buffer,
2828
transform_location: <glow::Context as HasContext>::UniformLocation,
2929
storage: Storage,
30-
#[cfg(feature = "image_rs")]
30+
#[cfg(feature = "image")]
3131
raster_cache: RefCell<raster::Cache<Storage>>,
3232
#[cfg(feature = "svg")]
3333
vector_cache: RefCell<vector::Cache<Storage>>,
@@ -115,14 +115,14 @@ impl Pipeline {
115115
vertex_buffer,
116116
transform_location,
117117
storage: Storage::default(),
118-
#[cfg(feature = "image_rs")]
118+
#[cfg(feature = "image")]
119119
raster_cache: RefCell::new(raster::Cache::default()),
120120
#[cfg(feature = "svg")]
121121
vector_cache: RefCell::new(vector::Cache::default()),
122122
}
123123
}
124124

125-
#[cfg(feature = "image_rs")]
125+
#[cfg(feature = "image")]
126126
pub fn dimensions(&self, handle: &iced_native::image::Handle) -> Size<u32> {
127127
self.raster_cache.borrow_mut().load(handle).dimensions()
128128
}
@@ -151,20 +151,20 @@ impl Pipeline {
151151
gl.bind_buffer(glow::ARRAY_BUFFER, Some(self.vertex_buffer));
152152
}
153153

154-
#[cfg(feature = "image_rs")]
154+
#[cfg(feature = "image")]
155155
let mut raster_cache = self.raster_cache.borrow_mut();
156156

157157
#[cfg(feature = "svg")]
158158
let mut vector_cache = self.vector_cache.borrow_mut();
159159

160160
for image in images {
161161
let (entry, bounds) = match &image {
162-
#[cfg(feature = "image_rs")]
162+
#[cfg(feature = "image")]
163163
layer::Image::Raster { handle, bounds } => (
164164
raster_cache.upload(handle, &mut gl, &mut self.storage),
165165
bounds,
166166
),
167-
#[cfg(not(feature = "image_rs"))]
167+
#[cfg(not(feature = "image"))]
168168
layer::Image::Raster { handle: _, bounds } => (None, bounds),
169169

170170
#[cfg(feature = "svg")]
@@ -217,7 +217,7 @@ impl Pipeline {
217217
}
218218

219219
pub fn trim_cache(&mut self, mut gl: &glow::Context) {
220-
#[cfg(feature = "image_rs")]
220+
#[cfg(feature = "image")]
221221
self.raster_cache
222222
.borrow_mut()
223223
.trim(&mut self.storage, &mut gl);

glow/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
pub use glow;
2525

2626
mod backend;
27-
#[cfg(any(feature = "image_rs", feature = "svg"))]
27+
#[cfg(any(feature = "image", feature = "svg"))]
2828
mod image;
2929
mod program;
3030
mod quad;

wgpu/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ repository = "https://github.com/iced-rs/iced"
99

1010
[features]
1111
svg = ["iced_graphics/svg"]
12-
image = ["image_rs", "iced_graphics/image", "png", "jpeg", "jpeg_rayon", "gif", "webp", "bmp"]
13-
image_rs = ["iced_graphics/image_rs"]
12+
image = ["iced_graphics/image"]
1413
png = ["iced_graphics/png"]
1514
jpeg = ["iced_graphics/jpeg"]
1615
jpeg_rayon = ["iced_graphics/jpeg_rayon"]

wgpu/src/backend.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use iced_graphics::{Primitive, Viewport};
1010
use iced_native::alignment;
1111
use iced_native::{Font, Size};
1212

13-
#[cfg(any(feature = "image_rs", feature = "svg"))]
13+
#[cfg(any(feature = "image", feature = "svg"))]
1414
use crate::image;
1515

1616
/// A [`wgpu`] graphics backend for [`iced`].
@@ -23,7 +23,7 @@ pub struct Backend {
2323
text_pipeline: text::Pipeline,
2424
triangle_pipeline: triangle::Pipeline,
2525

26-
#[cfg(any(feature = "image_rs", feature = "svg"))]
26+
#[cfg(any(feature = "image", feature = "svg"))]
2727
image_pipeline: image::Pipeline,
2828

2929
default_text_size: u16,
@@ -47,15 +47,15 @@ impl Backend {
4747
let triangle_pipeline =
4848
triangle::Pipeline::new(device, format, settings.antialiasing);
4949

50-
#[cfg(any(feature = "image_rs", feature = "svg"))]
50+
#[cfg(any(feature = "image", feature = "svg"))]
5151
let image_pipeline = image::Pipeline::new(device, format);
5252

5353
Self {
5454
quad_pipeline,
5555
text_pipeline,
5656
triangle_pipeline,
5757

58-
#[cfg(any(feature = "image_rs", feature = "svg"))]
58+
#[cfg(any(feature = "image", feature = "svg"))]
5959
image_pipeline,
6060

6161
default_text_size: settings.default_text_size,
@@ -98,7 +98,7 @@ impl Backend {
9898
);
9999
}
100100

101-
#[cfg(any(feature = "image_rs", feature = "svg"))]
101+
#[cfg(any(feature = "image", feature = "svg"))]
102102
self.image_pipeline.trim_cache(device, encoder);
103103
}
104104

@@ -148,7 +148,7 @@ impl Backend {
148148
);
149149
}
150150

151-
#[cfg(any(feature = "image_rs", feature = "svg"))]
151+
#[cfg(any(feature = "image", feature = "svg"))]
152152
{
153153
if !layer.images.is_empty() {
154154
let scaled = transformation
@@ -294,7 +294,7 @@ impl backend::Text for Backend {
294294
}
295295
}
296296

297-
#[cfg(feature = "image_rs")]
297+
#[cfg(feature = "image")]
298298
impl backend::Image for Backend {
299299
fn dimensions(&self, handle: &iced_native::image::Handle) -> Size<u32> {
300300
self.image_pipeline.dimensions(handle)

wgpu/src/image.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mod atlas;
22

3-
#[cfg(feature = "image_rs")]
3+
#[cfg(feature = "image")]
44
use iced_graphics::image::raster;
55

66
#[cfg(feature = "svg")]
@@ -17,15 +17,15 @@ use std::mem;
1717

1818
use bytemuck::{Pod, Zeroable};
1919

20-
#[cfg(feature = "image_rs")]
20+
#[cfg(feature = "image")]
2121
use iced_native::image;
2222

2323
#[cfg(feature = "svg")]
2424
use iced_native::svg;
2525

2626
#[derive(Debug)]
2727
pub struct Pipeline {
28-
#[cfg(feature = "image_rs")]
28+
#[cfg(feature = "image")]
2929
raster_cache: RefCell<raster::Cache<Atlas>>,
3030
#[cfg(feature = "svg")]
3131
vector_cache: RefCell<vector::Cache<Atlas>>,
@@ -243,7 +243,7 @@ impl Pipeline {
243243
});
244244

245245
Pipeline {
246-
#[cfg(feature = "image_rs")]
246+
#[cfg(feature = "image")]
247247
raster_cache: RefCell::new(raster::Cache::default()),
248248

249249
#[cfg(feature = "svg")]
@@ -262,7 +262,7 @@ impl Pipeline {
262262
}
263263
}
264264

265-
#[cfg(feature = "image_rs")]
265+
#[cfg(feature = "image")]
266266
pub fn dimensions(&self, handle: &image::Handle) -> Size<u32> {
267267
let mut cache = self.raster_cache.borrow_mut();
268268
let memory = cache.load(handle);
@@ -291,15 +291,15 @@ impl Pipeline {
291291
) {
292292
let instances: &mut Vec<Instance> = &mut Vec::new();
293293

294-
#[cfg(feature = "image_rs")]
294+
#[cfg(feature = "image")]
295295
let mut raster_cache = self.raster_cache.borrow_mut();
296296

297297
#[cfg(feature = "svg")]
298298
let mut vector_cache = self.vector_cache.borrow_mut();
299299

300300
for image in images {
301301
match &image {
302-
#[cfg(feature = "image_rs")]
302+
#[cfg(feature = "image")]
303303
layer::Image::Raster { handle, bounds } => {
304304
if let Some(atlas_entry) = raster_cache.upload(
305305
handle,
@@ -314,7 +314,7 @@ impl Pipeline {
314314
);
315315
}
316316
}
317-
#[cfg(not(feature = "image_rs"))]
317+
#[cfg(not(feature = "image"))]
318318
layer::Image::Raster { .. } => {}
319319

320320
#[cfg(feature = "svg")]
@@ -450,7 +450,7 @@ impl Pipeline {
450450
device: &wgpu::Device,
451451
encoder: &mut wgpu::CommandEncoder,
452452
) {
453-
#[cfg(feature = "image_rs")]
453+
#[cfg(feature = "image")]
454454
self.raster_cache
455455
.borrow_mut()
456456
.trim(&mut self.texture_atlas, &mut (device, encoder));

wgpu/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub use settings::Settings;
5656

5757
pub(crate) use iced_graphics::Transformation;
5858

59-
#[cfg(any(feature = "image_rs", feature = "svg"))]
59+
#[cfg(any(feature = "image", feature = "svg"))]
6060
mod image;
6161

6262
/// A [`wgpu`] graphics renderer for [`iced`].

0 commit comments

Comments
 (0)