roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
roo_display.h
Go to the documentation of this file.
1/// @file roo_display.h
2/// @brief Public API surface for roo_display display, touch, and drawing
3/// utilities.
4#pragma once
5
6#include <functional>
7
19
20namespace roo_display {
21
22class FrontToBackWriter;
23
24/// @brief Wrapper providing calibrated touch input for a display device.
26 public:
27 /// Constructs a touch display wrapper.
28 TouchDisplay(DisplayDevice& display_device, TouchDevice& touch_device,
29 TouchCalibration touch_calibration = TouchCalibration())
30 : display_device_(display_device),
31 touch_device_(touch_device),
32 touch_calibration_(touch_calibration) {}
33
34 /// Initializes the touch device.
35 void init() { touch_device_.initTouch(); }
36
37 /// Returns calibrated touch points in display coordinates.
38 TouchResult getTouch(TouchPoint* points, int max_points);
39
40 /// Returns raw touch points in absolute 0-4095 coordinates.
41 TouchResult getRawTouch(TouchPoint* points, int max_points) {
42 return touch_device_.getTouch(points, max_points);
43 }
44
45 /// Sets the touch calibration mapping.
46 void setCalibration(TouchCalibration touch_calibration) {
47 touch_calibration_ = touch_calibration;
48 }
49
50 /// Returns the current touch calibration.
51 const TouchCalibration& calibration() const { return touch_calibration_; }
52
53 private:
54 DisplayDevice& display_device_;
55 TouchDevice& touch_device_;
56 TouchCalibration touch_calibration_;
57
58 int16_t raw_touch_x_;
59 int16_t raw_touch_y_;
60 int16_t raw_touch_z_;
61};
62
63/// @brief Display facade that owns a display device and optional touch input.
64class Display {
65 public:
66 /// Constructs a display without touch support.
67 Display(DisplayDevice& display_device)
68 : Display(display_device, nullptr, TouchCalibration()) {}
69
70 /// Constructs a display with touch support and optional calibration.
71 Display(DisplayDevice& display_device, TouchDevice& touch_device,
72 TouchCalibration touch_calibration = TouchCalibration())
73 : Display(display_device, &touch_device, touch_calibration) {}
74
75 /// Constructs a display from a combo device.
77 : Display(device.display(), device.touch(), device.touch_calibration()) {}
78
79 /// Returns the total pixel area of the raw device.
80 int32_t area() const {
81 return display_device_.raw_width() * display_device_.raw_height();
82 }
83
84 /// Returns the current extents used by this display.
85 const Box& extents() const { return extents_; }
86
87 /// Returns the width in pixels of the current extents.
88 int16_t width() const { return extents_.width(); }
89 /// Returns the height in pixels of the current extents.
90 int16_t height() const { return extents_.height(); }
91
92 /// Initializes the display and touch devices.
93 void init() {
94 display_device_.init();
95 touch_.init();
96 }
97
98 /// Initializes the device, fills the screen with the specified color, and
99 /// sets that color as the default background hint.
100 void init(Color bgcolor);
101
102 /// Sets the display orientation. Resets the clip box to the max display area.
104
105 /// Returns the current orientation.
106 Orientation orientation() const { return orientation_; }
107
108 /// Returns the touch calibration for the display.
110 return touch_.calibration();
111 }
112
113 /// Returns mutable access to the display output.
114 DisplayOutput& output() { return *output_; }
115 /// Returns const access to the display output.
116 const DisplayOutput& output() const { return *output_; }
117
118 /// Returns calibrated touch points in display coordinates.
119 ///
120 /// If no touch has been registered, returns {.touch_points = 0} and does not
121 /// modify `points`. If k touch points have been registered, sets up to
122 /// max_points entries in `points`, and returns {.touch_points = k}. In both
123 /// cases, the returned timestamp specifies the detection time.
124 TouchResult getTouch(TouchPoint* points, int max_points) {
125 return touch_.getTouch(points, max_points);
126 }
127
128 /// Returns raw touch points in absolute coordinates (0-4095).
129 TouchResult getRawTouch(TouchPoint* points, int max_points) {
130 return touch_.getRawTouch(points, max_points);
131 }
132
133 /// Returns true and sets (x, y) if touched; otherwise returns false.
134 bool getTouch(int16_t& x, int16_t& y);
135
136 /// Resets the clip box to the maximum device-allowed values.
138 extents_ = Box(0, 0, display_device_.effective_width() - 1,
139 display_device_.effective_height() - 1);
140 }
141
142 /// Sets a default clip box, inherited by derived contexts.
143 void setExtents(const Box& extents) {
144 resetExtents();
145 extents_ = Box::Intersect(extents_, extents);
146 }
147
148 /// Sets a rasterizable background for all derived contexts.
149 void setBackground(const Rasterizable* bg) {
150 background_ = bg;
151 bgcolor_ = color::Transparent;
152 }
153
154 /// Sets the touch calibration mapping.
155 void setTouchCalibration(TouchCalibration touch_calibration) {
156 touch_.setCalibration(touch_calibration);
157 }
158
159 /// Returns the rasterizable background for derived contexts.
160 const Rasterizable* getRasterizableBackground() const { return background_; }
161
162 /// Sets a background color used by all derived contexts.
163 /// Initially set to color::Transparent.
165 bgcolor_ = bgcolor;
166 display_device_.setBgColorHint(bgcolor);
167 }
168
169 /// Returns the background color for derived contexts.
170 Color getBackgroundColor() const { return bgcolor_; }
171
172 /// Clears the display, respecting the clip box and background settings.
173 void clear();
174
175 void enableTurbo();
176
177 void disableTurbo();
178
179 bool isTurboEnabled() const { return turbo_ != nullptr; }
180
181 private:
182 Display(DisplayDevice& display_device, TouchDevice* touch_device,
183 TouchCalibration touch_calibration);
184
185 friend class DrawingContext;
186
187 void nest() {
188 if (nest_level_++ == 0) {
189 display_device_.begin();
190 }
191 }
192
193 void unnest() {
194 if (--nest_level_ == 0) {
195 display_device_.end();
196 }
197 }
198
199 int16_t dx() const { return 0; }
200 int16_t dy() const { return 0; }
201 bool is_write_once() const { return false; }
202 FillMode fill_mode() const { return FillMode::kVisible; }
204
205 DisplayDevice& display_device_;
206 std::unique_ptr<BackgroundFillOptimizer::FrameBuffer> turbo_frame_buffer_;
207 std::unique_ptr<BackgroundFillOptimizer> turbo_;
208 // Set to either the display_device_ or the turbo wrapper.
209 DisplayOutput* output_;
210 TouchDisplay touch_;
211 int16_t nest_level_;
212 Orientation orientation_;
213
214 Box extents_;
215 Color bgcolor_;
216 const Rasterizable* background_;
217};
218
219/// @brief Primary top-level interface for drawing to screens, off-screen
220/// buffers, or other devices.
221///
222/// Supports rectangular clip regions, as well as arbitrary clip masks.
223///
224/// Able to render objects implementing the Drawable interface.
226 public:
227 /// Constructs a drawing context covering the entire display.
228 template <typename Display>
230 : DrawingContext(display, 0, 0, display.extents()) {}
231
232 /// Constructs a drawing context covering the specified bounds, relative to
233 /// the display's extents. If bounds exceed the display's extents, they will
234 /// be clipped accordingly, but the requested bounds will still be used for
235 /// alignment purposes. For example, drawing a centered object will center it
236 /// relative to the bounds(), even if they exceed the display's extents.
237 template <typename Display>
239 : DrawingContext(display, 0, 0, bounds) {}
240
241 /// Constructs a drawing context covering the entire display, with device
242 /// coordinates offset by the specified amounts.
243 template <typename Display>
244 DrawingContext(Display& display, int16_t x_offset, int16_t y_offset)
245 : DrawingContext(display, x_offset, y_offset,
246 display.extents().translate(-x_offset, -y_offset)) {}
247
248 /// Constructs a drawing context covering the specified bounds, with device
249 /// coordinates offset by the specified amounts. The bounds are expressed
250 /// post-translation. That is, bounds corresponding to the entire display
251 /// surface would be equal to display.extents().translate(-x_offset,
252 /// -y_offset). If bounds exceed the display's extents, they will be clipped
253 /// accordingly, but the requested bounds will still be used for alignment
254 /// purposes. For example, drawing a centered object will center it relative
255 /// to the requested bounds, even if they exceed the display's extents.
256 template <typename Display>
257 DrawingContext(Display& display, int16_t x_offset, int16_t y_offset,
258 Box bounds)
259 : output_(display.output()),
260 dx_(display.dx() + x_offset),
261 dy_(display.dy() + y_offset),
262 bounds_(bounds),
263 max_clip_box_(Box::Intersect(
264 bounds, display.extents().translate(-x_offset, -y_offset))),
265 clip_box_(max_clip_box_),
266 unnest_([&display]() { display.unnest(); }),
267 write_once_(display.is_write_once()),
268 fill_mode_(display.fill_mode()),
269 blending_mode_(display.blending_mode()),
270 clip_mask_(nullptr),
271 background_(display.getRasterizableBackground()),
272 bgcolor_(display.getBackgroundColor()),
273 transformed_(false),
274 transformation_() {
275 display.nest();
276 }
277
279
280 /// Returns the bounds used for alignment.
281 const Box& bounds() const { return bounds_; }
282
283 /// Returns the width of the drawing context. Equivalent to bounds().width().
284 const uint16_t width() const { return bounds_.width(); }
285
286 /// Returns the height of the drawing context. Equivalent to
287 /// bounds().height().
288 const uint16_t height() const { return bounds_.height(); }
289
290 void setBackground(const Rasterizable* bg) { background_ = bg; }
291 const Rasterizable* getBackground() const { return background_; }
292
293 Color getBackgroundColor() const { return bgcolor_; }
295
296 FillMode fillMode() const { return fill_mode_; }
297 void setFillMode(FillMode fill_mode) { fill_mode_ = fill_mode; }
298
299 BlendingMode blendingMode() const { return blending_mode_; }
301 blending_mode_ = blending_mode;
302 }
303
304 /// Clears the display, respecting the clip box, and background settings.
305 void clear();
306
307 /// Fills the display with the specified color, respecting the clip box.
308 void fill(Color color);
309
310 /// Sets the clip box, intersected with the maximum allowed clip box.
311 /// Expressed in device coordinates.
312 void setClipBox(const Box& clip_box) {
313 clip_box_ = Box::Intersect(clip_box, max_clip_box_);
314 }
315
316 /// Sets the clip box, intersected with the maximum allowed clip box.
317 /// Expressed in device coordinates.
318 void setClipBox(int16_t x0, int16_t y0, int16_t x1, int16_t y1) {
319 setClipBox(Box(x0, y0, x1, y1));
320 }
321
322 void setClipMask(const ClipMask* clip_mask) { clip_mask_ = clip_mask; }
323
324 /// Returns the current clip box, in device coordinates.
325 const Box& getClipBox() const { return clip_box_; }
326
327 // void applyTransformation(Transformation t) {
328 // transformation_ = transformation_.transform(t);
329 // }
330
331 /// Sets a transformation to be applied to all drawn objects when converting
332 /// the drawing coordinates to device coordinates.
334 transformation_ = t;
335 transformed_ = (t.xy_swap() || t.is_rescaled() || t.is_translated());
336 }
337
338 /// Returns the current transformation. (The identity transformation by
339 /// default).
340 const Transformation& transformation() const { return transformation_; }
341
342 void setWriteOnce();
343
344 bool isWriteOnce() const { return write_once_; }
345
346 /// Allows to efficiently draw pixels to the context, using a buffered
347 /// pixel writer (avoiding virtual calls per pixel, and allowing for batch
348 /// writes). The provided function `fn` will be called with a
349 /// ClippingBufferedPixelWriter that respects the current clip box and
350 /// uses the specified blending mode.
351 void drawPixels(const std::function<void(ClippingBufferedPixelWriter&)>& fn,
353
354 /// Draws the object using its inherent coordinates. The point (0, 0) in the
355 /// object's coordinates maps to (0, 0) in the context's coordinates
356 /// (subject to the optional transformation).
357 inline void draw(const Drawable& object) {
358 drawInternal(object, 0, 0, bgcolor_);
359 }
360
361 /// Draws the object using the specified absolute offset. The point (0, 0) in
362 /// the object's coordinates maps to (dx, dy) in the context's coordinates
363 /// (subject to the optional transformation).
364 inline void draw(const Drawable& object, int16_t dx, int16_t dy) {
365 drawInternal(object, dx, dy, bgcolor_);
366 }
367
368 /// Draws the object applying the specified alignment, relative to the
369 /// bounds(). For example, for with kMiddle | kCenter, the object will be
370 /// centered relative to the bounds().
371 void draw(const Drawable& object, Alignment alignment) {
372 Box anchorExtents = object.anchorExtents();
373 if (transformed_) {
374 anchorExtents = transformation_.transformBox(anchorExtents);
375 }
376 Offset offset = alignment.resolveOffset(bounds(), anchorExtents);
377 drawInternal(object, offset.dx, offset.dy, bgcolor_);
378 }
379
380 /// Analogous to draw(object), but instead of drawing, replaces all the output
381 /// pixels with the background color.
382 void erase(const Drawable& object);
383
384 /// Analogous to draw(object, dx, dy), but instead of drawing, replaces all
385 /// the output pixels with the background color.
386 void erase(const Drawable& object, int16_t dx, int16_t dy);
387
388 /// Analogous to draw(object, alignment), but instead of drawing, replaces all
389 /// the output pixels with the background color.
390 void erase(const Drawable& object, Alignment alignment);
391
392 private:
393 DisplayOutput& output() { return output_; }
394 const DisplayOutput& output() const { return output_; }
395
396 void drawInternal(const Drawable& object, int16_t dx, int16_t dy,
397 Color bgcolor);
398
399 void drawInternalWithBackground(Surface& s, const Drawable& object);
400
401 void drawInternalTransformed(Surface& s, const Drawable& object);
402
403 DisplayOutput& output_;
404
405 /// Offset of the origin in the output coordinates. Empty Transformation maps
406 /// (0, 0) in drawing coordinates onto (dx_, dy_) in device coordinates.
407 int16_t dx_;
408 int16_t dy_;
409
410 /// Bounds used for alignment. Default to device extents. If different than
411 /// device extents, they both constrain the initial and max clip box.
412 Box bounds_;
413
414 /// The maximum allowed clip box. setClipBox will intersect its argument
415 /// with it. Equal to the intersection of bounds() and the original device
416 /// extents.
417 const Box max_clip_box_;
418
419 /// Absolute coordinates of the clip region in the device space. Inclusive.
420 Box clip_box_;
421
422 std::function<void()> unnest_;
423
424 bool write_once_;
425 std::unique_ptr<FrontToBackWriter> front_to_back_writer_;
426
427 FillMode fill_mode_;
428 BlendingMode blending_mode_;
429
430 const ClipMask* clip_mask_;
431 const Rasterizable* background_;
432 Color bgcolor_;
433 bool transformed_;
434 Transformation transformation_;
435};
436
437/**
438 * @brief Infinite single-color area.
439 *
440 * When drawn, it fills the entire clip box with the given color.
441 */
442class Fill : public Rasterizable {
443 public:
444 /// Constructs a fill with a constant color.
445 Fill(Color color) : color_(color) {}
446
447 Box extents() const override { return Box::MaximumBox(); }
448
449 void readColors(const int16_t* x, const int16_t* y, uint32_t count,
450 Color* result) const override;
451
452 bool readColorRect(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax,
453 Color* result) const override;
454
455 private:
456 void drawTo(const Surface& s) const override;
457
458 Color color_;
459};
460
461/**
462 * @brief Infinite transparent area.
463 *
464 * When drawn, it fills the entire clip box with the color implied by the
465 * background settings.
466 */
467class Clear : public Rasterizable {
468 public:
469 /// Constructs a clear fill.
470 Clear() {}
471
472 Box extents() const override { return Box::MaximumBox(); }
473
474 void readColors(const int16_t* x, const int16_t* y, uint32_t count,
475 Color* result) const override;
476
477 bool readColorRect(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax,
478 Color* result) const override;
479
480 private:
481 void drawTo(const Surface& s) const override;
482};
483
484/**
485 * @brief Temporarily pauses the output transport while a DrawingContext is
486 * active.
487 *
488 * This releases the bus (e.g. SPI) to allow custom drawables to perform
489 * operations on the same bus (e.g. reading data from an SD card). When an
490 * instance of this class is alive, and unless ResumeOutput is also used,
491 * DrawingContexts do not function and no drawing operations should be
492 * attempted.
493 *
494 * See jpeg.cpp and png.cpp for an application example.
495 */
497 public:
498 /// Ends the output transaction on construction.
499 PauseOutput(DisplayOutput& out) : out_(out) { out_.end(); }
500 /// Restarts the output transaction on destruction.
501 ~PauseOutput() { out_.begin(); }
502
503 private:
504 DisplayOutput& out_;
505};
506
507/**
508 * @brief Resumes a paused output transaction.
509 *
510 * Inverse of PauseOutput; enables drawing while in scope.
511 */
513 public:
514 /// Begins the output transaction on construction.
515 ResumeOutput(DisplayOutput& out) : out_(out) { out_.begin(); }
516 /// Ends the output transaction on destruction.
517 ~ResumeOutput() { out_.end(); }
518
519 private:
520 DisplayOutput& out_;
521};
522
523} // namespace roo_display
Combines horizontal and vertical alignment.
Definition alignment.h:172
Offset resolveOffset(const Box &outer, const Box &inner) const
Definition alignment.h:186
Axis-aligned integer rectangle.
Definition box.h:12
int16_t width() const
Width in pixels (inclusive coordinates).
Definition box.h:77
static Box MaximumBox()
Return a large sentinel box used for unbounded extents.
Definition box.h:59
int16_t height() const
Height in pixels (inclusive coordinates).
Definition box.h:80
static Box Intersect(const Box &a, const Box &b)
Return the intersection of two boxes (may be empty).
Definition box.h:25
Infinite transparent area.
void readColors(const int16_t *x, const int16_t *y, uint32_t count, Color *result) const override
Read colors for the given points.
bool readColorRect(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax, Color *result) const override
Read colors for a rectangle.
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
Clear()
Constructs a clear fill.
Binary clip mask using a packed bit buffer.
Definition clip_mask.h:17
Buffered pixel writer with a clipping box.
ARGB8888 color stored as a 32-bit unsigned integer.
Definition color.h:16
Base class for displays with integrated, pre-calibrated touch.
Definition combo_device.h:9
Base class for display device drivers.
Definition device.h:223
int16_t raw_width() const
Return the width of the display in its native orientation.
Definition device.h:256
int16_t raw_height() const
Return the height of the display in its native orientation.
Definition device.h:262
int16_t effective_height() const
Return the display height in the current orientation.
Definition device.h:270
virtual void init()
Initialize the display driver.
Definition device.h:232
int16_t effective_width() const
Return the display width in the current orientation.
Definition device.h:265
virtual void setBgColorHint(Color bgcolor)
Provide a background color hint for source-over blending.
Definition device.h:280
The abstraction for drawing to a display.
Definition device.h:15
virtual void end()
Finalize the previously entered write transaction, flushing any pending writes.
Definition device.h:32
virtual void begin()
Enter a write transaction.
Definition device.h:25
Display facade that owns a display device and optional touch input.
Definition roo_display.h:64
TouchResult getRawTouch(TouchPoint *points, int max_points)
Returns raw touch points in absolute coordinates (0-4095).
const Rasterizable * getRasterizableBackground() const
Returns the rasterizable background for derived contexts.
const DisplayOutput & output() const
Returns const access to the display output.
Display(DisplayDevice &display_device)
Constructs a display without touch support.
Definition roo_display.h:67
int16_t height() const
Returns the height in pixels of the current extents.
Definition roo_display.h:90
void setOrientation(Orientation orientation)
Sets the display orientation. Resets the clip box to the max display area.
TouchResult getTouch(TouchPoint *points, int max_points)
Returns calibrated touch points in display coordinates.
int16_t width() const
Returns the width in pixels of the current extents.
Definition roo_display.h:88
void setBackground(const Rasterizable *bg)
Sets a rasterizable background for all derived contexts.
void resetExtents()
Resets the clip box to the maximum device-allowed values.
Color getBackgroundColor() const
Returns the background color for derived contexts.
void setTouchCalibration(TouchCalibration touch_calibration)
Sets the touch calibration mapping.
int32_t area() const
Returns the total pixel area of the raw device.
Definition roo_display.h:80
Display(ComboDevice &device)
Constructs a display from a combo device.
Definition roo_display.h:76
Display(DisplayDevice &display_device, TouchDevice &touch_device, TouchCalibration touch_calibration=TouchCalibration())
Constructs a display with touch support and optional calibration.
Definition roo_display.h:71
Orientation orientation() const
Returns the current orientation.
void init()
Initializes the display and touch devices.
Definition roo_display.h:93
const Box & extents() const
Returns the current extents used by this display.
Definition roo_display.h:85
bool isTurboEnabled() const
void setBackgroundColor(Color bgcolor)
Sets a background color used by all derived contexts. Initially set to color::Transparent.
void setExtents(const Box &extents)
Sets a default clip box, inherited by derived contexts.
DisplayOutput & output()
Returns mutable access to the display output.
const TouchCalibration & touchCalibration() const
Returns the touch calibration for the display.
void clear()
Clears the display, respecting the clip box and background settings.
Interface for objects that can be drawn to an output device.
Definition drawable.h:229
Primary top-level interface for drawing to screens, off-screen buffers, or other devices.
DrawingContext(Display &display, int16_t x_offset, int16_t y_offset)
Constructs a drawing context covering the entire display, with device coordinates offset by the speci...
const Transformation & transformation() const
Returns the current transformation. (The identity transformation by default).
DrawingContext(Display &display)
Constructs a drawing context covering the entire display.
void setBackground(const Rasterizable *bg)
void fill(Color color)
Fills the display with the specified color, respecting the clip box.
void setFillMode(FillMode fill_mode)
const Rasterizable * getBackground() const
const uint16_t width() const
Returns the width of the drawing context. Equivalent to bounds().width().
void setClipBox(int16_t x0, int16_t y0, int16_t x1, int16_t y1)
Sets the clip box, intersected with the maximum allowed clip box. Expressed in device coordinates.
void setTransformation(Transformation t)
Sets a transformation to be applied to all drawn objects when converting the drawing coordinates to d...
void setBackgroundColor(Color bgcolor)
void erase(const Drawable &object)
Analogous to draw(object), but instead of drawing, replaces all the output pixels with the background...
void setClipBox(const Box &clip_box)
Sets the clip box, intersected with the maximum allowed clip box. Expressed in device coordinates.
void draw(const Drawable &object, int16_t dx, int16_t dy)
Draws the object using the specified absolute offset. The point (0, 0) in the object's coordinates ma...
BlendingMode blendingMode() const
Color getBackgroundColor() const
DrawingContext(Display &display, Box bounds)
Constructs a drawing context covering the specified bounds, relative to the display's extents....
void drawPixels(const std::function< void(ClippingBufferedPixelWriter &)> &fn, BlendingMode blending_mode=BlendingMode::kSourceOver)
Allows to efficiently draw pixels to the context, using a buffered pixel writer (avoiding virtual cal...
const Box & getClipBox() const
Returns the current clip box, in device coordinates.
const uint16_t height() const
Returns the height of the drawing context. Equivalent to bounds().height().
const Box & bounds() const
Returns the bounds used for alignment.
void setBlendingMode(BlendingMode blending_mode)
void setClipMask(const ClipMask *clip_mask)
void draw(const Drawable &object, Alignment alignment)
Draws the object applying the specified alignment, relative to the bounds(). For example,...
void draw(const Drawable &object)
Draws the object using its inherent coordinates. The point (0, 0) in the object's coordinates maps to...
FillMode fillMode() const
DrawingContext(Display &display, int16_t x_offset, int16_t y_offset, Box bounds)
Constructs a drawing context covering the specified bounds, with device coordinates offset by the spe...
void clear()
Clears the display, respecting the clip box, and background settings.
Infinite single-color area.
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
bool readColorRect(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax, Color *result) const override
Read colors for a rectangle.
Fill(Color color)
Constructs a fill with a constant color.
void readColors(const int16_t *x, const int16_t *y, uint32_t count, Color *result) const override
Read colors for the given points.
Represents the orientation of a display device.
Definition orientation.h:25
Temporarily pauses the output transport while a DrawingContext is active.
PauseOutput(DisplayOutput &out)
Ends the output transaction on construction.
~PauseOutput()
Restarts the output transaction on destruction.
Drawable that can provide a color for any point within its extents.
Resumes a paused output transaction.
~ResumeOutput()
Ends the output transaction on destruction.
ResumeOutput(DisplayOutput &out)
Begins the output transaction on construction.
Low-level handle used to draw to an underlying device.
Definition drawable.h:60
Touch calibration parameters (bounds + orientation).
Definition calibration.h:10
Touch controller interface.
Definition device.h:428
virtual void initTouch()
Initialize the touch controller.
Definition device.h:433
virtual TouchResult getTouch(TouchPoint *points, int max_points)=0
Read the current touch state.
Wrapper providing calibrated touch input for a display device.
Definition roo_display.h:25
TouchDisplay(DisplayDevice &display_device, TouchDevice &touch_device, TouchCalibration touch_calibration=TouchCalibration())
Constructs a touch display wrapper.
Definition roo_display.h:28
TouchResult getTouch(TouchPoint *points, int max_points)
Returns calibrated touch points in display coordinates.
TouchResult getRawTouch(TouchPoint *points, int max_points)
Returns raw touch points in absolute 0-4095 coordinates.
Definition roo_display.h:41
void setCalibration(TouchCalibration touch_calibration)
Sets the touch calibration mapping.
Definition roo_display.h:46
const TouchCalibration & calibration() const
Returns the current touch calibration.
Definition roo_display.h:51
void init()
Initializes the touch device.
Definition roo_display.h:35
Geometric transformation: swap, scale, translate, rotate, clip.
Box transformBox(Box in) const
Apply the transformation to a box.
bool xy_swap() const
Whether x/y axes are swapped.
bool is_translated() const
Returns true if translation is non-zero.
bool is_rescaled() const
Returns true if scale differs from 1 on any axis.
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.
Definition blending.h:17
@ kSourceOver
Source is placed (alpha-blended) over the destination. This is the default blending mode.
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.
DisplayOutput * out
Definition smooth.cpp:886
Color bgcolor
Definition smooth.cpp:889
FillMode fill_mode
Definition smooth.cpp:887
BlendingMode blending_mode
Definition smooth.cpp:888
A single touch point returned by a touch controller.
Definition device.h:390
Metadata for a touch sampling result.
Definition device.h:415