summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2ecf1e1)
raw | patch | inline | side by side (parent: 2ecf1e1)
author | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Wed, 25 May 2016 14:30:07 +0000 (17:30 +0300) | ||
committer | Tomi Valkeinen <tomi.valkeinen@ti.com> | |
Wed, 25 May 2016 14:30:07 +0000 (17:30 +0300) |
libkms++util/CMakeLists.txt | patch | blob | history | |
libkms++util/testpat.cpp | patch | blob | history |
index d08ec842ab6e304c19640bc9b098da9a5f24bacc..533b4467b2509529a9aad6153206a9350b2524a7 100644 (file)
file(GLOB SRCS "*.cpp" "*.h")
add_library(kms++util ${SRCS})
-target_link_libraries(kms++util kms++)
+target_link_libraries(kms++util kms++ pthread)
target_include_directories(kms++util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
index cee6e85b4e946b167fb74f910bc4601f3536a692..7a15a35567f1608f8df8bb801ec8d5330c9c00d8 100644 (file)
--- a/libkms++util/testpat.cpp
+++ b/libkms++util/testpat.cpp
#include <chrono>
#include <cstring>
#include <cassert>
+#include <thread>
#include <kms++.h>
#include <kms++util.h>
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+using namespace std;
+
namespace kms
{
static void draw_rgb_pixel(IMappedFramebuffer& buf, unsigned x, unsigned y, RGB color)
@@ -209,11 +212,10 @@ static RGB get_test_pattern_pixel(IMappedFramebuffer& fb, unsigned x, unsigned y
}
}
-static void draw_test_pattern_impl(IMappedFramebuffer& fb)
+static void draw_test_pattern_part(IMappedFramebuffer& fb, unsigned start_y, unsigned end_y)
{
unsigned x, y;
unsigned w = fb.width();
- unsigned h = fb.height();
switch (fb.format()) {
case PixelFormat::XRGB8888:
case PixelFormat::ARGB8888:
case PixelFormat::ABGR8888:
case PixelFormat::RGB565:
- for (y = 0; y < h; y++) {
+ for (y = start_y; y < end_y; y++) {
for (x = 0; x < w; x++) {
RGB pixel = get_test_pattern_pixel(fb, x, y);
draw_rgb_pixel(fb, x, y, pixel);
case PixelFormat::YUYV:
case PixelFormat::YVYU:
case PixelFormat::VYUY:
- for (y = 0; y < h; y++) {
+ for (y = start_y; y < end_y; y++) {
for (x = 0; x < w; x += 2) {
RGB pixel1 = get_test_pattern_pixel(fb, x, y);
RGB pixel2 = get_test_pattern_pixel(fb, x + 1, y);
case PixelFormat::NV12:
case PixelFormat::NV21:
- for (y = 0; y < h; y += 2) {
+ for (y = start_y; y < end_y; y += 2) {
for (x = 0; x < w; x += 2) {
RGB pixel00 = get_test_pattern_pixel(fb, x, y);
RGB pixel10 = get_test_pattern_pixel(fb, x + 1, y);
}
}
+static void draw_test_pattern_impl(IMappedFramebuffer& fb)
+{
+ if (fb.height() < 20) {
+ draw_test_pattern_part(fb, 0, fb.height());
+ return;
+ }
+
+ unsigned num_threads = thread::hardware_concurrency();
+ vector<thread> workers;
+
+ unsigned part = (fb.height() / num_threads) & ~1;
+
+ for (unsigned n = 0; n < num_threads; ++n) {
+ unsigned start = n * part;
+ unsigned end = start + part;
+
+ if (n == num_threads - 1)
+ end = fb.height();
+
+ workers.push_back(thread([&fb, start, end]() { draw_test_pattern_part(fb, start, end); }));
+ }
+
+ for (thread& t : workers)
+ t.join();
+}
+
void draw_test_pattern(IMappedFramebuffer &fb)
{
#ifdef DRAW_PERF_PRINT