roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
roo_display::BackgroundFillOptimizerDevice Class Reference

Display device wrapper that applies background fill optimization. More...

#include <background_fill_optimizer.h>

Inheritance diagram for roo_display::BackgroundFillOptimizerDevice:
[legend]
Collaboration diagram for roo_display::BackgroundFillOptimizerDevice:
[legend]

Public Member Functions

 BackgroundFillOptimizerDevice (DisplayDevice &device)
 Create a wrapper device.
 
void setPalette (const Color *palette, uint8_t palette_size, Color prefilled=color::Transparent)
 Set the palette and optional prefilled color.
 
void setPalette (std::initializer_list< Color > palette, Color prefilled=color::Transparent)
 Set palette using an initializer list.
 
void init () override
 Initialize the display driver.
 
void orientationUpdated () override
 Invoked when orientation() is updated.
 
virtual void setBgColorHint (Color bgcolor)
 Provide a background color hint for source-over blending.
 
void begin () override
 Enter a write transaction.
 
void end () override
 Finalize the previously entered write transaction, flushing any pending writes.
 
void setAddress (uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, BlendingMode mode) override
 Set a rectangular window filled by subsequent calls to write().
 
void write (Color *color, uint32_t pixel_count) override
 Write pixels into the current address window.
 
void fill (Color color, uint32_t pixel_count) override
 Write pixel_count copies of the same color into the current address window.
 
void writeRects (BlendingMode mode, Color *color, int16_t *x0, int16_t *y0, int16_t *x1, int16_t *y1, uint16_t count) override
 Draw the specified rectangles (per-rectangle colors). Invalidates the address window.
 
void fillRects (BlendingMode mode, Color color, int16_t *x0, int16_t *y0, int16_t *x1, int16_t *y1, uint16_t count) override
 Draw the specified rectangles using the same color. Invalidates the address window.
 
void writePixels (BlendingMode mode, Color *color, int16_t *x, int16_t *y, uint16_t pixel_count) override
 Draw the specified pixels (per-pixel colors). Invalidates the address window.
 
void fillPixels (BlendingMode mode, Color color, int16_t *x, int16_t *y, uint16_t pixel_count) override
 Draw the specified pixels using the same color. Invalidates the address window.
 
void drawDirectRect (const roo::byte *data, size_t row_width_bytes, int16_t src_x0, int16_t src_y0, int16_t src_x1, int16_t src_y1, int16_t dst_x0, int16_t dst_y0) override
 Draw a rectangle represented in the device's native color format.
 
const ColorFormatgetColorFormat () const override
 Return the native color format used by this device for direct drawing.
 
const BackgroundFillOptimizer::FrameBufferbuffer () const
 Accessor for testing: retrieve the internal frame buffer.
 
- Public Member Functions inherited from roo_display::DisplayDevice
virtual ~DisplayDevice ()
 
void setOrientation (Orientation orientation)
 Set the orientation of the display.
 
Orientation orientation () const
 Return the current orientation of the display.
 
int16_t raw_width () const
 Return the width of the display in its native orientation.
 
int16_t raw_height () const
 Return the height of the display in its native orientation.
 
int16_t effective_width () const
 Return the display width in the current orientation.
 
int16_t effective_height () const
 Return the display height in the current orientation.
 
- Public Member Functions inherited from roo_display::DisplayOutput
virtual ~DisplayOutput ()
 
virtual void flush ()
 Wait until pending asynchronous drawing operations complete.
 
void setAddress (const Box &bounds, BlendingMode blending_mode)
 Convenience overload for setAddress() using a Box.
 
void fillRect (BlendingMode blending_mode, const Box &rect, Color color)
 Fill a single rectangle. Invalidates the address window.
 
void fillRect (BlendingMode blending_mode, int16_t x0, int16_t y0, int16_t x1, int16_t y1, Color color)
 Fill a single rectangle. Invalidates the address window.
 
void fillRect (int16_t x0, int16_t y0, int16_t x1, int16_t y1, Color color)
 Fill a single rectangle using BlendingMode::kSource.
 
virtual void drawDirectRectAsync (const roo::byte *data, size_t row_width_bytes, int16_t src_x0, int16_t src_y0, int16_t src_x1, int16_t src_y1, int16_t dst_x0, int16_t dst_y0)
 Asynchronous variant of drawDirectRect().
 

Additional Inherited Members

- Protected Member Functions inherited from roo_display::DisplayDevice
 DisplayDevice (int16_t raw_width, int16_t raw_height)
 
 DisplayDevice (Orientation orientation, int16_t raw_width, int16_t raw_height)
 

Detailed Description

Display device wrapper that applies background fill optimization.

Definition at line 231 of file background_fill_optimizer.h.

Constructor & Destructor Documentation

◆ BackgroundFillOptimizerDevice()

roo_display::BackgroundFillOptimizerDevice::BackgroundFillOptimizerDevice ( DisplayDevice device)

Member Function Documentation

◆ begin()

void roo_display::BackgroundFillOptimizerDevice::begin ( )
inlineoverridevirtual

Enter a write transaction.

Normally called by the DrawingContext constructor, and does not need to be called explicitly.

Reimplemented from roo_display::DisplayOutput.

Definition at line 258 of file background_fill_optimizer.h.

References roo_display::DisplayOutput::begin().

◆ buffer()

const BackgroundFillOptimizer::FrameBuffer & roo_display::BackgroundFillOptimizerDevice::buffer ( ) const
inline

Accessor for testing: retrieve the internal frame buffer.

Definition at line 307 of file background_fill_optimizer.h.

◆ drawDirectRect()

void roo_display::BackgroundFillOptimizerDevice::drawDirectRect ( const roo::byte *  data,
size_t  row_width_bytes,
int16_t  src_x0,
int16_t  src_y0,
int16_t  src_x1,
int16_t  src_y1,
int16_t  dst_x0,
int16_t  dst_y0 
)
inlineoverridevirtual

Draw a rectangle represented in the device's native color format.

Source data pointer correspond to the (0, 0) point in the source coordinate system, with stride of row_width_bytes. The source rectangle at (src_x0, src_y0, src_x1, src_y1) relative to the data pointer, gets copied to the destination rectangle with top-left corner at (dst_x0, dst_y0). The caller must ensure that the destination rectangle fits within the device's bounds.

The default implementation processes the rectangle by small tiles, converting the data to an array of regular colors, and calling regular window functions to draw them. Specific devices can override this method to provide a more efficient implementation that draws directly from the source data.

Reimplemented from roo_display::DisplayOutput.

Definition at line 295 of file background_fill_optimizer.h.

References roo_display::BackgroundFillOptimizer::drawDirectRect().

◆ end()

void roo_display::BackgroundFillOptimizerDevice::end ( )
inlineoverridevirtual

Finalize the previously entered write transaction, flushing any pending writes.

Normally called by the DrawingContext destructor, and does not need to be called explicitly.

Reimplemented from roo_display::DisplayOutput.

Definition at line 260 of file background_fill_optimizer.h.

References roo_display::DisplayOutput::end().

◆ fill()

void roo_display::BackgroundFillOptimizerDevice::fill ( Color  color,
uint32_t  pixel_count 
)
inlineoverridevirtual

Write pixel_count copies of the same color into the current address window.

The same preconditions as write() apply: the address must be set via setAddress() and not invalidated by any of the write* / fill* methods. Otherwise, the behavior is undefined.

Default implementation falls back to chunked write(). Drivers and filters can override this for a more efficient single-color path.

Reimplemented from roo_display::DisplayOutput.

Definition at line 271 of file background_fill_optimizer.h.

References color, and roo_display::BackgroundFillOptimizer::fill().

◆ fillPixels()

void roo_display::BackgroundFillOptimizerDevice::fillPixels ( BlendingMode  blending_mode,
Color  color,
int16_t x,
int16_t y,
uint16_t  pixel_count 
)
inlineoverridevirtual

Draw the specified pixels using the same color. Invalidates the address window.

Parameters
blending_modeBlending mode used for drawing.
colorThe color to use for all pixels.
xPointer to x-coordinates for each pixel.
yPointer to y-coordinates for each pixel.
pixel_countNumber of pixels.

Implements roo_display::DisplayOutput.

Definition at line 290 of file background_fill_optimizer.h.

References color, and roo_display::BackgroundFillOptimizer::fillPixels().

◆ fillRects()

void roo_display::BackgroundFillOptimizerDevice::fillRects ( BlendingMode  blending_mode,
Color  color,
int16_t x0,
int16_t y0,
int16_t x1,
int16_t y1,
uint16_t  count 
)
inlineoverridevirtual

Draw the specified rectangles using the same color. Invalidates the address window.

Parameters
blending_modeBlending mode used for drawing.
colorThe color to use for all rectangles.
x0Pointer to left coordinates for each rectangle.
y0Pointer to top coordinates for each rectangle.
x1Pointer to right coordinates for each rectangle.
y1Pointer to bottom coordinates for each rectangle.
countNumber of rectangles.

Implements roo_display::DisplayOutput.

Definition at line 280 of file background_fill_optimizer.h.

References color, and roo_display::BackgroundFillOptimizer::fillRects().

◆ getColorFormat()

const ColorFormat & roo_display::BackgroundFillOptimizerDevice::getColorFormat ( ) const
inlineoverridevirtual

Return the native color format used by this device for direct drawing.

Implements roo_display::DisplayOutput.

Definition at line 302 of file background_fill_optimizer.h.

References roo_display::DisplayOutput::getColorFormat().

◆ init()

void roo_display::BackgroundFillOptimizerDevice::init ( )
inlineoverridevirtual

Initialize the display driver.

Must be called once before any DisplayOutput methods are used. Can be called later to re-initialize the display to default settings. Must be called outside a transaction.

Reimplemented from roo_display::DisplayDevice.

Definition at line 244 of file background_fill_optimizer.h.

References roo_display::DisplayDevice::init().

◆ orientationUpdated()

void roo_display::BackgroundFillOptimizerDevice::orientationUpdated ( )
inlineoverridevirtual

Invoked when orientation() is updated.

Devices that support orientation change should override this method.

Reimplemented from roo_display::DisplayDevice.

Definition at line 246 of file background_fill_optimizer.h.

References roo_display::DisplayDevice::orientation(), roo_display::DisplayDevice::orientationUpdated(), and roo_display::BackgroundFillOptimizer::FrameBuffer::setSwapXY().

◆ setAddress()

void roo_display::BackgroundFillOptimizerDevice::setAddress ( uint16_t  x0,
uint16_t  y0,
uint16_t  x1,
uint16_t  y1,
BlendingMode  blending_mode 
)
inlineoverridevirtual

Set a rectangular window filled by subsequent calls to write().

Parameters
x0Left coordinate (inclusive).
y0Top coordinate (inclusive).
x1Right coordinate (inclusive).
y1Bottom coordinate (inclusive).
blending_modeBlending mode for subsequent writes.

Implements roo_display::DisplayOutput.

Definition at line 262 of file background_fill_optimizer.h.

References roo_display::BackgroundFillOptimizer::setAddress().

◆ setBgColorHint()

virtual void roo_display::BackgroundFillOptimizerDevice::setBgColorHint ( Color  bgcolor)
inlinevirtual

Provide a background color hint for source-over blending.

Devices that support BlendingMode::kSourceOver should ignore this hint. Devices that do not support alpha blending (e.g. hardware can't read the framebuffer) should use this color as the assumed background for writes using BlendingMode::kSourceOver.

Reimplemented from roo_display::DisplayDevice.

Definition at line 254 of file background_fill_optimizer.h.

References bgcolor, and roo_display::DisplayDevice::setBgColorHint().

◆ setPalette() [1/2]

void roo_display::BackgroundFillOptimizerDevice::setPalette ( const Color palette,
uint8_t  palette_size,
Color  prefilled = color::Transparent 
)

Set the palette and optional prefilled color.

Definition at line 970 of file background_fill_optimizer.cpp.

References palette, and roo_display::BackgroundFillOptimizer::setPalette().

Referenced by setPalette().

◆ setPalette() [2/2]

void roo_display::BackgroundFillOptimizerDevice::setPalette ( std::initializer_list< Color palette,
Color  prefilled = color::Transparent 
)

Set palette using an initializer list.

Definition at line 977 of file background_fill_optimizer.cpp.

References palette, and setPalette().

◆ write()

void roo_display::BackgroundFillOptimizerDevice::write ( Color color,
uint32_t  pixel_count 
)
inlineoverridevirtual

Write pixels into the current address window.

The address must be set via setAddress() and not invalidated by any of the write* / fill* methods. Otherwise, the behavior is undefined.

Parameters
colorPointer to source pixels.
pixel_countNumber of pixels to write.

Implements roo_display::DisplayOutput.

Definition at line 267 of file background_fill_optimizer.h.

References color, and roo_display::BackgroundFillOptimizer::write().

◆ writePixels()

void roo_display::BackgroundFillOptimizerDevice::writePixels ( BlendingMode  blending_mode,
Color color,
int16_t x,
int16_t y,
uint16_t  pixel_count 
)
inlineoverridevirtual

Draw the specified pixels (per-pixel colors). Invalidates the address window.

Parameters
blending_modeBlending mode used for drawing.
colorPointer to colors for each pixel.
xPointer to x-coordinates for each pixel.
yPointer to y-coordinates for each pixel.
pixel_countNumber of pixels.

Implements roo_display::DisplayOutput.

Definition at line 285 of file background_fill_optimizer.h.

References color, and roo_display::BackgroundFillOptimizer::writePixels().

◆ writeRects()

void roo_display::BackgroundFillOptimizerDevice::writeRects ( BlendingMode  blending_mode,
Color color,
int16_t x0,
int16_t y0,
int16_t x1,
int16_t y1,
uint16_t  count 
)
inlineoverridevirtual

Draw the specified rectangles (per-rectangle colors). Invalidates the address window.

Parameters
blending_modeBlending mode used for drawing.
colorPointer to colors for each rectangle.
x0Pointer to left coordinates for each rectangle.
y0Pointer to top coordinates for each rectangle.
x1Pointer to right coordinates for each rectangle.
y1Pointer to bottom coordinates for each rectangle.
countNumber of rectangles.

Implements roo_display::DisplayOutput.

Definition at line 275 of file background_fill_optimizer.h.

References color, and roo_display::BackgroundFillOptimizer::writeRects().


The documentation for this class was generated from the following files: