wayland: implement surface transformations
- buffer scale - buffer transform - viewporter
This commit is contained in:
parent
20f0fba553
commit
95327685c1
16 changed files with 635 additions and 75 deletions
21
src/fixed.rs
21
src/fixed.rs
|
|
@ -1,4 +1,5 @@
|
|||
use std::{
|
||||
cmp::Ordering,
|
||||
fmt::{Debug, Display, Formatter},
|
||||
ops::{Add, AddAssign, Sub, SubAssign},
|
||||
};
|
||||
|
|
@ -8,6 +9,10 @@ use std::{
|
|||
pub struct Fixed(pub i32);
|
||||
|
||||
impl Fixed {
|
||||
pub fn is_integer(self) -> bool {
|
||||
self.0 & 255 == 0
|
||||
}
|
||||
|
||||
pub fn from_f64(f: f64) -> Self {
|
||||
Self((f * 256.0) as i32)
|
||||
}
|
||||
|
|
@ -20,6 +25,10 @@ impl Fixed {
|
|||
Self(i >> 8)
|
||||
}
|
||||
|
||||
pub fn to_int(self) -> i32 {
|
||||
self.0 >> 8
|
||||
}
|
||||
|
||||
pub fn from_int(i: i32) -> Self {
|
||||
Self(i << 8)
|
||||
}
|
||||
|
|
@ -33,6 +42,18 @@ impl Fixed {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq<i32> for Fixed {
|
||||
fn eq(&self, other: &i32) -> bool {
|
||||
self.0 == *other << 8
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd<i32> for Fixed {
|
||||
fn partial_cmp(&self, other: &i32) -> Option<Ordering> {
|
||||
self.0.partial_cmp(&(*other << 8))
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for Fixed {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
Debug::fmt(&self.to_f64(), f)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue