2021-01-04 20:45:23 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
2021-01-16 20:02:08 +00:00
|
|
|
/*
|
|
|
|
|
Primitives needed:
|
|
|
|
|
|
|
|
|
|
- clipping rectangles (for drawing)
|
|
|
|
|
- rounded rectangles
|
|
|
|
|
- inverse text
|
|
|
|
|
- icons/sprites
|
|
|
|
|
- width of a text string with a given font (to compute alignments)
|
|
|
|
|
- untrusted backgrounds
|
|
|
|
|
- bitmaps
|
|
|
|
|
|
|
|
|
|
*/
|
2020-12-02 17:48:10 +00:00
|
|
|
|
2021-01-19 09:10:31 +00:00
|
|
|
//////////////// primitives
|
|
|
|
|
pub mod points;
|
|
|
|
|
pub use points::Point;
|
|
|
|
|
pub mod styles;
|
|
|
|
|
pub use styles::*;
|
|
|
|
|
pub mod shapes;
|
|
|
|
|
pub use shapes::*;
|
|
|
|
|
pub mod text;
|
|
|
|
|
pub use text::*;
|
2022-01-21 07:01:56 +00:00
|
|
|
pub mod glyphstyle;
|
|
|
|
|
pub use glyphstyle::*;
|
2022-01-22 20:08:32 +00:00
|
|
|
pub mod blitstr2;
|
|
|
|
|
pub use blitstr2::*;
|
2020-12-02 17:48:10 +00:00
|
|
|
|
2021-08-03 17:25:32 +00:00
|
|
|
use std::hash::{Hash, Hasher};
|
2020-12-02 17:48:10 +00:00
|
|
|
|
2022-01-22 20:08:32 +00:00
|
|
|
pub const LINES: usize = 536;
|
|
|
|
|
pub const WIDTH: usize = 336;
|
|
|
|
|
|
2021-04-02 16:53:30 +00:00
|
|
|
//////////////// IPC APIs
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)]
|
2021-01-19 09:10:31 +00:00
|
|
|
pub struct Gid {
|
|
|
|
|
/// a 128-bit random identifier for graphical objects
|
|
|
|
|
gid: [u32; 4],
|
2020-08-29 17:17:56 +00:00
|
|
|
}
|
2021-01-19 09:10:31 +00:00
|
|
|
impl Gid {
|
2021-08-16 14:52:06 +00:00
|
|
|
pub fn new(id: [u32; 4]) -> Self {
|
|
|
|
|
Gid { gid: id }
|
|
|
|
|
}
|
|
|
|
|
pub fn gid(&self) -> [u32; 4] {
|
|
|
|
|
self.gid
|
|
|
|
|
}
|
2020-12-02 17:48:10 +00:00
|
|
|
}
|
2021-08-03 17:25:32 +00:00
|
|
|
impl Hash for Gid {
|
2021-01-19 09:10:31 +00:00
|
|
|
fn hash<H>(&self, state: &mut H)
|
|
|
|
|
where
|
2021-08-16 14:52:06 +00:00
|
|
|
H: Hasher,
|
2021-01-19 09:10:31 +00:00
|
|
|
{
|
|
|
|
|
Hash::hash(&self.gid[..], state);
|
2020-12-02 17:48:10 +00:00
|
|
|
}
|
2020-11-22 16:40:40 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-16 14:52:06 +00:00
|
|
|
pub const SERVER_NAME_GFX: &str = "_Graphics_";
|
2021-04-02 16:53:30 +00:00
|
|
|
|
|
|
|
|
#[derive(Debug, num_derive::FromPrimitive, num_derive::ToPrimitive)]
|
2021-04-02 16:57:30 +00:00
|
|
|
pub(crate) enum Opcode {
|
2020-08-29 17:17:56 +00:00
|
|
|
/// Flush the buffer to the screen
|
|
|
|
|
Flush,
|
|
|
|
|
|
2020-12-02 17:48:10 +00:00
|
|
|
/// Clear the buffer to "light" colored pixels
|
|
|
|
|
Clear,
|
2020-08-29 17:17:56 +00:00
|
|
|
|
|
|
|
|
/// Draw a line at the specified area
|
2021-04-02 16:53:30 +00:00
|
|
|
Line, //(Line),
|
2020-08-29 17:17:56 +00:00
|
|
|
|
|
|
|
|
/// Draw a rectangle or square at the specified coordinates
|
2021-04-02 16:53:30 +00:00
|
|
|
Rectangle, //(Rectangle),
|
2020-08-29 17:17:56 +00:00
|
|
|
|
2021-02-28 20:01:33 +00:00
|
|
|
/// Draw a rounded rectangle
|
2021-04-02 16:53:30 +00:00
|
|
|
RoundedRectangle, //(RoundedRectangle),
|
2021-02-28 20:01:33 +00:00
|
|
|
|
2020-08-29 17:17:56 +00:00
|
|
|
/// Draw a circle with a specified radius
|
2021-04-02 16:53:30 +00:00
|
|
|
Circle, //(Circle),
|
2021-01-18 16:05:33 +00:00
|
|
|
|
2020-11-23 06:55:56 +00:00
|
|
|
/// Retrieve the X and Y dimensions of the screen
|
|
|
|
|
ScreenSize,
|
2020-11-23 07:42:58 +00:00
|
|
|
|
2021-01-17 20:12:40 +00:00
|
|
|
/// gets info about the current glyph to assist with layout
|
2021-04-02 16:53:30 +00:00
|
|
|
QueryGlyphProps, //(GlyphStyle),
|
2021-01-18 20:54:54 +00:00
|
|
|
|
2021-03-05 17:10:18 +00:00
|
|
|
/// draws a textview
|
2021-04-02 16:53:30 +00:00
|
|
|
DrawTextView, //(TextView),
|
2021-03-05 17:10:18 +00:00
|
|
|
|
|
|
|
|
/// draws an object that requires clipping
|
2021-04-02 16:53:30 +00:00
|
|
|
DrawClipObject, //(ClipObject),
|
2021-03-10 17:45:54 +00:00
|
|
|
|
|
|
|
|
/// draws the sleep screen; assumes requests are vetted by GAM/xous-names
|
2021-05-01 17:38:44 +00:00
|
|
|
DrawSleepScreen,
|
|
|
|
|
|
2021-05-01 19:36:54 +00:00
|
|
|
/// sets whether a sleep note should be rendered or not on suspend
|
|
|
|
|
SetSleepNote,
|
|
|
|
|
|
2021-07-03 13:08:39 +00:00
|
|
|
/// permanently turns on the Devboot mark
|
|
|
|
|
Devboot,
|
|
|
|
|
|
2021-08-02 20:58:34 +00:00
|
|
|
/// bulk read for signature verifications
|
|
|
|
|
BulkReadFonts,
|
|
|
|
|
RestartBulkRead,
|
|
|
|
|
|
2021-09-15 17:00:22 +00:00
|
|
|
/// generates a test pattern
|
|
|
|
|
TestPattern,
|
|
|
|
|
|
2021-05-01 17:38:44 +00:00
|
|
|
/// SuspendResume callback
|
|
|
|
|
SuspendResume,
|
2021-06-12 20:40:50 +00:00
|
|
|
|
|
|
|
|
Quit,
|
2020-08-29 17:17:56 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
2021-03-05 17:10:18 +00:00
|
|
|
pub enum ClipObjectType {
|
|
|
|
|
Line(Line),
|
|
|
|
|
Circ(Circle),
|
|
|
|
|
Rect(Rectangle),
|
|
|
|
|
RoundRect(RoundedRectangle),
|
2021-07-29 14:13:44 +00:00
|
|
|
XorLine(Line),
|
2021-03-05 17:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
2021-03-15 18:02:53 +00:00
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
2021-03-05 17:10:18 +00:00
|
|
|
pub struct ClipObject {
|
|
|
|
|
pub clip: Rectangle,
|
|
|
|
|
pub obj: ClipObjectType,
|
|
|
|
|
}
|
2021-06-12 20:40:50 +00:00
|
|
|
|
|
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
|
|
|
|
pub struct TokenClaim {
|
|
|
|
|
pub token: Option<[u32; 4]>,
|
2021-08-16 14:52:06 +00:00
|
|
|
pub name: xous_ipc::String<128>,
|
2021-08-02 20:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// the buffer length of this equal to the internal length passed by the
|
|
|
|
|
/// engine-sha512 implementation times 2 (a small amount of overhead is required
|
|
|
|
|
/// out of an even 4096 page for bookkeeping). We could make this a neat power of 2,
|
|
|
|
|
/// but then you'd end up doing an extra memory message for the overhead bits that
|
|
|
|
|
/// are left over.
|
|
|
|
|
#[derive(Debug, rkyv::Archive, rkyv::Serialize, rkyv::Deserialize, Copy, Clone)]
|
|
|
|
|
pub struct BulkRead {
|
|
|
|
|
pub buf: [u8; 7936],
|
|
|
|
|
pub from_offset: u32,
|
|
|
|
|
pub len: u32, // used to return the length read out of the font map
|
|
|
|
|
}
|
|
|
|
|
impl BulkRead {
|
|
|
|
|
pub fn default() -> BulkRead {
|
|
|
|
|
BulkRead {
|
|
|
|
|
buf: [0; 7936],
|
|
|
|
|
from_offset: 0,
|
|
|
|
|
len: 7936,
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-16 14:52:06 +00:00
|
|
|
}
|