render: effectively rename Display to Output, push remaining common code into Renderer task
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::geometry::*;
|
||||
use crate::render::{Surface, Shader, Surfaces};
|
||||
use crate::lib8::interpolate::Fract8Ops;
|
||||
use crate::render::{PixelView, Sample, Shader, Surface, Surfaces};
|
||||
|
||||
use std::fmt::Debug;
|
||||
use std::rc::Rc;
|
||||
@@ -158,11 +159,27 @@ impl<S: Surface + Default> SurfacePool<S> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: Surface + Default> Surfaces<S> for SurfacePool<S> {
|
||||
impl<S: Surface + Default> Surfaces for SurfacePool<S> {
|
||||
type Surface = S;
|
||||
fn new_surface(&mut self, area: &Rectangle<Virtual>) -> Result<S, io::Error> {
|
||||
let mut surface = S::default();
|
||||
surface.set_rect(area);
|
||||
self.surfaces.push(surface.clone());
|
||||
return Ok(surface);
|
||||
}
|
||||
|
||||
fn render_to<Sampler: Sample>(&self, output: &mut Sampler, frame: usize) {
|
||||
for surface in self.iter() {
|
||||
let opacity = surface.opacity();
|
||||
if opacity > 0 {
|
||||
let rect = surface.rect();
|
||||
let mut sample = output.sample(&rect);
|
||||
surface.with_shader(|shader| {
|
||||
while let Some((virt_coords, pixel)) = sample.next() {
|
||||
*pixel = pixel.blend8(shader.draw(&virt_coords, frame).into(), opacity);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user