switch size data types to u16
The binary protocol is limited to using u16's so limit everything to that.
This commit is contained in:
@@ -15,8 +15,8 @@ pub struct Canvas {
|
||||
host: String,
|
||||
painter_count: usize,
|
||||
painter_handles: Vec<Handle>,
|
||||
size: (u32, u32),
|
||||
offset: (u32, u32),
|
||||
size: (u16, u16),
|
||||
offset: (u16, u16),
|
||||
}
|
||||
|
||||
impl Canvas {
|
||||
@@ -24,8 +24,8 @@ impl Canvas {
|
||||
pub fn new(
|
||||
host: &str,
|
||||
painter_count: usize,
|
||||
size: (u32, u32),
|
||||
offset: (u32, u32),
|
||||
size: (u16, u16),
|
||||
offset: (u16, u16),
|
||||
binary: bool,
|
||||
) -> Canvas {
|
||||
// Initialize the object
|
||||
@@ -52,10 +52,10 @@ impl Canvas {
|
||||
// Spawn some painters
|
||||
for i in 0..self.painter_count {
|
||||
// Determine the slice width
|
||||
let width = self.size.0 / (self.painter_count as u32);
|
||||
let width = self.size.0 / (self.painter_count as u16);
|
||||
|
||||
// Define the area to paint per thread
|
||||
let painter_area = Rect::from((i as u32) * width, 0, width, self.size.1);
|
||||
let painter_area = Rect::from((i as u16) * width, 0, width, self.size.1);
|
||||
|
||||
// Spawn the painter
|
||||
self.spawn_painter(painter_area, binary);
|
||||
|
||||
@@ -48,7 +48,7 @@ impl Client {
|
||||
}
|
||||
|
||||
/// Write a pixel to the given stream.
|
||||
pub fn write_pixel(&mut self, x: u32, y: u32, color: Color) -> Result<(), Error> {
|
||||
pub fn write_pixel(&mut self, x: u16, y: u16, color: Color) -> Result<(), Error> {
|
||||
if self.binary {
|
||||
self.write_command(
|
||||
&[
|
||||
@@ -74,7 +74,7 @@ impl Client {
|
||||
}
|
||||
|
||||
/// Read the size of the screen.
|
||||
pub fn read_screen_size(&mut self) -> Result<(u32, u32), Error> {
|
||||
pub fn read_screen_size(&mut self) -> Result<(u16, u16), Error> {
|
||||
// Read the screen size
|
||||
let data = self
|
||||
.write_read_command(b"SIZE")
|
||||
@@ -87,10 +87,10 @@ impl Client {
|
||||
match re.captures(&data) {
|
||||
Some(matches) => Ok((
|
||||
matches[1]
|
||||
.parse::<u32>()
|
||||
.parse::<u16>()
|
||||
.expect("Failed to parse screen width, received malformed data"),
|
||||
matches[2]
|
||||
.parse::<u32>()
|
||||
.parse::<u16>()
|
||||
.expect("Failed to parse screen height, received malformed data"),
|
||||
)),
|
||||
None => Err(Error::new(
|
||||
|
||||
Reference in New Issue
Block a user