1
0
Fork 0
forked from wry/wry

render: split rendering into two phases

In the first phase we collect a list of simple operations (copying
textures and filling rectangles.)

In the second phase we send this list to the graphics API to be
executed.

As part of this, we also remove the use of scissors.
This commit is contained in:
Julian Orth 2023-10-22 16:10:10 +02:00
parent a2a04512ed
commit 5e8a6eb86f
27 changed files with 732 additions and 384 deletions

View file

@ -1,6 +1,9 @@
use std::cell::{Cell, RefCell};
use std::{
cell::{Cell, RefCell},
cmp::Ordering,
};
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Color {
pub r: f32,
pub g: f32,
@ -8,6 +11,24 @@ pub struct Color {
pub a: f32,
}
impl Eq for Color {}
impl Ord for Color {
fn cmp(&self, other: &Self) -> Ordering {
self.r
.total_cmp(&other.r)
.then_with(|| self.g.total_cmp(&other.g))
.then_with(|| self.b.total_cmp(&other.b))
.then_with(|| self.a.total_cmp(&other.a))
}
}
impl PartialOrd for Color {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
fn to_f32(c: u8) -> f32 {
c as f32 / 255f32
}