services/graphics-server: Implement From instead of Into

Signed-off-by: Jean-Pierre De Jesus DIAZ <me@jeandudey.tech>
This commit is contained in:
Jean-Pierre De Jesus DIAZ 2022-10-12 15:31:53 +02:00
parent 0316cd2a3a
commit 136aec042b
No known key found for this signature in database
GPG key ID: 6279AEC20A9524EC
5 changed files with 28 additions and 28 deletions

View file

@ -29,9 +29,9 @@ impl From<usize> for GlyphStyle {
/// Convert style to number for use with register-based message passing sytems /// Convert style to number for use with register-based message passing sytems
// [by bunnie for Xous] // [by bunnie for Xous]
impl Into<usize> for GlyphStyle { impl From<GlyphStyle> for usize {
fn into(self) -> usize { fn from(g: GlyphStyle) -> usize {
match self { match g {
GlyphStyle::Small => 0, GlyphStyle::Small => 0,
GlyphStyle::Regular => 1, GlyphStyle::Regular => 1,
GlyphStyle::Bold => 2, GlyphStyle::Bold => 2,

View file

@ -99,9 +99,9 @@ impl From<&Point> for (i16, i16) {
} }
} }
impl Into<usize> for Point { impl From<Point> for usize {
fn into(self) -> usize { fn from(point: Point) -> usize {
(self.x as usize) << 16 | (self.y as usize) (point.x as usize) << 16 | (point.y as usize)
} }
} }

View file

@ -248,13 +248,13 @@ impl Rectangle {
} }
} }
impl Into<ClipRect> for Rectangle { impl From<Rectangle> for ClipRect {
fn into(self) -> ClipRect { fn from(rectangle: Rectangle) -> ClipRect {
ClipRect::new( ClipRect::new(
self.x0() as _, rectangle.x0() as _,
self.y0() as _, rectangle.y0() as _,
self.x1() as _, rectangle.x1() as _,
self.y1() as _, rectangle.y1() as _,
) )
} }
} }

View file

@ -16,9 +16,9 @@ impl From<bool> for PixelColor {
} }
} }
impl Into<bool> for PixelColor { impl From<PixelColor> for bool {
fn into(self) -> bool { fn from(pc: PixelColor) -> bool {
if self == PixelColor::Dark { if pc == PixelColor::Dark {
true true
} else { } else {
false false
@ -36,9 +36,9 @@ impl From<usize> for PixelColor {
} }
} }
impl Into<usize> for PixelColor { impl From<PixelColor> for usize {
fn into(self) -> usize { fn from(pc: PixelColor) -> usize {
if self == PixelColor::Light { if pc == PixelColor::Light {
0 0
} else { } else {
1 1
@ -103,11 +103,11 @@ impl From<usize> for DrawStyle {
} }
} }
impl Into<usize> for DrawStyle { impl From<DrawStyle> for usize {
fn into(self) -> usize { fn from(draw_style: DrawStyle) -> usize {
let sc: usize; let sc: usize;
if self.stroke_color.is_some() { if draw_style.stroke_color.is_some() {
if self.stroke_color.unwrap() == PixelColor::Dark { if draw_style.stroke_color.unwrap() == PixelColor::Dark {
sc = 0b11; sc = 0b11;
} else { } else {
sc = 0b10; sc = 0b10;
@ -116,8 +116,8 @@ impl Into<usize> for DrawStyle {
sc = 0; sc = 0;
} }
let fc: usize; let fc: usize;
if self.fill_color.is_some() { if draw_style.fill_color.is_some() {
if self.fill_color.unwrap() == PixelColor::Dark { if draw_style.fill_color.unwrap() == PixelColor::Dark {
fc = 0b11; fc = 0b11;
} else { } else {
fc = 0b10; fc = 0b10;
@ -126,7 +126,7 @@ impl Into<usize> for DrawStyle {
} else { } else {
fc = 0; fc = 0;
} }
(self.stroke_width as usize) << 16 | sc << 2 | fc (draw_style.stroke_width as usize) << 16 | sc << 2 | fc
} }
} }

View file

@ -58,9 +58,9 @@ pub enum TextOp {
Render, Render,
ComputeBounds, // maybe we don't need this ComputeBounds, // maybe we don't need this
} }
impl Into<usize> for TextOp { impl From<TextOp> for usize {
fn into(self) -> usize { fn from(op: TextOp) -> usize {
match self { match op {
TextOp::Nop => 0, TextOp::Nop => 0,
TextOp::Render => 1, TextOp::Render => 1,
TextOp::ComputeBounds => 2, TextOp::ComputeBounds => 2,