23 if (
box->contains(x, y))
return true;
31 if (
box->intersects(
rect))
return true;
37 size_t size()
const {
return end_ - begin_; }
54 address_window_(0, 0, 0, 0),
65 address_window_ =
Box(x0, y0, x1, y1);
66 blending_mode_ = mode;
76 if (!exclusion_->
contains(cursor_x_, cursor_y_)) {
79 if (++cursor_x_ > address_window_.
xMax()) {
81 cursor_x_ = address_window_.
xMin();
91 if (!exclusion_->
contains(cursor_x_, cursor_y_)) {
92 filler.fillPixel(cursor_x_, cursor_y_);
94 if (++cursor_x_ > address_window_.
xMax()) {
96 cursor_x_ = address_window_.
xMin();
105 while (count-- > 0) {
106 writeRect(*
color++, *x0++, *y0++, *x1++, *y1++, 0, &
writer);
113 while (count-- > 0) {
114 fillRect(*x0++, *y0++, *x1++, *y1++, 0, &
filler);
173 if (mask_idx == (
int)exclusion_->
size()) {
174 writer->writeRect(x0, y0, x1, y1, color);
178 if (intruder.yMin() > y0) {
179 writeRect(color, x0, y0, x1, intruder.yMin() - 1, mask_idx + 1,
writer);
180 y0 = intruder.yMin();
182 if (intruder.xMin() > x0) {
183 writeRect(color, x0, y0, intruder.xMin() - 1, intruder.yMax(),
186 if (intruder.xMax() < x1) {
187 writeRect(color, intruder.xMax() + 1, y0, x1, intruder.yMax(),
190 if (intruder.yMax() < y1) {
191 writeRect(color, x0, intruder.yMax() + 1, x1, y1, mask_idx + 1,
writer);
195 void fillRect(int16_t x0, int16_t y0, int16_t x1, int16_t y1,
int mask_idx,
196 BufferedRectFiller* filler) {
198 Box rect(x0, y0, x1, y1);
199 while (mask_idx < (
int)exclusion_->
size() &&
204 if (mask_idx == (
int)exclusion_->
size()) {
205 filler->fillRect(x0, y0, x1, y1);
210 if (intruder.yMin() > y0) {
211 fillRect(x0, y0, x1, intruder.yMin() - 1, mask_idx + 1, filler);
212 y0 = intruder.yMin();
214 if (intruder.xMin() > x0) {
215 fillRect(x0, y0, intruder.xMin() - 1, intruder.yMax(), mask_idx + 1,
218 if (intruder.xMax() < x1) {
219 fillRect(intruder.xMax() + 1, y0, x1, intruder.yMax(), mask_idx + 1,
222 if (intruder.yMax() < y1) {
223 fillRect(x0, intruder.yMax() + 1, x1, y1, mask_idx + 1, filler);
227 DisplayOutput* output_;
228 const RectUnion* exclusion_;
BufferedRectWriter & writer
Axis-aligned integer rectangle.
int16_t xMin() const
Minimum x (inclusive).
int16_t xMax() const
Maximum x (inclusive).
bool intersects(const Box &other) const
Return whether this box intersects the other box.
static Box Intersect(const Box &a, const Box &b)
Return the intersection of two boxes (may be empty).
Buffered filler for arbitrary pixels using a single color.
Buffered writer for arbitrary pixels with per-pixel colors.
ARGB8888 color stored as a 32-bit unsigned integer.
The abstraction for drawing to a display.
virtual const ColorFormat & getColorFormat() const =0
Return the native color format used by this device for direct drawing.
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.
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.
Filtering device that excludes a union of rectangles.
const ColorFormat & getColorFormat() const override
Return the native color format used by this device for direct drawing.
virtual ~RectUnionFilter()
void fill(Color color, uint32_t pixel_count) override
Write pixel_count copies of the same color into the current address window.
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 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 setOutput(DisplayOutput &output)
Replace the underlying output.
RectUnionFilter(DisplayOutput &output, const RectUnion *exclusion)
Create a filter with an exclusion union.
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 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 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.
void write(Color *color, uint32_t pixel_count) override
Write pixels into the current address window.
Union of rectangles used as an exclusion mask.
bool intersects(const Box &rect) const
Return whether the union intersects a rectangle.
RectUnion(const Box *begin, const Box *end)
Construct a rect union from a range.
void reset(const Box *begin, const Box *end)
Reset to a new range.
size_t size() const
Return the number of rectangles in the union.
const Box & at(int idx) const
Return the rectangle at index idx.
bool contains(int16_t x, int16_t y) const
Return whether the union contains a point.
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.