From a8e78090873d7165449b6d40905341f57f25287e Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 27 May 2022 17:41:22 +0800 Subject: [PATCH] fixup feature fest --- services/gam/Cargo.toml | 2 +- services/gam/src/bitmap.rs | 21 ++++++++++----------- services/graphics-server/src/api/shapes.rs | 4 ---- services/graphics-server/src/api/tile.rs | 2 ++ services/graphics-server/src/op.rs | 3 ++- services/modals/Cargo.toml | 2 +- services/modals/src/lib.rs | 6 ++++-- xtask/src/main.rs | 4 +++- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/services/gam/Cargo.toml b/services/gam/Cargo.toml index 024def170..4a54ff958 100644 --- a/services/gam/Cargo.toml +++ b/services/gam/Cargo.toml @@ -45,6 +45,6 @@ utralib = {path = "../../utralib"} [features] debugprint = [] tts = [] -ditherpunk = [] +ditherpunk = ["dither", "image"] # default = ["debugprint"] # "debugprint" default = [] diff --git a/services/gam/src/bitmap.rs b/services/gam/src/bitmap.rs index f4fcfdb38..33b2f022d 100644 --- a/services/gam/src/bitmap.rs +++ b/services/gam/src/bitmap.rs @@ -1,7 +1,6 @@ use core::cmp::{max, min}; use dither::prelude::{Dither, Img, RGB}; -use graphics_server::api::shapes; -use graphics_server::api::{Point, Rectangle, Tile}; +use graphics_server::api::*; use graphics_server::PixelColor; use std::convert::TryInto; use std::ops::Deref; @@ -62,17 +61,17 @@ impl Bitmap { fn tile_spec(bm_size: Point) -> (Point, i16) { let bm_width_bits = 1 + bm_size.x as usize; let mut tile_width_bits = bm_width_bits; - let tile_width_words = if bm_width_bits > shapes::BITS_PER_TILE { + let tile_width_words = if bm_width_bits > BITS_PER_TILE { log::warn!("Bitmap max width exceeded"); - tile_width_bits = shapes::WORDS_PER_TILE * shapes::BITS_PER_WORD; - shapes::WORDS_PER_TILE + tile_width_bits = WORDS_PER_TILE * BITS_PER_WORD; + WORDS_PER_TILE } else { - match bm_width_bits % shapes::BITS_PER_WORD { - 0 => bm_width_bits / shapes::BITS_PER_WORD, - _ => bm_width_bits / shapes::BITS_PER_WORD + 1, + match bm_width_bits % BITS_PER_WORD { + 0 => bm_width_bits / BITS_PER_WORD, + _ => bm_width_bits / BITS_PER_WORD + 1, } }; - let tile_height_bits = shapes::WORDS_PER_TILE / tile_width_words; + let tile_height_bits = WORDS_PER_TILE / tile_width_words; let tile_size = Point::new(tile_width_bits as i16, tile_height_bits as i16); (tile_size, tile_width_words as i16) } @@ -134,12 +133,12 @@ impl Bitmap { &mut self.mosaic.as_mut_slice()[tile] } - pub fn get_line(&self, point: Point) -> Vec { + pub fn get_line(&self, point: Point) -> Vec { self.get_tile(point).get_line(point) } #[allow(dead_code)] - fn get_word(&self, point: Point) -> shapes::Word { + fn get_word(&self, point: Point) -> Word { self.get_tile(point).get_word(point) } diff --git a/services/graphics-server/src/api/shapes.rs b/services/graphics-server/src/api/shapes.rs index ceea0e439..8e2088499 100644 --- a/services/graphics-server/src/api/shapes.rs +++ b/services/graphics-server/src/api/shapes.rs @@ -1,10 +1,6 @@ use crate::api::{ClipRect, DrawStyle, Point}; use crate::op::{HEIGHT, WIDTH}; use core::cmp::{max, min}; -#[cfg(feature="ditherpunk")] -use crate::api::PixelColor; -#[cfg(feature="ditherpunk")] -use std::convert::TryInto; #[derive(Debug, Clone, Copy, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)] pub struct Rectangle { diff --git a/services/graphics-server/src/api/tile.rs b/services/graphics-server/src/api/tile.rs index d6edda0a3..7d1f5a448 100644 --- a/services/graphics-server/src/api/tile.rs +++ b/services/graphics-server/src/api/tile.rs @@ -1,3 +1,5 @@ +use crate::api::*; +use std::convert::TryInto; //////////////////////// Tile -------- author: nworbnhoj /* diff --git a/services/graphics-server/src/op.rs b/services/graphics-server/src/op.rs index e5d298775..2a9211c64 100644 --- a/services/graphics-server/src/op.rs +++ b/services/graphics-server/src/op.rs @@ -590,9 +590,10 @@ pub fn rounded_rectangle(fb: &mut LcdFB, rr: RoundedRectangle, clip: Option) { use std::cmp::min; - use crate::api::Tile; // prepare the clip boundries: min (LCD, clip, tile) let bound = tile.bound(); let tl_x = bound.tl.x as usize; diff --git a/services/modals/Cargo.toml b/services/modals/Cargo.toml index 196130828..7b42e4939 100644 --- a/services/modals/Cargo.toml +++ b/services/modals/Cargo.toml @@ -33,5 +33,5 @@ utralib = { path = "../../utralib"} [features] tts = [] -ditherpunk = [] +ditherpunk = ["image", "dither", "fast_image_resize"] default = [] diff --git a/services/modals/src/lib.rs b/services/modals/src/lib.rs index 7e146bee5..b5bdc9d3e 100644 --- a/services/modals/src/lib.rs +++ b/services/modals/src/lib.rs @@ -198,12 +198,14 @@ impl Modals { Ok(()) } + #[cfg(feature="ditherpunk")] + const MODAL_WIDTH: u32 = 300; + #[cfg(feature="ditherpunk")] + const MODAL_HEIGHT: u32 = 370; /// this blocks until the image has been dismissed. #[cfg(feature="ditherpunk")] pub fn show_image(&self, img: &RgbImage) -> Result<(), xous::Error> { self.lock(); - const MODAL_WIDTH: u32 = 300; - const MODAL_HEIGHT: u32 = 370; // resize and/or rotate let (modal_width, modal_height) = (Modals::MODAL_WIDTH as f32, Modals::MODAL_HEIGHT as f32); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 2c99c34af..5ffb06ee0 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -457,7 +457,9 @@ fn main() -> Result<(), Box> { &pkgs, lkey, kkey, - None, + Some(&[ + "--features", "ditherpunk", + ]), &[], None, )?