21#ifndef ROO_DISPLAY_TESTING
38 : device_(device), blending_mode_(
blending_mode), buffer_size_(0) {}
49 if (
color.asArgb() == 0 &&
53 x_buffer_[buffer_size_] = x;
54 y_buffer_[buffer_size_] = y;
55 color_buffer_[buffer_size_] =
color;
63 if (buffer_size_ == 0)
return;
64 device_.
writePixels(blending_mode_, color_buffer_, x_buffer_, y_buffer_,
78template <
typename PixelWriter>
138 x_buffer_[buffer_size_] = x;
139 y_buffer_[buffer_size_] = y;
147 if (buffer_size_ == 0)
return;
148 device_.
fillPixels(blending_mode_, color_, x_buffer_, y_buffer_,
192 : device_(device), buffer_size_(0) {}
196 color_buffer_[buffer_size_] =
color;
206 buffer_size_ += count;
215 buffer_size_ = count;
228 memcpy(color_buffer_ + buffer_size_, colors, count *
sizeof(
Color));
229 buffer_size_ += count;
232 if (buffer_size_ != 0) {
240 memcpy(color_buffer_, colors, count *
sizeof(
Color));
241 buffer_size_ = count;
261 buffer_size_ += count;
263 device_.
write(color_buffer_, buffer_size_);
273 memcpy(color_buffer_ + buffer_size_, colors, count *
sizeof(
Color));
274 buffer_size_ += count;
277 if (buffer_size_ != 0) {
291 if (buffer_size_ == 0)
return;
292 device_.
write(color_buffer_, buffer_size_);
296 DisplayOutput& device_;
298 int16_t buffer_size_;
312 x0_buffer_[buffer_size_] = x0;
313 y0_buffer_[buffer_size_] = y0;
314 x1_buffer_[buffer_size_] = x1;
321 if (buffer_size_ == 0)
return;
322 device_.
fillRects(blending_mode_, color_, x0_buffer_, y0_buffer_,
323 x1_buffer_, y0_buffer_, buffer_size_);
344 if (x0 > clip_box_.
xMax() || x1 < clip_box_.
xMin() ||
345 y0 > clip_box_.
yMax() || y0 < clip_box_.
yMin() || x1 < x0) {
349 if (x0 < clip_box_.
xMin()) x0 = clip_box_.
xMin();
350 if (x1 > clip_box_.
xMax()) x1 = clip_box_.
xMax();
376 x0_buffer_[buffer_size_] = x0;
377 y0_buffer_[buffer_size_] = y0;
378 y1_buffer_[buffer_size_] = y1;
385 if (buffer_size_ == 0)
return;
386 device_.
fillRects(blending_mode_, color_, x0_buffer_, y0_buffer_,
387 x0_buffer_, y1_buffer_, buffer_size_);
408 if (x0 > clip_box_.
xMax() || x0 < clip_box_.
xMin() ||
409 y0 > clip_box_.
yMax() || y1 < clip_box_.
yMin() || y1 < y0) {
413 if (y0 < clip_box_.
yMin()) y0 = clip_box_.
yMin();
414 if (y1 > clip_box_.
yMax()) y1 = clip_box_.
yMax();
432 : device_(device), blending_mode_(
blending_mode), buffer_size_(0) {}
448 color_[buffer_size_] =
color;
449 x0_buffer_[buffer_size_] = x0;
450 y0_buffer_[buffer_size_] = y0;
451 x1_buffer_[buffer_size_] = x1;
452 y1_buffer_[buffer_size_] = y1;
459 if (buffer_size_ == 0)
return;
460 device_.
writeRects(blending_mode_, color_, x0_buffer_, y0_buffer_,
461 x1_buffer_, y1_buffer_, buffer_size_);
476template <
typename RectWriter>
483 writer_.writePixel(x, y, color_);
487 writer_.fillHLine(x0, y0, x1, color_);
491 writer_.fillVLine(x0, y0, y1, color_);
495 writer_.writeRect(x0, y0, x1, y1, color_);
522 if (x0 > clip_box_.
xMax() || x1 < clip_box_.
xMin() ||
523 y0 > clip_box_.
yMax() || y1 < clip_box_.
yMin() || y1 < y0 || x1 < x0) {
527 if (x0 < clip_box_.
xMin()) x0 = clip_box_.
xMin();
528 if (x1 > clip_box_.
xMax()) x1 = clip_box_.
xMax();
529 if (y0 < clip_box_.
yMin()) y0 = clip_box_.
yMin();
530 if (y1 > clip_box_.
yMax()) y1 = clip_box_.
yMax();
567 x0_buffer_[buffer_size_] = x0;
568 y0_buffer_[buffer_size_] = y0;
569 x1_buffer_[buffer_size_] = x1;
570 y1_buffer_[buffer_size_] = y1;
577 if (buffer_size_ == 0)
return;
578 device_.
fillRects(blending_mode_, color_, x0_buffer_, y0_buffer_,
579 x1_buffer_, y1_buffer_, buffer_size_);
611 if (x0 > clip_box_.
xMax() || x1 < clip_box_.
xMin() ||
612 y0 > clip_box_.
yMax() || y1 < clip_box_.
yMin() || y1 < y0 || x1 < x0) {
616 if (x0 < clip_box_.
xMin()) x0 = clip_box_.
xMin();
617 if (x1 > clip_box_.
xMax()) x1 = clip_box_.
xMax();
618 if (y0 < clip_box_.
yMin()) y0 = clip_box_.
yMin();
619 if (y1 > clip_box_.
yMax()) y1 = clip_box_.
yMax();
BufferedRectWriter & writer
Axis-aligned integer rectangle.
int16_t xMin() const
Minimum x (inclusive).
int16_t xMax() const
Maximum x (inclusive).
bool contains(int16_t x, int16_t y) const
Return whether the point (x, y) lies within the box.
int16_t yMax() const
Maximum y (inclusive).
int16_t yMin() const
Minimum y (inclusive).
Buffered writer for sequential color values (used with setAddress()).
uint16_t writeColorsAligned(Color *colors, uint16_t count)
Write up to the remaining buffer space and return count written.
void writeColor(Color color)
Write a single color value.
void writeColors(Color *colors, uint16_t count)
Write count pixels with distinct colors.
BufferedColorWriter(DisplayOutput &device)
void writeColorN(Color color, uint16_t count)
Write count pixels with the same color.
uint16_t remaining_buffer_space() const
Return remaining buffer capacity before a flush is needed.
void advance_buffer_ptr(uint16_t count)
Advance the buffer after direct writes via buffer_ptr().
Color * buffer_ptr()
Return raw access to the buffer at the current write position.
void fillHLine(int16_t x0, int16_t y0, int16_t x1)
BufferedHLineFiller(DisplayOutput &device, Color color, BlendingMode blending_mode)
Buffered filler for arbitrary pixels using a single color.
void flush()
Flush any buffered pixels.
BufferedPixelFiller(DisplayOutput &device, Color color, BlendingMode blending_mode)
void fillPixel(int16_t x, int16_t y)
Fill a pixel (buffered).
Adapter that turns a pixel writer into a single-color filler.
void fillPixel(int16_t x, int16_t y)
Fill a pixel using the configured color.
BufferedPixelWriterFillAdapter(PixelWriter &writer, Color color)
Buffered writer for arbitrary pixels with per-pixel colors.
BufferedPixelWriter(DisplayOutput &device, BlendingMode blending_mode)
Construct a writer targeting device using blending_mode.
BufferedPixelWriter & operator=(const BufferedPixelWriter &)=delete
BufferedPixelWriter(BufferedPixelWriter &)=delete
BufferedPixelWriter & operator=(BufferedPixelWriter &&)=delete
BufferedPixelWriter(const BufferedPixelWriter &)=delete
void flush()
Flush any buffered pixels.
void writePixel(int16_t x, int16_t y, Color color)
Write a single pixel (buffered).
void fillPixel(int16_t x, int16_t y)
void fillHLine(int16_t x0, int16_t y0, int16_t x1)
void fillVLine(int16_t x0, int16_t y0, int16_t y1)
BufferedRectFiller(DisplayOutput &device, Color color, BlendingMode blending_mode)
void fillRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1)
void fillRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1)
void fillPixel(int16_t x, int16_t y)
BufferedRectWriterFillAdapter(RectWriter &writer, Color color)
void fillHLine(int16_t x0, int16_t y0, int16_t x1)
void fillVLine(int16_t x0, int16_t y0, int16_t y1)
void writeRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1, Color color)
void writePixel(int16_t x, int16_t y, Color color)
BufferedRectWriter(DisplayOutput &device, BlendingMode blending_mode)
void writeVLine(int16_t x0, int16_t y0, int16_t y1, Color color)
void writeHLine(int16_t x0, int16_t y0, int16_t x1, Color color)
void fillVLine(int16_t x0, int16_t y0, int16_t y1)
BufferedVLineFiller(DisplayOutput &device, Color color, BlendingMode blending_mode)
const Box & clip_box() const
void fillHLine(int16_t x0, int16_t y0, int16_t x1)
ClippingBufferedHLineFiller(DisplayOutput &device, Color color, Box clip_box, BlendingMode blending_mode)
Buffered pixel filler with a clipping box.
const Box & clip_box() const
ClippingBufferedPixelFiller(DisplayOutput &device, Color color, Box clip_box, BlendingMode blending_mode)
void flush()
Flush any buffered pixels.
void fillPixel(int16_t x, int16_t y)
Fill a pixel if it lies within clip_box().
Buffered pixel writer with a clipping box.
const Box & clip_box() const
void writePixel(int16_t x, int16_t y, Color color)
Write a pixel if it lies within clip_box().
void flush()
Flush any buffered pixels.
ClippingBufferedPixelWriter(ClippingBufferedPixelWriter &)=delete
ClippingBufferedPixelWriter(const ClippingBufferedPixelWriter &)=delete
ClippingBufferedPixelWriter(DisplayOutput &device, Box clip_box, BlendingMode blending_mode)
void fillVLine(int16_t x0, int16_t y0, int16_t y1)
void fillPixel(int16_t x, int16_t y)
void fillHLine(int16_t x0, int16_t y0, int16_t x1)
const Box & clip_box() const
void fillRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1)
ClippingBufferedRectFiller(DisplayOutput &device, Color color, Box clip_box, BlendingMode blending_mode)
ClippingBufferedRectWriter(DisplayOutput &device, Box clip_box, BlendingMode blending_mode)
void writeRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1, Color color)
void writeHLine(int16_t x0, int16_t y0, int16_t x1, Color color)
void writeVLine(int16_t x0, int16_t y0, int16_t y1, Color color)
const Box & clip_box() const
void writePixel(int16_t x, int16_t y, Color color)
const Box & clip_box() const
void fillVLine(int16_t x0, int16_t y0, int16_t y1)
ClippingBufferedVLineFiller(DisplayOutput &device, Color color, Box clip_box, BlendingMode blending_mode)
ARGB8888 color stored as a 32-bit unsigned integer.
The abstraction for drawing to a display.
virtual void writeRects(BlendingMode blending_mode, Color *color, int16_t *x0, int16_t *y0, int16_t *x1, int16_t *y1, uint16_t count)=0
Draw the specified rectangles (per-rectangle colors). Invalidates the address window.
virtual void write(Color *color, uint32_t pixel_count)=0
Write pixels into the current address window.
virtual void fillPixels(BlendingMode blending_mode, Color color, int16_t *x, int16_t *y, uint16_t pixel_count)=0
Draw the specified pixels using the same color. Invalidates the address window.
virtual void writePixels(BlendingMode blending_mode, Color *color, int16_t *x, int16_t *y, uint16_t pixel_count)=0
Draw the specified pixels (per-pixel colors). Invalidates the address window.
virtual void fillRects(BlendingMode blending_mode, Color color, int16_t *x0, int16_t *y0, int16_t *x1, int16_t *y1, uint16_t count)=0
Draw the specified rectangles using the same color. Invalidates the address window.
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.
@ kSourceOverOpaque
Similar to kSourceOver, but assumes that the destination is opaque.
@ kSourceOver
Source is placed (alpha-blended) over the destination. This is the default blending mode.
static const uint8_t kPixelWritingBufferSize
static const uint8_t kRectWritingBufferSize
void FillColor(Color *buf, uint32_t count, Color color)
Fill an array with a single color.
BlendingMode blending_mode