2#include "TinyGPU/Surface/ISurface.h"
3#include "TinyGPU/Surface/SurfaceBase.h"
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52template <
typename RGB_T =
RGB565>
59 WindowedSurface(ISurface<RGB_T>& backing, int32_t offsetX, int32_t offsetY, size_t fullWidth,
60 size_t fullHeight,
IFont<RGB_T>& font)
61 :
SurfaceBase<RGB_T>(
static_cast<size_t>(offsetX) + backing.width(),
62 static_cast<size_t>(offsetY) + backing.height(), font),
75 void setPixel(size_t x, size_t y, RGB_T color)
override {
76 const long bx =
static_cast<
long>(x) - offsetX_;
77 const long by =
static_cast<
long>(y) - offsetY_;
78 if (bx < 0 || by < 0)
return;
79 if (
static_cast<size_t>(bx) >= backing_.width() ||
static_cast<size_t>(by) >= backing_.height()) {
82 backing_.setPixel(
static_cast<size_t>(bx),
static_cast<size_t>(by), color);
85 RGB_T
getPixel(size_t x, size_t y)
const override {
86 const long bx =
static_cast<
long>(x) - offsetX_;
87 const long by =
static_cast<
long>(y) - offsetY_;
88 if (bx < 0 || by < 0)
return RGB_T();
89 if (
static_cast<size_t>(bx) >= backing_.width() ||
static_cast<size_t>(by) >= backing_.height()) {
92 return backing_.getPixel(
static_cast<size_t>(bx),
static_cast<size_t>(by));
104 const uint8_t*
data()
const override {
return nullptr; }
114 return x < SurfaceBase<RGB_T>::width_ && y < SurfaceBase<RGB_T>::height_ &&
115 this->isClipVisible(x, y);
119 ISurface<RGB_T>& backing_;
Font rendering interface for TinyGPU-compatible framebuffers.
Definition: IFont.h:19
RGB color stored in 16-bit RGB565 format, byte-swapped from the conventional bit layout.
Definition: RGB565.h:24
Base class for 2D surfaces with drawing and text rendering support.
Definition: SurfaceBase.h:25
An ISurface that reports a full width x height extent but physically redirects every pixel write into...
Definition: WindowedSurface.h:53
bool contains(size_t x, size_t y) override
Definition: WindowedSurface.h:113
WindowedSurface(ISurface< RGB_T > &backing, int32_t offsetX, int32_t offsetY, size_t fullWidth, size_t fullHeight, IFont< RGB_T > &font)
Definition: WindowedSurface.h:59
size_t height() const override
Get the height of the surface.
Definition: WindowedSurface.h:73
const uint8_t * data() const override
Definition: WindowedSurface.h:104
bool resizeBuffer(size_t, size_t) override
Definition: WindowedSurface.h:98
size_t width() const override
Definition: WindowedSurface.h:72
void setPixel(size_t x, size_t y, RGB_T color) override
Definition: WindowedSurface.h:75
size_t size() const override
Provides the total data size in bytes.
Definition: WindowedSurface.h:105
RGB_T getPixel(size_t x, size_t y) const override
Abstract method: get the pixel color at (x, y).
Definition: WindowedSurface.h:85
Definition: DSIBusESP32.h:19