12#include "roo_io/data/byte_order.h"
54template <
typename Target>
73 template <
typename...
Args>
78 template <
typename...
Args>
107 target_.setAddrWindow(x0, y0, x1, y1);
109 blending_mode_ = mode;
122 processColorSequence(blending_mode_,
color, buffer, 64);
138 while (count-- > 0) {
139 target_.setAddrWindow(*x0, *y0, *x1, *y1);
157 while (count-- > 0) {
158 target_.setAddrWindow(*x0, *y0, *x1, *y1);
171 blending_mode_ = mode;
179 target_.setAddrWindow(x, y, x + count - 1, y);
183 target_.setAddrWindow(x, y, x, y + count - 1);
187 target_.setAddrWindow(x - count + 1, y, x, y);
188 std::reverse(colors + offset, colors + offset + count);
192 target_.setAddrWindow(x, y - count + 1, x, y);
193 std::reverse(colors + offset, colors + offset + count);
214 target_.setAddrWindow(x, y, x + count - 1, y);
218 target_.setAddrWindow(x, y, x, y + count - 1);
222 target_.setAddrWindow(x - count + 1, y, x, y);
226 target_.setAddrWindow(x, y - count + 1, x, y);
263 const size_t width_bytes =
static_cast<size_t>(width) *
kBytesPerPixel;
264 const roo::byte*
row = data +
270 target_.ramWrite(
row,
static_cast<size_t>(width) * height);
274 for (
int16_t y = 0; y < height; ++y) {
307 template <
typename U,
typename =
void>
308 struct has_async_blit : std::false_type {};
310 template <
typename U>
311 struct has_async_blit<
312 U, std::
void_t<decltype(std::declval<U&>().ramWriteAsyncBlit(
313 std::declval<const roo::byte*>(), std::declval<size_t>(),
314 std::declval<size_t>(), std::declval<size_t>()))>>
318 void drawDirectRectAsyncImpl(
const roo::byte* data,
size_t row_width_bytes,
319 int16_t src_x0, int16_t src_y0, int16_t src_x1,
320 int16_t src_y1, int16_t dst_x0, int16_t dst_y0,
322 if (src_x1 < src_x0 || src_y1 < src_y0) {
326 if constexpr (ColorTraits<typename Target::ColorMode>::bytes_per_pixel <
328 drawDirectRect(data, row_width_bytes, src_x0, src_y0, src_x1, src_y1,
333 int16_t width = src_x1 - src_x0 + 1;
334 int16_t height = src_y1 - src_y0 + 1;
335 target_.setAddrWindow(dst_x0, dst_y0, dst_x0 + width - 1,
336 dst_y0 + height - 1);
339 const size_t width_bytes =
static_cast<size_t>(width) *
kBytesPerPixel;
340 const roo::byte* row = data +
341 static_cast<size_t>(src_y0) * row_width_bytes +
343 target_.ramWriteAsyncBlit(row, row_width_bytes, width_bytes,
344 static_cast<size_t>(height));
348 void drawDirectRectAsyncImpl(
const roo::byte* data,
size_t row_width_bytes,
349 int16_t src_x0, int16_t src_y0, int16_t src_x1,
350 int16_t src_y1, int16_t dst_x0, int16_t dst_y0,
352 drawDirectRect(data, row_width_bytes, src_x0, src_y0, src_x1, src_y1,
357 __attribute__((always_inline)) {
359 ColorIo<typename Target::ColorMode, Target::byte_order> io;
364 roo::byte* dest, uint32_t pixel_count)
365 __attribute__((always_inline)) {
367 ColorIo<typename Target::ColorMode, Target::byte_order> io;
368 while (pixel_count-- > 0) {
369 io.store(*src++, dest);
375 uint16_t last_x0_, last_x1_, last_y0_, last_y1_;
378 Compactor compactor_;
const ColorMode & color_mode() const
void flush() override
Wait until pending asynchronous drawing operations complete.
void writePixels(BlendingMode mode, Color *colors, int16_t *xs, int16_t *ys, uint16_t pixel_count) override
Draw the specified pixels (per-pixel colors). Invalidates the address window.
typename Target::ColorMode ColorMode
void end() override
Finalize the previously entered write transaction, flushing any pending writes.
~AddrWindowDevice() override
void fill(Color color, uint32_t pixel_count) override
Write pixel_count copies of the same color into the current address window.
void init() override
Initialize the display driver.
void writeRects(BlendingMode blending_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 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.
AddrWindowDevice(Orientation orientation, Target target)
AddrWindowDevice(Args &&... args)
void orientationUpdated() override
Invoked when orientation() is updated.
void write(Color *color, uint32_t pixel_count) override
Write pixels into the current address window.
void fillPixels(BlendingMode blending_mode, Color color, int16_t *xs, int16_t *ys, uint16_t pixel_count) override
Draw the specified pixels using the same color. Invalidates the address window.
AddrWindowDevice(uint16_t width, uint16_t height)
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 ByteOrder byte_order
AddrWindowDevice(Orientation orientation, Args &&... args)
void setBgColorHint(Color bgcolor) override
Provide a background color hint for source-over blending.
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) override
Asynchronous variant of drawDirectRect().
void fillRects(BlendingMode blending_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.
AddrWindowDevice(Orientation orientation, uint16_t width, uint16_t height)
static constexpr int kBytesPerPixel
static constexpr ColorPixelOrder pixel_order
roo::byte[kBytesPerPixel] raw_color_type
AddrWindowDevice(Target target)
const ColorFormat & getColorFormat() const override
Return the native color format used by this device for direct drawing.
ARGB8888 color stored as a 32-bit unsigned integer.
void drawPixels(int16_t *xs, int16_t *ys, uint16_t pixel_count, Writer write=Writer())
Base class for display device drivers.
Orientation orientation() const
Return the current orientation of the display.
virtual 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)
Draw a rectangle represented in the device's native color format.
Represents the orientation of a display device.
Defines 140 opaque HTML named colors.
void ApplyBlendingOverBackground(BlendingMode mode, Color bg, Color *src, int16_t count)
BlendingMode
Porter-Duff style blending modes.
Color ApplyBlending(BlendingMode mode, Color dst, Color src)
roo_io::ByteOrder ByteOrder
BlendingMode blending_mode
Traits for a color mode's storage characteristics.