summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3f0a023)
raw | patch | inline | side by side (parent: 3f0a023)
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Tue, 8 Mar 2016 13:27:27 +0000 (15:27 +0200) | ||
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Tue, 8 Mar 2016 13:42:47 +0000 (15:42 +0200) |
diff --git a/libkmstest/color.cpp b/libkmstest/color.cpp
index 78012ac845adde3428d6e033f6407338c5b40e7c..3ad8203955dd9fa448a1c7f3e757428470b2186e 100644 (file)
--- a/libkmstest/color.cpp
+++ b/libkmstest/color.cpp
}
RGB::RGB(uint8_t r, uint8_t g, uint8_t b)
+ :RGB(255, r, g, b)
+{
+}
+
+RGB::RGB(uint8_t a, uint8_t r, uint8_t g, uint8_t b)
{
this->r = r;
this->g = g;
this->b = b;
- this->a = 255;
+ this->a = a;
+}
+
+RGB::RGB(uint32_t argb)
+{
+ this->b = (argb >> 0) & 0xff;
+ this->g = (argb >> 8) & 0xff;
+ this->r = (argb >> 16) & 0xff;
+ this->a = (argb >> 24) & 0xff;
}
-uint32_t RGB::rgb888() const
+uint32_t RGB::argb8888() const
{
return (a << 24) | (r << 16) | (g << 8) | (b << 0);
}
-uint32_t RGB::bgr888() const
+uint32_t RGB::abgr8888() const
{
return (a << 24) | (b << 16) | (g << 8) | (r << 0);
}
diff --git a/libkmstest/color.h b/libkmstest/color.h
index f84fc689d6c0d28406b6acfac2d55a87977648bb..f99a951de739b6368ee5d180de4138ec94c530d3 100644 (file)
--- a/libkmstest/color.h
+++ b/libkmstest/color.h
{
RGB();
RGB(uint8_t r, uint8_t g, uint8_t b);
+ RGB(uint8_t a, uint8_t r, uint8_t g, uint8_t b);
+ RGB(uint32_t argb);
- uint32_t rgb888() const;
- uint32_t bgr888() const;
+ uint32_t argb8888() const;
+ uint32_t abgr8888() const;
uint16_t rgb565() const;
YUV yuv() const;
- struct
- {
- uint8_t b;
- uint8_t g;
- uint8_t r;
- uint8_t a;
- };
+ uint8_t b;
+ uint8_t g;
+ uint8_t r;
+ uint8_t a;
};
struct YUV
YUV(uint8_t y, uint8_t u, uint8_t v);
YUV(const RGB& rgb);
- struct
- {
- uint8_t v;
- uint8_t u;
- uint8_t y;
- uint8_t a;
- };
+ uint8_t v;
+ uint8_t u;
+ uint8_t y;
+ uint8_t a;
};
}
index c1b6c16588d2656100eec0f0db69d9b7b0da1e6c..811b81ca4f95ea7cecb856c2d78ac9003c6dc160 100644 (file)
--- a/libkmstest/colorbar.cpp
+++ b/libkmstest/colorbar.cpp
}
for (int x = xpos; x < xpos + width; ++x)
- line[x] = bcol.rgb888();
+ line[x] = bcol.argb8888();
}
}
diff --git a/libkmstest/kmstest.h b/libkmstest/kmstest.h
index 0482072920d308c0f69537603f61d51d629498bb..0564ab5a2ab47399bdbaafa8ed7148c1c6948b3b 100644 (file)
--- a/libkmstest/kmstest.h
+++ b/libkmstest/kmstest.h
#pragma once
+#include "color.h"
+
namespace kms
{
class MappedBuffer;
void draw_test_pattern(MappedBuffer& fb);
void draw_test_pattern(DumbFramebuffer &fb);
+
+void draw_rect(MappedBuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color);
+void draw_rect(DumbFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color);
}
diff --git a/libkmstest/testpat.cpp b/libkmstest/testpat.cpp
index 33a4ec1efea5b76529de178c332bbe2d3af31409..059c1bcd2fe067b9b2023f88cf79a6ed0d9a9c62 100644 (file)
--- a/libkmstest/testpat.cpp
+++ b/libkmstest/testpat.cpp
@@ -26,14 +26,14 @@ static void draw_rgb_pixel(MappedBuffer& buf, unsigned x, unsigned y, RGB color)
case PixelFormat::ARGB8888:
{
uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
- *p = color.rgb888();
+ *p = color.argb8888();
break;
}
case PixelFormat::XBGR8888:
case PixelFormat::ABGR8888:
{
uint32_t *p = (uint32_t*)(buf.map(0) + buf.stride(0) * y + x * 4);
- *p = color.bgr888();
+ *p = color.abgr8888();
break;
}
case PixelFormat::RGB565:
printf("draw took %u us\n", (unsigned)time_span.count());
#endif
}
+
+void draw_rect(MappedBuffer &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);
+ }
+ }
+}
+
+void draw_rect(DumbFramebuffer &fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color)
+{
+ MappedDumbBuffer mfb(fb);
+ draw_rect(mfb, x, y, w, h, color);
+}
+
}
diff --git a/py/pykms.i b/py/pykms.i
index d1b6581eb23c1feaf60fda6d0434917a8d4dfefd..080165394c8fcf1fed0c32ccb594c374ed959c44 100644 (file)
--- a/py/pykms.i
+++ b/py/pykms.i
%include "pagefliphandler.h"
%include "videomode.h"
+%include "color.h"
%include "kmstest.h"
%template(ConnectorVector) std::vector<kms::Connector*>;