summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: eafc32e)
raw | patch | inline | side by side (parent: eafc32e)
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Tue, 9 Jan 2018 10:50:29 +0000 (12:50 +0200) | ||
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Tue, 9 Jan 2018 10:53:17 +0000 (12:53 +0200) |
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
kms++util/src/drawing.cpp | patch | blob | history |
index a187dc08409541110717da327506aa40453d7df2..4e5c6c1fe8ac83dbaca9dc3e48f4f96764315ef9 100644 (file)
{
void draw_rgb_pixel(IFramebuffer& buf, unsigned x, unsigned y, RGB color)
{
+ if (x >= buf.width() || y >= buf.height())
+ throw runtime_error("attempt to draw outside the buffer");
+
switch (buf.format()) {
case PixelFormat::XRGB8888:
case PixelFormat::ARGB8888:
void draw_yuv422_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1, YUV yuv2)
{
+ if ((x + 1) >= buf.width() || y >= buf.height())
+ throw runtime_error("attempt to draw outside the buffer");
+
ASSERT((x & 1) == 0);
uint8_t *p = (uint8_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
@@ -104,6 +110,9 @@ void draw_yuv422_macropixel(IFramebuffer& buf, unsigned x, unsigned y, YUV yuv1,
void draw_yuv420_macropixel(IFramebuffer& buf, unsigned x, unsigned y,
YUV yuv1, YUV yuv2, YUV yuv3, YUV yuv4)
{
+ if ((x + 1) >= buf.width() || (y + 1) >= buf.height())
+ throw runtime_error("attempt to draw outside the buffer");
+
ASSERT((x & 1) == 0);
ASSERT((y & 1) == 0);