1#![feature(portable_simd)]
3
4use const_format::formatcp;
5
6#[cfg(target_arch = "x86_64")]
7mod assembler;
8mod framebuffer;
9mod memchr;
10mod original;
11mod refactored;
12
13#[cfg(target_arch = "x86_64")]
14pub use assembler::AssemblerParser;
15pub use framebuffer::{
16 FB_BYTES_PER_PIXEL, FrameBuffer, shared_memory::SharedMemoryFrameBuffer,
17 simple::SimpleFrameBuffer,
18};
19pub use memchr::MemchrParser;
20pub use original::OriginalParser;
21pub use refactored::RefactoredParser;
22
23pub const HELP_TEXT: &[u8] = formatcp!("\
24Pixelflut server powered by breakwater https://github.com/sbernauer/breakwater
25Available commands:
26HELP: Show this help
27PX x y rrggbb: Color the pixel (x,y) with the given hexadecimal color rrggbb
28{}
29PX x y gg: Color the pixel (x,y) with the hexadecimal color gggggg. Basically this is the same as the other commands, but is a more efficient way of filling white, black or gray areas
30PX x y: Get the color value of the pixel (x,y)
31{}{}SIZE: Get the size of the drawing surface, e.g. `SIZE 1920 1080`
32OFFSET x y: Apply offset (x,y) to all further pixel draws on this connection. This can e.g. be used to pre-calculate an image/animation and simply use the OFFSET command to move it around the screen without the need to re-calculate it
33",
34if cfg!(feature = "alpha") {
35 "PX x y rrggbbaa: Color the pixel (x,y) with the given hexadecimal color rrggbb and a transparency of aa, where ff means draw normally on top of the existing pixel and 00 means fully transparent (no change at all)"
36} else {
37 "PX x y rrggbbaa: Color the pixel (x,y) with the given hexadecimal color rrggbb. The alpha part is discarded for performance reasons, as breakwater was compiled without the alpha feature"
38},
39if cfg!(feature = "binary-set-pixel") {
40 "PBxxyyrgba: Binary version of the PX command. x and y are little-endian 16 bit coordinates, r, g, b and a are a byte each. There is *no* newline after the command.\n"
41} else {
42 ""
43},
44if cfg!(feature = "binary-sync-pixels") {
45 "PXMULTI<startX:16><startY:16><len:32><rgba 1 of (startX, startY)><rgba 2 of (startX + 1, startY)><rgba 3 of (startX + 1, startY)>...<rgba len>: EXPERIMENTAL binary syncing of whole pixel areas. Please note that for performance reasons this will be copied 1:1 to the servers framebuffer. The server will just take the following <len> bytes and memcpy it into the framebuffer, so the alpha channel doesn't matter and you might mess up the screen. This is intended for export-use, especially when syncing or combining multiple Pixelflut screens across multiple servers\n"
46} else {
47 ""
48},
49).as_bytes();
50
51pub const ALT_HELP_TEXT: &[u8] = b"Stop spamming HELP!\n";
52
53pub trait Parser {
54 fn parse(&mut self, buffer: &[u8], response: &mut Vec<u8>) -> usize;
56
57 fn parser_lookahead(&self) -> usize;
59}