Remove trait-specific draw logic in iced_native
This commit is contained in:
parent
3aae45c191
commit
03b3493138
71 changed files with 641 additions and 3126 deletions
|
|
@ -5,10 +5,8 @@ use crate::{Settings, Transformation, Viewport};
|
|||
|
||||
use iced_graphics::backend;
|
||||
use iced_graphics::font;
|
||||
use iced_graphics::Layer;
|
||||
use iced_graphics::Primitive;
|
||||
use iced_graphics::{Layer, Primitive};
|
||||
use iced_native::alignment;
|
||||
use iced_native::mouse;
|
||||
use iced_native::{Font, Size};
|
||||
|
||||
/// A [`glow`] graphics backend for [`iced`].
|
||||
|
|
@ -47,13 +45,13 @@ impl Backend {
|
|||
///
|
||||
/// The text provided as overlay will be rendered on top of the primitives.
|
||||
/// This is useful for rendering debug information.
|
||||
pub fn draw<T: AsRef<str>>(
|
||||
pub fn present<T: AsRef<str>>(
|
||||
&mut self,
|
||||
gl: &glow::Context,
|
||||
primitive: &Primitive,
|
||||
viewport: &Viewport,
|
||||
(primitive, mouse_interaction): &(Primitive, mouse::Interaction),
|
||||
overlay_text: &[T],
|
||||
) -> mouse::Interaction {
|
||||
) {
|
||||
let viewport_size = viewport.physical_size();
|
||||
let scale_factor = viewport.scale_factor() as f32;
|
||||
let projection = viewport.projection();
|
||||
|
|
@ -70,8 +68,6 @@ impl Backend {
|
|||
viewport_size.height,
|
||||
);
|
||||
}
|
||||
|
||||
*mouse_interaction
|
||||
}
|
||||
|
||||
fn flush(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use crate::{Backend, Color, Error, Renderer, Settings, Viewport};
|
|||
use core::ffi::c_void;
|
||||
use glow::HasContext;
|
||||
use iced_graphics::{Antialiasing, Size};
|
||||
use iced_native::mouse;
|
||||
|
||||
/// A window graphics backend for iced powered by `glow`.
|
||||
#[allow(missing_debug_implementations)]
|
||||
|
|
@ -59,14 +58,13 @@ impl iced_graphics::window::GLCompositor for Compositor {
|
|||
}
|
||||
}
|
||||
|
||||
fn draw<T: AsRef<str>>(
|
||||
fn present<T: AsRef<str>>(
|
||||
&mut self,
|
||||
renderer: &mut Self::Renderer,
|
||||
viewport: &Viewport,
|
||||
color: Color,
|
||||
output: &<Self::Renderer as iced_native::Renderer>::Output,
|
||||
overlay: &[T],
|
||||
) -> mouse::Interaction {
|
||||
) {
|
||||
let gl = &self.gl;
|
||||
|
||||
let [r, g, b, a] = color.into_linear();
|
||||
|
|
@ -76,6 +74,8 @@ impl iced_graphics::window::GLCompositor for Compositor {
|
|||
gl.clear(glow::COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
renderer.backend_mut().draw(gl, viewport, output, overlay)
|
||||
renderer.present(|backend, primitive| {
|
||||
backend.present(gl, primitive, viewport, overlay);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue