pub struct Locked<'a, B: Buffer> { /* private fields */ }
Expand description
A GPU component on which methods can be invoked.
This type combines a GPU address, an Invoker
that can be used to make method calls, and a
scratch buffer used to perform CBOR encoding and decoding. A value of this type can be created
by calling Gpu::lock
, and it can be dropped to return the borrow of the invoker and buffer
to the caller so they can be reused for other purposes.
The 'a
lifetime is the lifetime of the invoker and the buffer. The B
type is the type of
scratch buffer to use.
Implementations§
Source§impl<'a, B: Buffer> Locked<'a, B>
impl<'a, B: Buffer> Locked<'a, B>
Sourcepub async fn bind(&mut self, screen: Address, reset: bool) -> Result<(), Error>
pub async fn bind(&mut self, screen: Address, reset: bool) -> Result<(), Error>
Binds the GPU to a screen.
If reset
is true
, then the screen is reset to its maximum resolution and colour depth,
and its colours are set to white on black. The text content, however, is not cleared.
§Errors
Sourcepub async fn get_screen(&mut self) -> Result<Option<Address>, Error>
pub async fn get_screen(&mut self) -> Result<Option<Address>, Error>
Returns the address of the screen the GPU is bound to, or None
if it is unbound.
§Errors
Sourcepub async fn get_background(&mut self) -> Result<Colour, Error>
pub async fn get_background(&mut self) -> Result<Colour, Error>
Sourcepub async fn set_background(
&mut self,
colour: Colour,
) -> Result<(Rgb, Option<PaletteIndex>), Error>
pub async fn set_background( &mut self, colour: Colour, ) -> Result<(Rgb, Option<PaletteIndex>), Error>
Sets the background colour, returning the old colour.
§Errors
Sourcepub async fn get_foreground(&mut self) -> Result<Colour, Error>
pub async fn get_foreground(&mut self) -> Result<Colour, Error>
Sourcepub async fn set_foreground(
&mut self,
colour: Colour,
) -> Result<(Rgb, Option<PaletteIndex>), Error>
pub async fn set_foreground( &mut self, colour: Colour, ) -> Result<(Rgb, Option<PaletteIndex>), Error>
Sets the foreground colour, returning the old colour.
§Errors
Sourcepub async fn get_palette_colour(
&mut self,
index: PaletteIndex,
) -> Result<Rgb, Error>
pub async fn get_palette_colour( &mut self, index: PaletteIndex, ) -> Result<Rgb, Error>
Returns the colour at a palette index.
§Errors
Sourcepub async fn set_palette_colour(
&mut self,
index: PaletteIndex,
colour: Rgb,
) -> Result<Rgb, Error>
pub async fn set_palette_colour( &mut self, index: PaletteIndex, colour: Rgb, ) -> Result<Rgb, Error>
Sets the colour at a palette index, returning the old colour.
§Errors
Sourcepub async fn max_depth(&mut self) -> Result<u8, Error>
pub async fn max_depth(&mut self) -> Result<u8, Error>
Returns the maximum supported colour depth based on the tiers of the GPU and the bound screen.
§Errors
Sourcepub async fn max_resolution(&mut self) -> Result<Dimension, Error>
pub async fn max_resolution(&mut self) -> Result<Dimension, Error>
Returns the maximum supported resolution based on the tiers of the GPU and the bound screen.
§Errors
Sourcepub async fn get_resolution(&mut self) -> Result<Dimension, Error>
pub async fn get_resolution(&mut self) -> Result<Dimension, Error>
Sourcepub async fn set_resolution(
&mut self,
resolution: Dimension,
) -> Result<bool, Error>
pub async fn set_resolution( &mut self, resolution: Dimension, ) -> Result<bool, Error>
Sets the screen resolution, returning whether or not it was changed from its previous value.
§Errors
Sourcepub async fn get_viewport(&mut self) -> Result<Dimension, Error>
pub async fn get_viewport(&mut self) -> Result<Dimension, Error>
Sourcepub async fn set_viewport(
&mut self,
resolution: Dimension,
) -> Result<bool, Error>
pub async fn set_viewport( &mut self, resolution: Dimension, ) -> Result<bool, Error>
Sets the viewport, returning whether or not it was changed from its previous value.
§Errors
Sourcepub async fn get(
&mut self,
point: Point,
) -> Result<CharacterCellContents, Error>
pub async fn get( &mut self, point: Point, ) -> Result<CharacterCellContents, Error>
Returns the character and colours at a specific character cell.
It is possible for a Java string to contain an unpaired UTF-16 surrogate half. It is possible (in Lua, at least) to place such a byte sequence into a character cell in a screen. Should this method be called on such a character cell, a replacement character is silently returned instead.
§Errors
Sourcepub async fn set(
&mut self,
position: Point,
text: &str,
direction: TextDirection,
) -> Result<(), Error>
pub async fn set( &mut self, position: Point, text: &str, direction: TextDirection, ) -> Result<(), Error>
Sourcepub async fn copy(
&mut self,
source: Point,
dimension: Dimension,
translation: Vector2,
) -> Result<(), Error>
pub async fn copy( &mut self, source: Point, dimension: Dimension, translation: Vector2, ) -> Result<(), Error>
Copies data from one rectangle to another.