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