Crate piet_hardware

Source
Expand description

An adaptor for piet that allows it to take advantage of GPU acceleration.

This crate provides common types, traits and functionality that should be useful for implementations of the piet drawing framework for hardware-accelerated backends like OpenGL, Vulkan and WGPU. It handles things like rasterization, atlas packing and memory management, while leaving the actual implementation of the GPU commands to the backend.

To use, first implement the GpuContext trait on a type of your choice that represents an active GPU context. Wrap this type in the Source type, and then use that to create a RenderContext. From here, you can pass that type to your rendering code. It conforms to the piet API, so you can use it as a drop-in replacement for any piet backend, including [piet-common].

Note that this crate generally uses thread-unsafe primitives. This is because UI management is usually pinned to one thread anyways, and it’s a bad idea to do drawing outside of that thread.

§Implementation

This crate works first and foremost by converting drawing operations to a series of triangles.

Re-exports§

pub use piet;

Modules§

gpu_types
Structures that are useful for implementing the GpuContext type.

Structs§

Brush
The brush type used by the GPU renderer.
Image
The image type used by the GPU renderer.
RenderContext
The whole point of this crate.
Source
The source of the GPU renderer.
Text
The text layout engine for the GPU renderer.
TextLayout
The text layout for the GPU renderer.
TextLayoutBuilder
The text layout builder for the GPU renderer.
Vertex
The vertex type used by the GPU renderer.

Enums§

BufferType
The type of the buffer to use.
RepeatStrategy
The strategy to use for repeating.

Traits§

GpuContext
The backend for the GPU renderer.