update iced to 0.13, v0.4

This commit is contained in:
jazzfool 2024-09-21 13:20:43 +10:00
parent 65f9cc5a5d
commit 61b083929e
6 changed files with 1151 additions and 256 deletions

View file

@ -1,4 +1,4 @@
use iced_wgpu::primitive::pipeline::Primitive;
use iced_wgpu::primitive::Primitive;
use iced_wgpu::wgpu;
use std::{
collections::BTreeMap,
@ -204,7 +204,7 @@ impl VideoPipeline {
);
}
fn prepare(&mut self, queue: &wgpu::Queue, video_id: u64, bounds: iced::Rectangle) {
fn prepare(&mut self, queue: &wgpu::Queue, video_id: u64, bounds: &iced::Rectangle) {
if let Some((_, buffer, _)) = self.textures.get(&video_id) {
let uniforms = Uniforms {
rect: [
@ -227,7 +227,7 @@ impl VideoPipeline {
&self,
target: &wgpu::TextureView,
encoder: &mut wgpu::CommandEncoder,
viewport: iced::Rectangle<u32>,
viewport: &iced::Rectangle<u32>,
video_id: u64,
) {
if let Some((_, _, bind_group)) = self.textures.get(&video_id) {
@ -288,13 +288,12 @@ impl VideoPrimitive {
impl Primitive for VideoPrimitive {
fn prepare(
&self,
format: wgpu::TextureFormat,
device: &wgpu::Device,
queue: &wgpu::Queue,
bounds: iced::Rectangle,
_target_size: iced::Size<u32>,
_scale_factor: f32,
storage: &mut iced_wgpu::primitive::pipeline::Storage,
format: wgpu::TextureFormat,
storage: &mut iced_wgpu::primitive::Storage,
bounds: &iced::Rectangle,
_viewport: &iced_wgpu::graphics::Viewport,
) {
if !storage.has::<VideoPipeline>() {
storage.store(VideoPipeline::new(device, format));
@ -317,13 +316,12 @@ impl Primitive for VideoPrimitive {
fn render(
&self,
storage: &iced_wgpu::primitive::pipeline::Storage,
target: &wgpu::TextureView,
_target_size: iced::Size<u32>,
viewport: iced::Rectangle<u32>,
encoder: &mut wgpu::CommandEncoder,
storage: &iced_wgpu::primitive::Storage,
target: &wgpu::TextureView,
clip_bounds: &iced::Rectangle<u32>,
) {
let pipeline = storage.get::<VideoPipeline>().unwrap();
pipeline.draw(target, encoder, viewport, self.video_id);
pipeline.draw(target, encoder, clip_bounds, self.video_id);
}
}

View file

@ -353,7 +353,7 @@ impl Video {
// maybe in a small window between seek and wait the old frame comes in?
inner.wait.recv().map_err(|_| Error::Sync)?;
inner.wait.recv().map_err(|_| Error::Sync)?;
Ok(img::Handle::from_pixels(
Ok(img::Handle::from_rgba(
inner.width as _,
inner.height as _,
self.0

View file

@ -4,7 +4,7 @@ use iced::{
advanced::{self, graphics::core::event::Status, layout, widget, Widget},
Element,
};
use iced_wgpu::primitive::pipeline::Renderer as PrimitiveRenderer;
use iced_wgpu::primitive::Renderer as PrimitiveRenderer;
use log::error;
use std::{marker::PhantomData, sync::atomic::Ordering};
use std::{sync::Arc, time::Duration};
@ -111,7 +111,7 @@ where
_viewport: &iced::Rectangle,
) {
let inner = self.video.0.borrow();
renderer.draw_pipeline_primitive(
renderer.draw_primitive(
layout.bounds(),
VideoPrimitive::new(
inner.id,
@ -135,7 +135,7 @@ where
) -> Status {
let mut inner = self.video.0.borrow_mut();
if let iced::Event::Window(_, iced::window::Event::RedrawRequested(now)) = event {
if let iced::Event::Window(iced::window::Event::RedrawRequested(now)) = event {
if inner.restart_stream || (!inner.is_eos && !inner.paused) {
let mut restart_stream = false;
if inner.restart_stream {