summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJyri Sarha <jsarha@ti.com>2016-08-10 23:16:39 +0300
committerJyri Sarha <jsarha@ti.com>2016-08-11 12:20:29 +0300
commit3788242e4fdc57b1421b4721120477ebb2298e52 (patch)
treec2b0c7fe512daaee254859fa530bafd5972a9796
parentbd5f6471e619a6ba2987bc7f66ef78a531f94d6c (diff)
Add BGR888 (BG24) and BGR565 (BG16) pixelformats.
Note colorbar does not support 24 bit modes (RGB888 or BGR888) yet.
-rw-r--r--kms++/inc/kms++/pixelformats.h2
-rw-r--r--kms++/src/pixelformats.cpp2
-rw-r--r--kms++util/inc/kms++util/color.h2
-rw-r--r--kms++util/src/color.cpp10
-rw-r--r--kms++util/src/colorbar.cpp5
-rw-r--r--kms++util/src/drawing.cpp16
6 files changed, 37 insertions, 0 deletions
diff --git a/kms++/inc/kms++/pixelformats.h b/kms++/inc/kms++/pixelformats.h
index 8ecfcb3..6392de1 100644
--- a/kms++/inc/kms++/pixelformats.h
+++ b/kms++/inc/kms++/pixelformats.h
@@ -28,8 +28,10 @@ enum class PixelFormat : uint32_t
ABGR8888 = MakeFourCC("AB24"),
RGB888 = MakeFourCC("RG24"),
+ BGR888 = MakeFourCC("BG24"),
RGB565 = MakeFourCC("RG16"),
+ BGR565 = MakeFourCC("BG16"),
};
static inline PixelFormat FourCCToPixelFormat(const std::string& fourcc)
diff --git a/kms++/src/pixelformats.cpp b/kms++/src/pixelformats.cpp
index ee2356d..84ea924 100644
--- a/kms++/src/pixelformats.cpp
+++ b/kms++/src/pixelformats.cpp
@@ -17,8 +17,10 @@ static const map<PixelFormat, PixelFormatInfo> format_info_array = {
{ PixelFormat::NV21, { 2, { { 8, 1, 1, }, { 8, 2, 2 } }, } },
/* RGB16 */
{ PixelFormat::RGB565, { 1, { { 16, 1, 1 } }, } },
+ { PixelFormat::BGR565, { 1, { { 16, 1, 1 } }, } },
/* RGB24 */
{ PixelFormat::RGB888, { 1, { { 24, 1, 1 } }, } },
+ { PixelFormat::BGR888, { 1, { { 24, 1, 1 } }, } },
/* RGB32 */
{ PixelFormat::XRGB8888, { 1, { { 32, 1, 1 } }, } },
{ PixelFormat::XBGR8888, { 1, { { 32, 1, 1 } }, } },
diff --git a/kms++util/inc/kms++util/color.h b/kms++util/inc/kms++util/color.h
index ef85a67..ba2ed25 100644
--- a/kms++util/inc/kms++util/color.h
+++ b/kms++util/inc/kms++util/color.h
@@ -14,9 +14,11 @@ struct RGB
RGB(uint32_t argb);
uint32_t rgb888() const;
+ uint32_t bgr888() const;
uint32_t argb8888() const;
uint32_t abgr8888() const;
uint16_t rgb565() const;
+ uint16_t bgr565() const;
YUV yuv() const;
uint8_t b;
diff --git a/kms++util/src/color.cpp b/kms++util/src/color.cpp
index 4bfc33e..ae8a4b4 100644
--- a/kms++util/src/color.cpp
+++ b/kms++util/src/color.cpp
@@ -34,6 +34,11 @@ uint32_t RGB::rgb888() const
return (r << 16) | (g << 8) | (b << 0);
}
+uint32_t RGB::bgr888() const
+{
+ return (b << 16) | (g << 8) | (r << 0);
+}
+
uint32_t RGB::argb8888() const
{
return (a << 24) | (r << 16) | (g << 8) | (b << 0);
@@ -49,6 +54,11 @@ uint16_t RGB::rgb565() const
return ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0);
}
+uint16_t RGB::bgr565() const
+{
+ return ((b >> 3) << 11) | ((g >> 2) << 5) | ((r >> 3) << 0);
+}
+
YUV RGB::yuv() const
{
return YUV(*this);
diff --git a/kms++util/src/colorbar.cpp b/kms++util/src/colorbar.cpp
index bca8dc6..e2d257b 100644
--- a/kms++util/src/colorbar.cpp
+++ b/kms++util/src/colorbar.cpp
@@ -116,6 +116,11 @@ void draw_color_bar(IMappedFramebuffer& buf, int old_xpos, int xpos, int width)
drm_draw_color_bar_rgb565(buf, old_xpos, xpos, width);
break;
+ case PixelFormat::BGR565:
+ // XXX not right, red and blue are reversed
+ drm_draw_color_bar_rgb565(buf, old_xpos, xpos, width);
+ break;
+
case PixelFormat::XRGB8888:
drm_draw_color_bar_rgb888(buf, old_xpos, xpos, width);
break;
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 157c799..44634e1 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -31,12 +31,26 @@ void draw_rgb_pixel(IMappedFramebuffer& buf, unsigned x, unsigned y, RGB color)
p[2] = color.b;
break;
}
+ case PixelFormat::BGR888:
+ {
+ uint8_t *p = buf.map(0) + buf.stride(0) * y + x * 3;
+ p[0] = color.b;
+ p[1] = color.g;
+ p[2] = color.r;
+ break;
+ }
case PixelFormat::RGB565:
{
uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
*p = color.rgb565();
break;
}
+ case PixelFormat::BGR565:
+ {
+ uint16_t *p = (uint16_t*)(buf.map(0) + buf.stride(0) * y + x * 2);
+ *p = color.bgr565();
+ break;
+ }
default:
throw std::invalid_argument("invalid pixelformat");
}
@@ -159,7 +173,9 @@ static void draw_char(IMappedFramebuffer& buf, uint32_t xpos, uint32_t ypos, cha
case PixelFormat::ARGB8888:
case PixelFormat::ABGR8888:
case PixelFormat::RGB888:
+ case PixelFormat::BGR888:
case PixelFormat::RGB565:
+ case PixelFormat::BGR565:
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
bool b = get_char_pixel(c, x, y);