summaryrefslogtreecommitdiff
path: root/kms++util/src
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2017-04-12 10:20:16 +0300
committerTomi Valkeinen <tomi.valkeinen@ti.com>2017-05-17 11:04:58 +0300
commit4743ba504270cddaf35ab3629f868d72f5e2abd6 (patch)
treebdc98815662d1e54f1e0195d2a77a577585cea7d /kms++util/src
parentd6f335d09ae883f2c79e0ada948a355093f3825d (diff)
draw_rect: support yuv modes
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Diffstat (limited to 'kms++util/src')
-rw-r--r--kms++util/src/drawing.cpp43
1 files changed, 40 insertions, 3 deletions
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index f8cc03f..fd54940 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -145,10 +145,47 @@ void draw_yuv420_macropixel(IMappedFramebuffer& buf, unsigned x, unsigned y,
void draw_rect(IMappedFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color)
{
- for (unsigned i = x; i < x + w; ++i) {
- for (unsigned j = y; j < y + h; ++j) {
- draw_rgb_pixel(fb, i, j, color);
+ unsigned i, j;
+ YUV yuvcolor = color.yuv();
+
+ switch (fb.format()) {
+ case PixelFormat::XRGB8888:
+ case PixelFormat::XBGR8888:
+ case PixelFormat::ARGB8888:
+ case PixelFormat::ABGR8888:
+ case PixelFormat::RGB888:
+ case PixelFormat::BGR888:
+ case PixelFormat::RGB565:
+ case PixelFormat::BGR565:
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i++) {
+ draw_rgb_pixel(fb, x + i, y + j, color);
+ }
+ }
+ break;
+
+ case PixelFormat::UYVY:
+ case PixelFormat::YUYV:
+ case PixelFormat::YVYU:
+ case PixelFormat::VYUY:
+ for (j = 0; j < h; j++) {
+ for (i = 0; i < w; i += 2) {
+ draw_yuv422_macropixel(fb, x + i, y + j, yuvcolor, yuvcolor);
+ }
+ }
+ break;
+
+ case PixelFormat::NV12:
+ case PixelFormat::NV21:
+ for (j = 0; j < h; j += 2) {
+ for (i = 0; i < w; i += 2) {
+ draw_yuv420_macropixel(fb, x + i, y + j,
+ yuvcolor, yuvcolor, yuvcolor, yuvcolor);
+ }
}
+ break;
+ default:
+ throw std::invalid_argument("unknown pixelformat");
}
}