roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
drawable.cpp
Go to the documentation of this file.
2
4
5namespace roo_display {
6
7namespace {
8
9const char* ToString(FillMode mode) {
10 switch (mode) {
12 return "FillMode::kExtents";
14 return "FillMode::kVisible";
15 }
16 return "FillMode::(unknown)";
17}
18
19class EmptyDrawable : public Drawable {
20 public:
21 Box extents() const override { return Box(); }
22};
23
24} // namespace
25
26roo_logging::Stream& operator<<(roo_logging::Stream& os, FillMode mode) {
27 return os << ToString(mode);
28}
29
30void Drawable::drawTo(const Surface& s) const {
31 if (s.fill_mode() == FillMode::kExtents) {
32 Box box = Box::Intersect(s.clip_box(), extents().translate(s.dx(), s.dy()));
33 if (!box.empty()) {
34 s.out().fillRect(BlendingMode::kSource, box, s.bgcolor());
35 }
36 }
37 drawInteriorTo(s);
38}
39
41 static EmptyDrawable empty;
42 return &empty;
43}
44
45} // namespace roo_display
static Box Intersect(const Box &a, const Box &b)
Return the intersection of two boxes (may be empty).
Definition box.h:25
Interface for objects that can be drawn to an output device.
Definition drawable.h:229
static const Drawable * Empty()
A singleton representing a no-op drawable with no bounding box.
Definition drawable.cpp:40
virtual Box extents() const =0
Return the bounding box encompassing all pixels that need to be drawn.
Defines 140 opaque HTML named colors.
@ kSource
The new ARGB8888 value completely replaces the old one.
roo_logging::Stream & operator<<(roo_logging::Stream &os, BlendingMode mode)
Definition blending.cpp:54
FillMode
Specifies whether a Drawable should fill its entire extents box, including fully transparent pixels.
Definition drawable.h:15
@ kVisible
Fully transparent pixels do not need to be filled.
@ kExtents
Fill the entire extents box (possibly with fully transparent pixels).