3#include "roo_backport.h"
4#include "roo_backport/byte.h"
53 static constexpr const int kBlock = 4;
70 return ((((w - 1) /
kBlock + 1) + 1) / 2) *
71 ((((h - 1) /
kBlock + 1) + 1) / 2) * 2;
108 std::unique_ptr<roo::byte[]> owned_buffer_;
156 void resetPendingDynamicPaletteColor();
169 void recountMaskUsage();
171 bool isReclaimablePaletteIdx(
uint8_t idx)
const;
177 uint32_t pixelsUntilStripeEnd()
const;
179 void beginPassthroughIfNeeded();
185 void flushDeferredUniformRun();
197 template <
typename Filler>
210 bool address_window_block_haligned_;
217 bool palette_full_hint_;
218 bool has_pending_dynamic_palette_color_;
219 Color pending_dynamic_palette_color_;
221 enum class WriteScanState { kScan, kPassthrough };
222 WriteScanState write_scan_state_;
223 bool passthrough_address_set_;
224 bool scan_uniform_active_;
225 Color scan_uniform_color_;
238 Color prefilled = color::Transparent);
242 Color prefilled = color::Transparent);
251 optimizer_.recountMaskUsage();
Display device wrapper that applies background fill optimization.
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.
void begin() override
Enter a write transaction.
const ColorFormat & getColorFormat() const override
Return the native color format used by this device for direct drawing.
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 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 setPalette(const Color *palette, uint8_t palette_size, Color prefilled=color::Transparent)
Set the palette and optional prefilled color.
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.
const BackgroundFillOptimizer::FrameBuffer & buffer() const
Accessor for testing: retrieve the internal frame buffer.
void end() override
Finalize the previously entered write transaction, flushing any pending writes.
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 orientationUpdated() override
Invoked when orientation() is updated.
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.
virtual void setBgColorHint(Color bgcolor)
Provide a background color hint for source-over blending.
void init() override
Initialize the display driver.
void fill(Color color, uint32_t pixel_count) override
Write pixel_count copies of the same color into the current address window.
Backing buffer for the optimizer state.
void invalidate()
Clear the entire background mask.
static constexpr size_t SizeForDimensions(int16_t w, int16_t h)
Return buffer size in bytes for a given device size.
void setSwapXY(bool swap)
Set whether the underlying display swaps x/y.
const internal::NibbleRect & mask() const
Accessor for testing: retrieve the internal nibble mask.
void invalidateRect(const Box &rect)
Clear the mask for the area covering rect.
Display output filter that avoids redundant background fills.
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().
static constexpr const int kDynamicPaletteMinWidth
Minimum rectangle width for dynamic palette enrollment.
void write(Color *color, uint32_t pixel_count) override
Write pixels into the current 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.
static constexpr const int kBlock
Size of the coarse background grid in pixels.
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 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 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 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.
virtual ~BackgroundFillOptimizer()
static constexpr const int kDynamicPaletteMinHeight
Minimum rectangle height for dynamic palette enrollment.
void fill(Color color, uint32_t pixel_count) override
Write pixel_count copies of the same color into the current address window.
const ColorFormat & getColorFormat() const override
Return the native color format used by this device for direct drawing.
void setPalette(const Color *palette, uint8_t palette_size)
Axis-aligned integer rectangle.
ARGB8888 color stored as a 32-bit unsigned integer.
Base class for display device drivers.
virtual void init()
Initialize the display driver.
Orientation orientation() const
Return the current orientation of the display.
virtual void orientationUpdated()
Invoked when orientation() is updated.
virtual void setBgColorHint(Color bgcolor)
Provide a background color hint for source-over blending.
The abstraction for drawing to a display.
virtual void end()
Finalize the previously entered write transaction, flushing any pending writes.
virtual const ColorFormat & getColorFormat() const =0
Return the native color format used by this device for direct drawing.
virtual void begin()
Enter a write transaction.
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.