roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
offscreen.cpp
Go to the documentation of this file.
1// Support for drawing to in-memory buffers, using various color modes.
2
4
9
10namespace roo_display {
11namespace internal {
12
14 : orientation_(Orientation::Default()),
15 offset_(0),
16 x0_(0),
17 x1_(-1),
18 y0_(0),
19 y1_(-1),
20 advance_x_(0),
21 advance_y_(0),
22 cursor_x_(0),
23 cursor_y_(0) {}
24
26 uint16_t y1, int16_t raw_width,
27 int16_t raw_height, Orientation orientation) {
28 orientation_ = orientation;
29 x0_ = x0;
30 y0_ = y0;
31 x1_ = x1;
32 y1_ = y1;
33 cursor_x_ = x0_;
34 cursor_y_ = y0_;
37
39 offset_ = (x_direction > 0 ? y0_ : raw_width - 1 - y0_) +
40 (y_direction > 0 ? x0_ : raw_height - 1 - x0_) * raw_width;
41 advance_x_ = y_direction * raw_width;
42 advance_y_ = x_direction - y_direction * (x1_ - x0_ + 1) * raw_width;
43 } else {
44 offset_ = (x_direction > 0 ? x0_ : raw_width - 1 - x0_) +
45 (y_direction > 0 ? y0_ : raw_height - 1 - y0_) * raw_width;
46 advance_x_ = x_direction;
47 advance_y_ = y_direction * raw_width - x_direction * (x1_ - x0_ + 1);
48 }
49}
50
51} // namespace internal
52
53namespace {
54
55Box alignExtents(Box extents) {
56 return Box(extents.xMin(), extents.yMin(),
57 extents.xMin() + ((extents.width() + 7) & ~7) - 1, extents.yMax());
58}
59
60} // namespace
61
62BitMaskOffscreen::BitMaskOffscreen(Box extents, roo::byte *buffer)
63 : Offscreen(alignExtents(extents), buffer,
64 Monochrome(color::Black, color::Transparent)) {
66}
67
69 : Offscreen(alignExtents(extents),
70 Monochrome(color::Black, color::Transparent)) {
72}
73
79
80} // namespace roo_display
BitMaskOffscreen(int16_t width, int16_t height, roo::byte *buffer)
Definition offscreen.h:680
Axis-aligned integer rectangle.
Definition box.h:12
int16_t width() const
Width in pixels (inclusive coordinates).
Definition box.h:77
int16_t xMin() const
Minimum x (inclusive).
Definition box.h:65
int16_t yMax() const
Maximum y (inclusive).
Definition box.h:74
int16_t yMin() const
Minimum y (inclusive).
Definition box.h:68
ARGB8888 color stored as a 32-bit unsigned integer.
Definition color.h:16
Offscreen rasterizable that writes into a pixel buffer.
Definition offscreen.h:491
void set_extents(const Box &extents)
Definition offscreen.h:629
Represents the orientation of a display device.
Definition orientation.h:25
bool isLeftToRight() const
Return whether horizontal direction is left-to-right.
Definition orientation.h:98
bool isTopToBottom() const
Return whether vertical direction is top-to-bottom.
bool isXYswapped() const
Return whether x maps to the vertical direction.
Definition orientation.h:90
void setAddress(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t raw_width, int16_t raw_height, Orientation orientation)
Definition offscreen.cpp:25
Orientation orientation() const
Definition offscreen.h:73
Defines 140 opaque HTML named colors.