Updating to iced 0.14
This commit is contained in:
parent
6ff166120c
commit
3e99427f5e
3 changed files with 22 additions and 22 deletions
|
@ -6,7 +6,7 @@ use iced_video_player::{Video, VideoPlayer};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
fn main() -> iced::Result {
|
fn main() -> iced::Result {
|
||||||
iced::run("Iced Video Player", App::update, App::view)
|
iced::application(App::default, App::update, App::view).run()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -30,10 +30,8 @@ impl Default for App {
|
||||||
App {
|
App {
|
||||||
video: Video::new(
|
video: Video::new(
|
||||||
&url::Url::from_file_path(
|
&url::Url::from_file_path(
|
||||||
std::path::PathBuf::from(file!())
|
std::path::PathBuf::from("/home/chris/dev/iced_video_player/.media/test.mp4")
|
||||||
.parent()
|
// .join("../.media/test.mp4")
|
||||||
.unwrap()
|
|
||||||
.join("../.media/test.mp4")
|
|
||||||
.canonicalize()
|
.canonicalize()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use crate::video::Frame;
|
use crate::video::Frame;
|
||||||
|
use iced::wgpu::PipelineCompilationOptions;
|
||||||
use iced_wgpu::primitive::Primitive;
|
use iced_wgpu::primitive::Primitive;
|
||||||
use iced_wgpu::wgpu;
|
use iced_wgpu::wgpu;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -95,8 +96,9 @@ impl VideoPipeline {
|
||||||
layout: Some(&layout),
|
layout: Some(&layout),
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: Some("vs_main"),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
|
compilation_options: PipelineCompilationOptions::default(),
|
||||||
},
|
},
|
||||||
primitive: wgpu::PrimitiveState::default(),
|
primitive: wgpu::PrimitiveState::default(),
|
||||||
depth_stencil: None,
|
depth_stencil: None,
|
||||||
|
@ -107,14 +109,16 @@ impl VideoPipeline {
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: Some("fs_main"),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format,
|
format,
|
||||||
blend: None,
|
blend: None,
|
||||||
write_mask: wgpu::ColorWrites::ALL,
|
write_mask: wgpu::ColorWrites::ALL,
|
||||||
})],
|
})],
|
||||||
|
compilation_options: PipelineCompilationOptions::default(),
|
||||||
}),
|
}),
|
||||||
multiview: None,
|
multiview: None,
|
||||||
|
cache: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
let sampler = device.create_sampler(&wgpu::SamplerDescriptor {
|
||||||
|
@ -189,6 +193,7 @@ impl VideoPipeline {
|
||||||
mip_level_count: None,
|
mip_level_count: None,
|
||||||
base_array_layer: 0,
|
base_array_layer: 0,
|
||||||
array_layer_count: None,
|
array_layer_count: None,
|
||||||
|
usage: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let view_uv = texture_uv.create_view(&wgpu::TextureViewDescriptor {
|
let view_uv = texture_uv.create_view(&wgpu::TextureViewDescriptor {
|
||||||
|
@ -200,6 +205,7 @@ impl VideoPipeline {
|
||||||
mip_level_count: None,
|
mip_level_count: None,
|
||||||
base_array_layer: 0,
|
base_array_layer: 0,
|
||||||
array_layer_count: None,
|
array_layer_count: None,
|
||||||
|
usage: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
let instances = device.create_buffer(&wgpu::BufferDescriptor {
|
let instances = device.create_buffer(&wgpu::BufferDescriptor {
|
||||||
|
@ -255,14 +261,14 @@ impl VideoPipeline {
|
||||||
} = self.videos.get(&video_id).unwrap();
|
} = self.videos.get(&video_id).unwrap();
|
||||||
|
|
||||||
queue.write_texture(
|
queue.write_texture(
|
||||||
wgpu::ImageCopyTexture {
|
wgpu::TexelCopyTextureInfo {
|
||||||
texture: texture_y,
|
texture: texture_y,
|
||||||
mip_level: 0,
|
mip_level: 0,
|
||||||
origin: wgpu::Origin3d::ZERO,
|
origin: wgpu::Origin3d::ZERO,
|
||||||
aspect: wgpu::TextureAspect::All,
|
aspect: wgpu::TextureAspect::All,
|
||||||
},
|
},
|
||||||
&frame[..(width * height) as usize],
|
&frame[..(width * height) as usize],
|
||||||
wgpu::ImageDataLayout {
|
wgpu::TexelCopyBufferLayout {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
bytes_per_row: Some(width),
|
bytes_per_row: Some(width),
|
||||||
rows_per_image: Some(height),
|
rows_per_image: Some(height),
|
||||||
|
@ -275,14 +281,14 @@ impl VideoPipeline {
|
||||||
);
|
);
|
||||||
|
|
||||||
queue.write_texture(
|
queue.write_texture(
|
||||||
wgpu::ImageCopyTexture {
|
wgpu::TexelCopyTextureInfo {
|
||||||
texture: texture_uv,
|
texture: texture_uv,
|
||||||
mip_level: 0,
|
mip_level: 0,
|
||||||
origin: wgpu::Origin3d::ZERO,
|
origin: wgpu::Origin3d::ZERO,
|
||||||
aspect: wgpu::TextureAspect::All,
|
aspect: wgpu::TextureAspect::All,
|
||||||
},
|
},
|
||||||
&frame[(width * height) as usize..],
|
&frame[(width * height) as usize..],
|
||||||
wgpu::ImageDataLayout {
|
wgpu::TexelCopyBufferLayout {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
bytes_per_row: Some(width),
|
bytes_per_row: Some(width),
|
||||||
rows_per_image: Some(height / 2),
|
rows_per_image: Some(height / 2),
|
||||||
|
@ -356,6 +362,7 @@ impl VideoPipeline {
|
||||||
load: wgpu::LoadOp::Load,
|
load: wgpu::LoadOp::Load,
|
||||||
store: wgpu::StoreOp::Store,
|
store: wgpu::StoreOp::Store,
|
||||||
},
|
},
|
||||||
|
depth_slice: None,
|
||||||
})],
|
})],
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
timestamp_writes: None,
|
timestamp_writes: None,
|
||||||
|
|
|
@ -121,7 +121,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&self,
|
&mut self,
|
||||||
_tree: &mut widget::Tree,
|
_tree: &mut widget::Tree,
|
||||||
_renderer: &Renderer,
|
_renderer: &Renderer,
|
||||||
limits: &layout::Limits,
|
limits: &layout::Limits,
|
||||||
|
@ -212,17 +212,17 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_event(
|
fn update(
|
||||||
&mut self,
|
&mut self,
|
||||||
_state: &mut widget::Tree,
|
_state: &mut widget::Tree,
|
||||||
event: iced::Event,
|
event: &iced::Event,
|
||||||
_layout: advanced::Layout<'_>,
|
_layout: advanced::Layout<'_>,
|
||||||
_cursor: advanced::mouse::Cursor,
|
_cursor: advanced::mouse::Cursor,
|
||||||
_renderer: &Renderer,
|
_renderer: &Renderer,
|
||||||
_clipboard: &mut dyn advanced::Clipboard,
|
_clipboard: &mut dyn advanced::Clipboard,
|
||||||
shell: &mut advanced::Shell<'_, Message>,
|
shell: &mut advanced::Shell<'_, Message>,
|
||||||
_viewport: &iced::Rectangle,
|
_viewport: &iced::Rectangle,
|
||||||
) -> Status {
|
) {
|
||||||
let mut inner = self.video.write();
|
let mut inner = self.video.write();
|
||||||
|
|
||||||
if let iced::Event::Window(iced::window::Event::RedrawRequested(_)) = event {
|
if let iced::Event::Window(iced::window::Event::RedrawRequested(_)) = event {
|
||||||
|
@ -284,15 +284,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.request_redraw(iced::window::RedrawRequest::NextFrame);
|
shell.request_redraw();
|
||||||
} else {
|
} else {
|
||||||
shell.request_redraw(iced::window::RedrawRequest::At(
|
shell.request_redraw();
|
||||||
Instant::now() + Duration::from_millis(32),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
Status::Captured
|
|
||||||
} else {
|
|
||||||
Status::Ignored
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue