]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android/external-libkmsxx.git/commitdiff
Add BGR888 (BG24) and BGR565 (BG16) pixelformats.
authorJyri Sarha <jsarha@ti.com>
Wed, 10 Aug 2016 20:16:39 +0000 (23:16 +0300)
committerJyri Sarha <jsarha@ti.com>
Thu, 11 Aug 2016 09:20:29 +0000 (12:20 +0300)
Note colorbar does not support 24 bit modes (RGB888 or BGR888) yet.

kms++/inc/kms++/pixelformats.h
kms++/src/pixelformats.cpp
kms++util/inc/kms++util/color.h
kms++util/src/color.cpp
kms++util/src/colorbar.cpp
kms++util/src/drawing.cpp

index 8ecfcb3c3f2b79ac25e9b6fba5cc4e259e8fc194..6392de1be9fd9544daf3180d380d9516ef3d872a 100644 (file)
@@ -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)
index ee2356debfa64afedf616250bcce9a77809174a4..84ea924a8ce2a04c2345b30c41bdcb0d6d5ba498 100644 (file)
@@ -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 } }, } },
index ef85a674eada429127383e15c7e4448a860c5771..ba2ed252a4eb6e359e79a113862ede912f83ffc8 100644 (file)
@@ -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;
index 4bfc33e0a170dcc6c599da3851a8946a747e7bc7..ae8a4b4421644ded30e5fcb014870723f981afaa 100644 (file)
@@ -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);
index bca8dc6c57a3a0b71eab90f378382e0b0d4b000b..e2d257b2cbcc380f8c611861395a910019e7f998 100644 (file)
@@ -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;
index 157c7994faf095f8728a6725467153e065f87aee..44634e170683d6a68bf7fc66dc2e5b719d4e98f2 100644 (file)
@@ -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);