roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
raster.h
Go to the documentation of this file.
1#pragma once
2
13#include "roo_io/data/byte_order.h"
14#include "roo_io/data/read.h"
15#include "roo_io/memory/load.h"
16#include "roo_io/memory/memory_iterable.h"
17
18namespace roo_display {
19
20/// Stream type produced by a resource iterable.
21template <typename Resource>
22using StreamType = decltype(std::declval<Resource>().iterator());
23
24template <typename ByteStream, typename ColorMode, ColorPixelOrder pixel_order,
25 ByteOrder byte_order,
26 int bytes_per_pixel = ColorTraits<ColorMode>::bytes_per_pixel>
28
29template <typename ByteStream, typename ColorMode, ColorPixelOrder pixel_order,
30 ByteOrder byte_order>
31struct ColorReader<ByteStream, ColorMode, pixel_order, byte_order, 1> {
32 Color operator()(ByteStream& in, const ColorMode& color_mode) const {
33 roo::byte buf[1];
34 in.read(buf, 1);
35 return ColorIo<ColorMode, byte_order>().load(buf, color_mode);
36 }
37};
38
39template <typename ByteStream, typename ColorMode, ColorPixelOrder pixel_order,
40 ByteOrder byte_order>
41struct ColorReader<ByteStream, ColorMode, pixel_order, byte_order, 2> {
42 Color operator()(ByteStream& in, const ColorMode& color_mode) const {
43 roo::byte buf[2];
44 in.read(buf, 2);
45 return ColorIo<ColorMode, byte_order>().load(buf, color_mode);
46 }
47};
48
49template <typename ByteStream, typename ColorMode, ColorPixelOrder pixel_order,
50 ByteOrder byte_order>
51struct ColorReader<ByteStream, ColorMode, pixel_order, byte_order, 3> {
52 Color operator()(ByteStream& in, const ColorMode& color_mode) const {
53 roo::byte buf[3];
54 in.read(buf, 3);
55 return ColorIo<ColorMode, byte_order>().load(buf, color_mode);
56 }
57};
58
59template <typename ByteStream, typename ColorMode, ColorPixelOrder pixel_order,
60 ByteOrder byte_order>
61struct ColorReader<ByteStream, ColorMode, pixel_order, byte_order, 4> {
62 Color operator()(ByteStream& in, const ColorMode& color_mode) const {
63 roo::byte buf[4];
64 in.read(buf, 4);
65 return ColorIo<ColorMode, byte_order>().load(buf, color_mode);
66 }
67};
68
69/// Pixel stream that reads from a raw byte resource.
70///
71/// Default implementation for color modes with multiple pixels per byte.
72/// The resource is interpreted as a non-compressed stream of consecutive
73/// pixels. Line/column semantics are handled by the caller.
74template <typename Resource, typename ColorMode, ColorPixelOrder pixel_order,
75 ByteOrder byte_order,
76 int pixels_per_byte = ColorTraits<ColorMode>::pixels_per_byte>
78 public:
80 : stream_(std::move(stream)),
81 pixel_index_(ColorTraits<ColorMode>::pixels_per_byte),
82 color_mode_(color_mode) {}
83
84 void Read(Color* buf, uint16_t size) override {
85 while (size-- > 0) {
86 *buf++ = next();
87 }
88 }
89
90 void Skip(uint32_t count) override { skip(count); }
91
92 // Advances the iterator to the next pixel in the buffer.
94 if (pixel_index_ == ColorTraits<ColorMode>::pixels_per_byte) {
95 pixel_index_ = 0;
96 fetch();
97 }
98 return cache_[pixel_index_++];
99 }
100
101 void skip(uint32_t count) {
102 uint32_t new_pixel_index = count + pixel_index_;
104 pixel_index_ = new_pixel_index;
105 return;
106 }
109 if (bytes_to_skip > 0) {
110 stream_.skip(bytes_to_skip);
111 }
113 if (pixel_index_ == 0) {
115 } else {
116 fetch();
117 }
118 }
119
120 TransparencyMode transparency() const { return color_mode_.transparency(); }
121
122 const ColorMode& color_mode() const { return color_mode_; }
123
124 private:
125 void fetch() {
127 io.loadBulk(color_mode_, stream_.read(), cache_);
128 }
129
130 StreamType<Resource> stream_;
131 uint8_t pixel_index_;
132 const ColorMode& color_mode_;
133 Color cache_[ColorTraits<ColorMode>::pixels_per_byte];
134};
135
136/// Specialization for color modes with at least one byte per pixel.
137template <typename Resource, typename ColorMode, ColorPixelOrder pixel_order,
138 ByteOrder byte_order>
139class RasterPixelStream<Resource, ColorMode, pixel_order, byte_order, 1>
140 : public PixelStream {
141 public:
143 : stream_(std::move(stream)), color_mode_(color_mode) {}
144
145 void Read(Color* buf, uint16_t size) override {
146 while (size-- > 0) {
147 *buf++ = next();
148 }
149 }
150
151 void Skip(uint32_t count) override { skip(count); }
152
153 // Advances the iterator to the next pixel in the buffer.
155 ColorReader<StreamType<Resource>, ColorMode, pixel_order, byte_order> read;
156 return read(stream_, color_mode_);
157 }
158
159 void skip(uint32_t count) {
160 stream_.skip(count * ColorMode::bits_per_pixel / 8);
161 }
162
163 TransparencyMode transparency() const { return color_mode_.transparency(); }
164
165 const ColorMode& color_mode() const { return color_mode_; }
166
167 private:
168 StreamType<Resource> stream_;
169 const ColorMode& color_mode_;
170};
171
172namespace internal {
173
174// For sub-byte color modes.
175template <typename ColorMode, ColorPixelOrder pixel_order, ByteOrder byte_order,
176 int8_t pixels_per_byte = ColorTraits<ColorMode>::pixels_per_byte,
177 typename storage_type = ColorStorageType<ColorMode>>
178struct Reader {
179 Color operator()(const roo::byte* p, uint32_t offset,
180 const ColorMode& color_mode) const {
181 SubByteColorIo<ColorMode, pixel_order> io;
182 int pixel_index = offset % pixels_per_byte;
183 const roo::byte* target = p + offset / pixels_per_byte;
184 return color_mode.toArgbColor(io.loadRaw(*target, pixel_index));
185 }
186};
187
188// For color modes in which a pixel takes up at least 1 byte.
189template <typename ColorMode, ColorPixelOrder pixel_order, ByteOrder byte_order,
190 typename storage_type>
191struct Reader<ColorMode, pixel_order, byte_order, 1, storage_type> {
192 Color operator()(const roo::byte* p, uint32_t offset,
193 const ColorMode& color_mode) const {
194 const roo::byte* src = p + offset * ColorTraits<ColorMode>::bytes_per_pixel;
195 return ColorIo<ColorMode, byte_order>().load(src, color_mode);
196 }
197};
198
199template <typename PtrTypeT>
200struct PtrTypeResolver {
201 using PtrType = PtrTypeT;
202};
203
204// To accommodate legacy generated raster definitions using uint8_t explicitly.
205template <>
206struct PtrTypeResolver<const uint8_t*> {
207 using PtrType = const roo::byte*;
208};
209
210} // namespace internal
211
212/// Non-owning raster view over a pixel buffer.
213///
214/// The raster representation is small and can be passed by value. Prefer using
215/// `DramRaster`, `ConstDramRaster`, or `ProgMemRaster` aliases instead of this
216/// template directly.
217template <typename PtrTypeT, typename ColorModeT,
219 ByteOrder byte_order = roo_io::kBigEndian>
220class Raster : public Rasterizable {
221 public:
224
227 pixel_order, byte_order>;
228
229 using Reader = internal::Reader<ColorMode, pixel_order, byte_order>;
230
231 /// Construct a raster for a width/height buffer.
233 const ColorMode& color_mode = ColorMode())
234 : Raster(Box(0, 0, width - 1, height - 1),
235 Box(0, 0, width - 1, height - 1), ptr, std::move(color_mode)) {}
236
237 /// Construct a raster with custom extents and buffer dimensions.
239 const ColorMode& color_mode = ColorMode())
240 : Raster(extents, Box(0, 0, width - 1, height - 1), ptr,
241 std::move(color_mode)) {}
242
243 /// Construct a raster with extents and a buffer pointer.
246
247 /// Construct a raster with extents and anchor extents.
249 const ColorMode& color_mode = ColorMode())
250 : extents_(std::move(extents)),
251 anchor_extents_(std::move(anchor_extents)),
252 ptr_((PtrType)ptr),
253 color_mode_(color_mode),
254 width_(extents.width()) {}
255
256 Box extents() const override { return extents_; }
257
258 Box anchorExtents() const override { return anchor_extents_; }
259
260 ColorMode& color_mode() { return color_mode_; }
261 const ColorMode& color_mode() const { return color_mode_; }
262
263 std::unique_ptr<StreamType> createRawStream() const {
264 return std::unique_ptr<StreamType>(new StreamType(
265 roo_io::UnsafeGenericMemoryIterator<PtrType>(ptr_), color_mode_));
266 }
267
268 std::unique_ptr<PixelStream> createStream() const override {
269 return std::unique_ptr<PixelStream>(new StreamType(
270 roo_io::UnsafeGenericMemoryIterator<PtrType>(ptr_), color_mode_));
271 }
272
273 std::unique_ptr<PixelStream> createStream(const Box& bounds) const override {
274 return SubRectangle(
275 StreamType(roo_io::UnsafeGenericMemoryIterator<PtrType>(ptr_),
276 color_mode_),
277 extents(), bounds);
278 }
279
280 void readColors(const int16_t* x, const int16_t* y, uint32_t count,
281 Color* result) const override {
282 Reader read;
283 while (count-- > 0) {
284 *result++ =
285 read(ptr_, *x++ - extents_.xMin() + (*y++ - extents_.yMin()) * width_,
286 color_mode_);
287 }
288 }
289
290 bool readColorRect(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax,
291 Color* result) const override {
292 int16_t rx0 = xMin - extents_.xMin();
293 int16_t ry0 = yMin - extents_.yMin();
294 int16_t rx1 = xMax - extents_.xMin();
295 int16_t ry1 = yMax - extents_.yMin();
296
297 size_t row_width_bytes;
298 if constexpr (ColorTraits<ColorMode>::pixels_per_byte == 1) {
300 static_cast<size_t>(width_) * ColorTraits<ColorMode>::bytes_per_pixel;
301 } else {
303 (static_cast<size_t>(width_) +
306 }
307
309 const roo::byte* data = reinterpret_cast<const roo::byte*>(ptr_);
310 if (io.decodeIfUniform(data, row_width_bytes, rx0, ry0, rx1, ry1, result,
311 color_mode_)) {
312 return true;
313 }
314 io.decode(data, row_width_bytes, rx0, ry0, rx1, ry1, result, color_mode_);
315 return false;
316 }
317
319 return transparency();
320 }
321
322 TransparencyMode transparency() const { return color_mode_.transparency(); }
323
324 Color get(int16_t x, int16_t y) const {
325 Reader read;
326 return read(ptr_, x - extents_.xMin() + (y - extents_.yMin()) * width_,
327 color_mode_);
328 }
329
330 const PtrType buffer() const { return ptr_; }
331
332 private:
333 void drawTo(const Surface& s) const override {
334 Box bounds =
335 Box::Intersect(s.clip_box().translate(-s.dx(), -s.dy()), extents_);
336 if (bounds.empty()) return;
339 bool replace_ok = source_opaque || (s.fill_mode() == FillMode::kExtents &&
340 s.bgcolor().a() == 0);
341 if (replace_ok) {
342 const DisplayOutput::ColorFormat& format = s.out().getColorFormat();
343 // Fast format check: only proceed when format, pixel, and byte order
344 // match.
345 bool format_match =
348 format.pixel_order() == pixel_order &&
349 format.byte_order() == byte_order;
350 if (format_match) {
351 BlendingMode mode = s.blending_mode();
352 // Porter-Duff folding: source-over is source when the source is opaque.
353 bool blend_is_source = mode == BlendingMode::kSource ||
354 ((mode == BlendingMode::kSourceOver ||
357 // When both source and destination are opaque, SOURCE_IN/SOURCE_ATOP
358 // reduce to a straight source copy as well.
361 (mode == BlendingMode::kSourceIn ||
362 mode == BlendingMode::kSourceAtop)) {
363 blend_is_source = true;
364 }
365 if (blend_is_source) {
366 int16_t src_x0 = bounds.xMin() - extents_.xMin();
367 int16_t src_y0 = bounds.yMin() - extents_.yMin();
368 int16_t src_x1 = bounds.xMax() - extents_.xMin();
369 int16_t src_y1 = bounds.yMax() - extents_.yMin();
370 int16_t dst_x0 = bounds.xMin() + s.dx();
371 int16_t dst_y0 = bounds.yMin() + s.dy();
372 size_t row_width_bytes;
373 if constexpr (ColorTraits<ColorMode>::pixels_per_byte == 1) {
374 row_width_bytes = width_ * ColorTraits<ColorMode>::bytes_per_pixel;
375 } else {
376 row_width_bytes =
377 (width_ + ColorTraits<ColorMode>::pixels_per_byte - 1) /
378 ColorTraits<ColorMode>::pixels_per_byte;
379 }
380 s.out().drawDirectRect(ptr_, row_width_bytes, src_x0, src_y0, src_x1,
381 src_y1, dst_x0, dst_y0);
382 return;
383 }
384 }
385 }
386 if (extents_.width() == bounds.width() &&
387 extents_.height() == bounds.height()) {
388 StreamType stream(roo_io::UnsafeGenericMemoryIterator<PtrType>(ptr_),
389 color_mode_);
390 internal::FillRectFromStream(s.out(), bounds.translate(s.dx(), s.dy()),
391 &stream, s.bgcolor(), s.fill_mode(),
392 s.blending_mode(), source_transparency);
393 } else {
394 auto stream = internal::MakeSubRectangle(
395 StreamType(roo_io::UnsafeGenericMemoryIterator<PtrType>(ptr_),
396 color_mode_),
397 extents_, bounds);
398 internal::FillRectFromStream(s.out(), bounds.translate(s.dx(), s.dy()),
399 &stream, s.bgcolor(), s.fill_mode(),
400 s.blending_mode(), source_transparency);
401 }
402 }
403
404 Box extents_;
405 Box anchor_extents_;
406 PtrType ptr_;
407 ColorMode color_mode_;
408 int16_t width_;
409};
410
411template <typename ColorMode,
413 ByteOrder byte_order = roo_io::kBigEndian>
415 : public Raster<roo::byte*, ColorMode, pixel_order, byte_order> {
416 public:
417 using Raster<roo::byte*, ColorMode, pixel_order, byte_order>::Raster;
418
420 const ColorMode& color_mode = ColorMode())
421 : Raster<roo::byte*, ColorMode, pixel_order, byte_order>(
422 width, height, (roo::byte*)ptr, color_mode) {}
423
425 const ColorMode& color_mode = ColorMode())
426 : Raster<roo::byte*, ColorMode, pixel_order, byte_order>(
427 width, height, std::move(extents), (roo::byte*)ptr, color_mode) {}
428
430 const ColorMode& color_mode = ColorMode())
431 : Raster<roo::byte*, ColorMode, pixel_order, byte_order>(
432 std::move(extents), extents, (roo::byte*)ptr, color_mode) {}
433
435 const ColorMode& color_mode = ColorMode())
436 : Raster<roo::byte*, ColorMode, pixel_order, byte_order>(
437 std::move(extents), std::move(anchor_extents), (roo::byte*)ptr,
438 color_mode) {}
439};
440
441template <typename ColorMode,
443 ByteOrder byte_order = roo_io::kBigEndian>
445 : public Raster<const roo::byte*, ColorMode, pixel_order, byte_order> {
446 public:
447 using Raster<const roo::byte*, ColorMode, pixel_order, byte_order>::Raster;
448
450 const ColorMode& color_mode = ColorMode())
451 : Raster<const roo::byte*, ColorMode, pixel_order, byte_order>(
452 width, height, (const roo::byte*)ptr, color_mode) {}
453
455 const uint8_t* ptr, const ColorMode& color_mode = ColorMode())
456 : Raster<const roo::byte*, ColorMode, pixel_order, byte_order>(
457 width, height, std::move(extents), (const roo::byte*)ptr,
458 color_mode) {}
459
461 const ColorMode& color_mode = ColorMode())
462 : Raster<const roo::byte*, ColorMode, pixel_order, byte_order>(
464
466 const ColorMode& color_mode = ColorMode())
467 : Raster<const roo::byte*, ColorMode, pixel_order, byte_order>(
468 std::move(extents), std::move(anchor_extents),
469 (const roo::byte*)ptr, color_mode) {}
470};
471
472template <typename ColorMode,
474 ByteOrder byte_order = roo_io::kBigEndian>
475class ProgMemRaster : public Raster<const roo::byte * PROGMEM, ColorMode,
476 pixel_order, byte_order> {
477 public:
478 using Raster<const roo::byte * PROGMEM, ColorMode, pixel_order,
479 byte_order>::Raster;
480
482 const ColorMode& color_mode = ColorMode())
483 : Raster<const roo::byte * PROGMEM, ColorMode, pixel_order, byte_order>(
484 width, height, (const roo::byte*)ptr, color_mode) {}
485
487 const uint8_t* PROGMEM ptr,
488 const ColorMode& color_mode = ColorMode())
489 : Raster<const roo::byte * PROGMEM, ColorMode, pixel_order, byte_order>(
490 width, height, std::move(extents), (const roo::byte*)ptr,
491 color_mode) {}
492
494 const ColorMode& color_mode = ColorMode())
495 : Raster<const roo::byte * PROGMEM, ColorMode, pixel_order, byte_order>(
497
499 const ColorMode& color_mode = ColorMode())
500 : Raster<const roo::byte * PROGMEM, ColorMode, pixel_order, byte_order>(
501 std::move(extents), std::move(anchor_extents),
502 (const roo::byte*)ptr, color_mode) {}
503};
504
505template <typename ColorMode>
508
509template <typename ColorMode>
512
513template <typename ColorMode>
516
517template <typename ColorMode>
520 roo_io::kLittleEndian>;
521
522template <typename ColorMode>
525
526template <typename ColorMode>
528 roo_io::kLittleEndian>;
529
530} // namespace roo_display
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 xMax() const
Maximum x (inclusive).
Definition box.h:71
bool empty() const
Return whether the box is empty.
Definition box.h:62
int16_t height() const
Height in pixels (inclusive coordinates).
Definition box.h:80
Box translate(int16_t x_offset, int16_t y_offset) const
Return a translated copy of this box.
Definition box.h:127
int16_t yMax() const
Maximum y (inclusive).
Definition box.h:74
static Box Intersect(const Box &a, const Box &b)
Return the intersection of two boxes (may be empty).
Definition box.h:25
int16_t yMin() const
Minimum y (inclusive).
Definition box.h:68
ARGB8888 color stored as a 32-bit unsigned integer.
Definition color.h:16
ConstDramRaster(int16_t width, int16_t height, Box extents, const uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:454
ConstDramRaster(Box extents, Box anchor_extents, const uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:465
ConstDramRaster(int16_t width, int16_t height, const uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:449
ConstDramRaster(Box extents, const uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:460
TransparencyMode transparency() const
Definition device.h:355
ColorPixelOrder pixel_order() const
Definition device.h:353
roo_io::ByteOrder byte_order() const
Definition device.h:351
virtual void drawDirectRect(const roo::byte *data, size_t row_width_bytes, int16_t src_x0, int16_t src_y0, int16_t src_x1, int16_t src_y1, int16_t dst_x0, int16_t dst_y0)
Draw a rectangle represented in the device's native color format.
Definition device.cpp:33
DramRaster(Box extents, Box anchor_extents, uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:434
DramRaster(Box extents, uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:429
DramRaster(int16_t width, int16_t height, Box extents, uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:424
DramRaster(int16_t width, int16_t height, uint8_t *ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:419
Stream of pixels in row-major order.
Definition streamable.h:12
ProgMemRaster(Box extents, Box anchor_extents, const uint8_t *PROGMEM ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:498
ProgMemRaster(int16_t width, int16_t height, Box extents, const uint8_t *PROGMEM ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:486
ProgMemRaster(int16_t width, int16_t height, const uint8_t *PROGMEM ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:481
ProgMemRaster(Box extents, const uint8_t *PROGMEM ptr, const ColorMode &color_mode=ColorMode())
Definition raster.h:493
void Read(Color *buf, uint16_t size) override
Read up to size pixels into buf.
Definition raster.h:145
RasterPixelStream(StreamType< Resource > stream, const ColorMode &color_mode)
Definition raster.h:142
Pixel stream that reads from a raw byte resource.
Definition raster.h:77
void Read(Color *buf, uint16_t size) override
Read up to size pixels into buf.
Definition raster.h:84
const ColorMode & color_mode() const
Definition raster.h:122
RasterPixelStream(StreamType< Resource > stream, const ColorMode &color_mode)
Definition raster.h:79
void Skip(uint32_t count) override
Skip count pixels.
Definition raster.h:90
TransparencyMode transparency() const
Definition raster.h:120
void skip(uint32_t count)
Definition raster.h:101
Non-owning raster view over a pixel buffer.
Definition raster.h:220
void readColors(const int16_t *x, const int16_t *y, uint32_t count, Color *result) const override
Read colors for the given points.
Definition raster.h:280
bool readColorRect(int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax, Color *result) const override
Read colors for a rectangle.
Definition raster.h:290
typename internal::PtrTypeResolver< PtrTypeT >::PtrType PtrType
Definition raster.h:223
Box anchorExtents() const override
Return the bounds used for alignment.
Definition raster.h:258
std::unique_ptr< PixelStream > createStream() const override
Create a stream covering the full extents().
Definition raster.h:268
TransparencyMode transparency() const
Definition raster.h:322
Raster(int16_t width, int16_t height, Box extents, PtrTypeT ptr, const ColorMode &color_mode=ColorMode())
Construct a raster with custom extents and buffer dimensions.
Definition raster.h:238
TransparencyMode getTransparencyMode() const override
Return the transparency mode for pixels in this stream.
Definition raster.h:318
Raster(int16_t width, int16_t height, PtrTypeT ptr, const ColorMode &color_mode=ColorMode())
Construct a raster for a width/height buffer.
Definition raster.h:232
ColorModeT ColorMode
Definition raster.h:222
Box extents() const override
Return the bounding box encompassing all pixels that need to be drawn.
Definition raster.h:256
ColorMode & color_mode()
Definition raster.h:260
internal::Reader< ColorMode, pixel_order, byte_order > Reader
Definition raster.h:229
std::unique_ptr< PixelStream > createStream(const Box &bounds) const override
Create a stream for the given clipped bounds.
Definition raster.h:273
Color get(int16_t x, int16_t y) const
Definition raster.h:324
RasterPixelStream< roo_io::UnsafeGenericMemoryIterable< PtrType >, ColorMode, pixel_order, byte_order > StreamType
Definition raster.h:227
const PtrType buffer() const
Definition raster.h:330
Raster(Box extents, PtrTypeT ptr, const ColorMode &color_mode=ColorMode())
Construct a raster with extents and a buffer pointer.
Definition raster.h:244
const ColorMode & color_mode() const
Definition raster.h:261
std::unique_ptr< StreamType > createRawStream() const
Definition raster.h:263
Raster(Box extents, Box anchor_extents, PtrTypeT ptr, const ColorMode &color_mode=ColorMode())
Construct a raster with extents and anchor extents.
Definition raster.h:248
Drawable that can provide a color for any point within its extents.
Low-level handle used to draw to an underlying device.
Definition drawable.h:60
int16_t dy() const
Return the y offset to apply to drawn objects.
Definition drawable.h:128
Color bgcolor() const
Return the background color used for blending.
Definition drawable.h:140
int16_t dx() const
Return the x offset to apply to drawn objects.
Definition drawable.h:125
BlendingMode blending_mode() const
Return the default blending mode for drawing.
Definition drawable.h:162
FillMode fill_mode() const
Return the fill mode the drawable should observe. FillMode::kVisible If FillMode::kExtents,...
Definition drawable.h:151
DisplayOutput & out() const
Return the device output.
Definition drawable.h:119
SubRectangleStream< Stream > MakeSubRectangle(Stream stream, const Box &extents, const Box &bounds)
Definition streamable.h:392
void FillRectFromStream(DisplayOutput &output, const Box &extents, PixelStream *stream, Color bgcolor, FillMode fill_mode, BlendingMode blending_mode, TransparencyMode transparency)
Definition streamable.h:156
Defines 140 opaque HTML named colors.
BlendingMode
Porter-Duff style blending modes.
Definition blending.h:17
@ kSourceOverOpaque
Similar to kSourceOver, but assumes that the destination is opaque.
@ kSource
The new ARGB8888 value completely replaces the old one.
@ kSourceIn
The source that overlaps the destination, replaces the destination.
@ kSourceAtop
Source which overlaps the destination, replaces the destination. Destination is placed elsewhere.
@ kSourceOver
Source is placed (alpha-blended) over the destination. This is the default blending mode.
decltype(std::declval< Resource >().iterator()) StreamType
Stream type produced by a resource iterable.
Definition raster.h:22
TransparencyMode
Transparency information for a stream or color mode.
Definition blending.h:103
@ kNone
All colors are fully opaque.
std::unique_ptr< PixelStream > SubRectangle(Stream stream, const Box &extents, const Box &bounds)
Create a pixel stream over a sub-rectangle of a larger stream.
Definition streamable.h:408
static const uint8_t font[] PROGMEM
@ kExtents
Fill the entire extents box (possibly with fully transparent pixels).
roo_io::ByteOrder ByteOrder
Definition byte_order.h:7
Color operator()(ByteStream &in, const ColorMode &color_mode) const
Definition raster.h:32
Color operator()(ByteStream &in, const ColorMode &color_mode) const
Definition raster.h:42
Color operator()(ByteStream &in, const ColorMode &color_mode) const
Definition raster.h:52
Color operator()(ByteStream &in, const ColorMode &color_mode) const
Definition raster.h:62
Traits for a color mode's storage characteristics.
Definition traits.h:9
#define const
Definition zconf.h:230