|
roo_display
API Documentation for roo_display
|
Low-level handle used to draw to an underlying device. More...
#include <drawable.h>
Public Member Functions | |
| 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. | |
| 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. | |
| Surface (Surface &&other)=default | |
| Surface (const Surface &other)=default | |
| DisplayOutput & | out () const |
| Return the device output. | |
| void | set_out (DisplayOutput *out) |
| Replace the output device pointer. | |
| int16_t | dx () const |
| Return the x offset to apply to drawn objects. | |
| int16_t | dy () const |
| Return the y offset to apply to drawn objects. | |
| bool | is_write_once () const |
| Return whether this surface is write-once. | |
| const Box & | clip_box () const |
| Return the clip box in device coordinates (independent of offsets). | |
| void | set_clip_box (const Box &clip_box) |
| Set the clip box in device coordinates. | |
| Color | bgcolor () const |
| Return the background color used for blending. | |
| void | set_bgcolor (Color bgcolor) |
| Set the background color used for blending. | |
| FillMode | fill_mode () const |
Return the fill mode the drawable should observe. FillMode::kVisible If FillMode::kExtents, the drawable must fill its entire (clipped) extents even if some pixels are completely transparent. If FillMode::kVisible, the drawable may omit fully transparent pixels. This assumes the appropriate background has been pre-applied. | |
| void | set_fill_mode (FillMode fill_mode) |
| Set the fill mode for drawables. | |
| BlendingMode | blending_mode () const |
| Return the default blending mode for drawing. | |
| void | set_blending_mode (BlendingMode blending_mode) |
| Set the default blending mode. | |
| void | set_dx (int16_t dx) |
| Set the x offset applied to drawables. | |
| void | set_dy (int16_t dy) |
| Set the y offset applied to drawables. | |
| void | drawObject (const Drawable &object) const |
| Draw a drawable object to this surface. | |
| void | drawObject (const Drawable &object, int16_t dx, int16_t dy) const |
| Draw a drawable object with an additional offset. | |
| Box::ClipResult | clipToExtents (Box extents) |
| Clip the given extents to the surface clip box. | |
Friends | |
| class | DrawingContext |
Low-level handle used to draw to an underlying device.
This is passed by the library to Drawable::drawTo(); do not create it directly.
The device uses absolute coordinates starting at (0, 0). To translate an object's extents into device coordinates, apply the surface offsets:
extents.translate(s.dx(), s.dy())
Constrain to clip_box() when drawing:
Box::Intersect(s.clip_box(), extents.translate(s.dx(), s.dy()))
To quickly reject objects outside the clip box:
Box bounds = Box::Intersect(s.clip_box(), extents.translate(s.dx(), s.dy())); if (bounds.empty()) return;
To compute clipped bounds in object coordinates:
Box clipped = Box::Intersect(s.clip_box().translate(-s.dx(), -s.dy()), extents);
Definition at line 60 of file drawable.h.
|
inline |
Create a surface targeting a device output.
| out | Output device. |
| dx | X offset to apply to drawn objects. |
| dy | Y offset to apply to drawn objects. |
| clip | Clip box in device coordinates. |
| is_write_once | Whether this surface is write-once. |
| bg | Background color used for blending. |
| fill_mode | Fill behavior for transparent pixels. |
| blending_mode | DefaFillMode::kVisiblee. |
Definition at line 72 of file drawable.h.
References blending_mode(), and roo_display::kSource.
|
inline |
Create a surface targeting a device output with no offset.
| out | Output device. |
| clip | Clip box in device coordinates. |
| is_write_once | Whether this surface is write-once. |
| bg | Background color used for blending. |
| fill_mode | Fill behavior for transparent pixels.FillMode::kVisible |
| blending_mode | Default blending mode. |
Definition at line 97 of file drawable.h.
References blending_mode(), roo_display::kSource, roo_display::kSourceOver, and roo_display::kSourceOverOpaque.
|
default |
|
inline |
Return the background color used for blending.
Definition at line 140 of file drawable.h.
Referenced by set_bgcolor().
|
inline |
Return the default blending mode for drawing.
If the mode is BlendingMode::kSourceOver, a drawable may replace it with BlendingMode::kSource when all pixels it writes are fully opaque. If an opaque background is specified, BlendingMode::kSourceOver is automatically replaced with BlendingMode::kSource.
Definition at line 162 of file drawable.h.
Referenced by set_blending_mode(), Surface(), and Surface().
Return the clip box in device coordinates (independent of offsets).
Definition at line 134 of file drawable.h.
Referenced by roo_display::png_draw(), and set_clip_box().
|
inline |
Clip the given extents to the surface clip box.
Definition at line 194 of file drawable.h.
References roo_display::Box::clip(), and roo_display::Box::translate().
Draw a drawable object to this surface.
Intended for custom Drawable implementations to draw child objects.
Definition at line 278 of file drawable.h.
References roo_display::Box::kEmpty.
Referenced by drawObject(), and roo_display::png_draw().
|
inline |
Draw a drawable object with an additional offset.
Convenience wrapper around drawObject().
Definition at line 182 of file drawable.h.
References drawObject(), dx(), and dy().
|
inline |
Return the x offset to apply to drawn objects.
Definition at line 125 of file drawable.h.
Referenced by drawObject(), and set_dx().
|
inline |
Return the y offset to apply to drawn objects.
Definition at line 128 of file drawable.h.
Referenced by drawObject(), roo_display::png_draw(), and set_dy().
|
inline |
Return the fill mode the drawable should observe. FillMode::kVisible If FillMode::kExtents, the drawable must fill its entire (clipped) extents even if some pixels are completely transparent. If FillMode::kVisible, the drawable may omit fully transparent pixels. This assumes the appropriate background has been pre-applied.
Definition at line 151 of file drawable.h.
Referenced by set_fill_mode().
|
inline |
Return whether this surface is write-once.
Definition at line 131 of file drawable.h.
|
inline |
Return the device output.
Definition at line 119 of file drawable.h.
Referenced by roo_display::png_draw(), and set_out().
Set the background color used for blending.
Definition at line 143 of file drawable.h.
References bgcolor().
|
inline |
Set the default blending mode.
Definition at line 165 of file drawable.h.
References blending_mode().
Set the clip box in device coordinates.
Definition at line 137 of file drawable.h.
References clip_box().
|
inline |
|
friend |
Definition at line 199 of file drawable.h.