Skip to content

feat(framebuffer): Export framebuffer, to be consumed by external crates#105

Merged
j-g00da merged 1 commit intoratatui:mainfrom
deadbaed:expose-framebuffer
Jul 4, 2025
Merged

feat(framebuffer): Export framebuffer, to be consumed by external crates#105
j-g00da merged 1 commit intoratatui:mainfrom
deadbaed:expose-framebuffer

Conversation

@deadbaed
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Member

@j-g00da j-g00da left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, added some docs suggestions

Comment on lines +1 to +8
//! # Framebuffer
//!
//!
//! A framebuffer can be used to contain new pixels of a new frame before being displayed.
//!
//! Some display driver write pixels directly on the display, which can cause some screen tearing.
//!
//! Mousefood can provide a framebuffer ready to be used.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! # Framebuffer
//!
//!
//! A framebuffer can be used to contain new pixels of a new frame before being displayed.
//!
//! Some display driver write pixels directly on the display, which can cause some screen tearing.
//!
//! Mousefood can provide a framebuffer ready to be used.
//! # Framebuffer
//!
//! A framebuffer implementation for storing pixels in memory before rendering to a display.
//!
//! This module provides [`HeapBuffer`], a heap-allocated framebuffer that can be used
//! with display drivers that don't provide their own internal framebuffer. This helps
//! prevent screen tearing by allowing you to compose a complete frame in memory before
//! sending it to the display.

Comment on lines +20 to +22
/// Framebuffer holding pixels, waiting to be drawn to the real display.
///
/// Created to be used in mousefood with a display driver not providing an internal framebuffer.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Framebuffer holding pixels, waiting to be drawn to the real display.
///
/// Created to be used in mousefood with a display driver not providing an internal framebuffer.
/// A heap-allocated framebuffer for storing pixels before rendering to a display.
///
/// `HeapBuffer` provides a memory-based framebuffer that can be used with display drivers
/// that don't have their own internal framebuffer. This helps prevent screen tearing by
/// allowing you to compose a complete frame in memory before sending it to the display.
///
/// The framebuffer is generic over any pixel color type that implements [`PixelColor`]
/// and [`Copy`]. It stores pixels in a contiguous `Vec<C>` arranged in row-major order.
///
/// # Type Parameters
///
/// * `C` - The pixel color type. Must implement [`PixelColor`] and [`Copy`].

Comment on lines +29 to +33
/// Create a new framebuffer with defined dimensions
///
/// # Arguments
///
/// * `bounding_box` - The dimensions of the framebuffer
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Create a new framebuffer with defined dimensions
///
/// # Arguments
///
/// * `bounding_box` - The dimensions of the framebuffer
/// Creates a new framebuffer with the specified dimensions.
///
/// The framebuffer is initialized with a background color derived from [`Color::Reset`].
///
/// # Arguments
///
/// * `bounding_box` - A [`Rectangle`] defining the position and size of the framebuffer.
/// The framebuffer will have `width × height` pixels, where width and height
/// are taken from the rectangle's size.
///
/// # Returns
///
/// A new [`HeapBuffer`] instance with the specified dimensions, initialized with
/// the default background color.
///
/// # Memory Usage
///
/// This method allocates `width × height × sizeof(C)` bytes of memory on the heap,
/// where `C` is the pixel color type.

@j-g00da
Copy link
Copy Markdown
Member

j-g00da commented Jul 3, 2025

(I know these are more detailed than most docs in the project. I want to rewrite all docs before v0.3 release.)

@deadbaed deadbaed force-pushed the expose-framebuffer branch from ea3b932 to 86304f7 Compare July 4, 2025 06:56
@deadbaed
Copy link
Copy Markdown
Contributor Author

deadbaed commented Jul 4, 2025

It's all good! Thanks for the better docs!

@j-g00da j-g00da merged commit 4c85ac5 into ratatui:main Jul 4, 2025
24 checks passed
@github-actions github-actions bot mentioned this pull request Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants