6#include "roo_logging/stream.h"
26[[deprecated(
"Use `FillMode::kExtents` instead.")]]
28[[
deprecated(
"Use `FillMode::kVisible` instead.")]]
79 clip_box_(std::
move(clip)),
98 Color bg = color::Transparent,
104 clip_box_(std::
move(clip)),
183 if (
dx == 0 &&
dy == 0) {
188 s.set_dx(
s.dx() +
dx);
189 s.set_dy(
s.dy() +
dy);
190 s.drawObject(
object);
202 Box extents()
const {
return clip_box_.
translate(-dx_, -dy_); }
204 void unnest()
const {}
205 const Rasterizable *getRasterizableBackground()
const {
return nullptr; }
206 Color getBackgroundColor()
const {
return bgcolor_; }
269 virtual void drawTo(
const Surface &
s)
const;
275 virtual void drawInteriorTo(
const Surface &
s)
const {}
Axis-aligned integer rectangle.
ClipResult
Result of clipping a box to a clip region.
Box translate(int16_t x_offset, int16_t y_offset) const
Return a translated copy of this box.
ClipResult clip(const Box &clip_box)
Clip this box to the given clip box.
ARGB8888 color stored as a 32-bit unsigned integer.
The abstraction for drawing to a display.
Interface for objects that can be drawn to an output device.
virtual Box anchorExtents() const
Return the bounds used for alignment.
static const Drawable * Empty()
A singleton representing a no-op drawable with no bounding box.
virtual Box extents() const =0
Return the bounding box encompassing all pixels that need to be drawn.
Primary top-level interface for drawing to screens, off-screen buffers, or other devices.
Drawable that can provide a color for any point within its extents.
Low-level handle used to draw to an underlying device.
void set_bgcolor(Color bgcolor)
Set the background color used for blending.
void set_out(DisplayOutput *out)
Replace the output device pointer.
int16_t dy() const
Return the y offset to apply to drawn objects.
Surface(Surface &&other)=default
void drawObject(const Drawable &object, int16_t dx, int16_t dy) const
Draw a drawable object with an additional offset.
Color bgcolor() const
Return the background color used for blending.
Box::ClipResult clipToExtents(Box extents)
Clip the given extents to the surface clip box.
void set_dy(int16_t dy)
Set the y offset applied to drawables.
void set_fill_mode(FillMode fill_mode)
Set the fill mode for drawables.
Surface(const Surface &other)=default
const Box & clip_box() const
Return the clip box in device coordinates (independent of offsets).
void set_blending_mode(BlendingMode blending_mode)
Set the default blending mode.
int16_t dx() const
Return the x offset to apply to drawn objects.
void set_clip_box(const Box &clip_box)
Set the clip box in device coordinates.
bool is_write_once() const
Return whether this surface is write-once.
Surface(DisplayOutput *out, Box clip, bool is_write_once, Color bg=color::Transparent, FillMode fill_mode=FillMode::kVisible, BlendingMode blending_mode=BlendingMode::kSourceOver)
Create a surface targeting a device output with no offset.
BlendingMode blending_mode() const
Return the default blending mode for drawing.
Surface(DisplayOutput &out, int16_t dx, int16_t dy, Box clip, bool is_write_once, Color bg=color::Transparent, FillMode fill_mode=FillMode::kVisible, BlendingMode blending_mode=BlendingMode::kSourceOver)
Create a surface targeting a device output.
void drawObject(const Drawable &object) const
Draw a drawable object to this surface.
void set_dx(int16_t dx)
Set the x offset applied to drawables.
FillMode fill_mode() const
Return the fill mode the drawable should observe. FillMode::kVisible If FillMode::kExtents,...
DisplayOutput & out() const
Return the device output.
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.
@ kSourceOverOpaque
Similar to kSourceOver, but assumes that the destination is opaque.
@ kSource
The new ARGB8888 value completely replaces the old one.
@ kSourceOver
Source is placed (alpha-blended) over the destination. This is the default blending mode.
roo_logging::Stream & operator<<(roo_logging::Stream &os, BlendingMode mode)
constexpr FillMode FILL_MODE_VISIBLE
FillMode
Specifies whether a Drawable should fill its entire extents box, including fully transparent pixels.
@ kVisible
Fully transparent pixels do not need to be filled.
@ kExtents
Fill the entire extents box (possibly with fully transparent pixels).
constexpr FillMode FILL_MODE_RECTANGLE