summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kms++util/inc/kms++util/kms++util.h2
-rw-r--r--kms++util/src/testpat.cpp33
-rw-r--r--utils/kmstest.cpp5
3 files changed, 34 insertions, 6 deletions
diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h
index be06cab..f10968d 100644
--- a/kms++util/inc/kms++util/kms++util.h
+++ b/kms++util/inc/kms++util/kms++util.h
@@ -38,6 +38,8 @@ struct TestPatternOptions {
};
void draw_test_pattern(IFramebuffer& fb, const TestPatternOptions& options = {});
+void draw_vbar_pattern(IFramebuffer& fb, unsigned x, unsigned width,
+ const TestPatternOptions& options = {});
} // namespace kms
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp
index bd0aeb8..24af32e 100644
--- a/kms++util/src/testpat.cpp
+++ b/kms++util/src/testpat.cpp
@@ -1,3 +1,4 @@
+#include <format>
#include <stdexcept>
#include <string>
@@ -9,11 +10,10 @@
namespace kms
{
-void draw_test_pattern(IFramebuffer& fb, const TestPatternOptions& options)
+static void fill_pixpat_buffer(pixpat_buffer& buf, IFramebuffer& fb)
{
const auto& info = get_pixel_format_info(fb.format());
- pixpat_buffer buf{};
buf.format = info.name.c_str();
buf.width = fb.width();
buf.height = fb.height();
@@ -26,8 +26,10 @@ void draw_test_pattern(IFramebuffer& fb, const TestPatternOptions& options)
buf.planes[i] = fb.map(i);
buf.strides[i] = fb.stride(i);
}
+}
- pixpat_pattern_opts popts{};
+static void fill_pattern_opts(pixpat_pattern_opts& popts, const TestPatternOptions& options)
+{
switch (options.rec) {
case RecStandard::BT601: popts.rec = PIXPAT_REC_BT601; break;
case RecStandard::BT709: popts.rec = PIXPAT_REC_BT709; break;
@@ -36,6 +38,15 @@ void draw_test_pattern(IFramebuffer& fb, const TestPatternOptions& options)
popts.range = options.range == ColorRange::Full ? PIXPAT_RANGE_FULL
: PIXPAT_RANGE_LIMITED;
popts.num_threads = 0;
+}
+
+void draw_test_pattern(IFramebuffer& fb, const TestPatternOptions& options)
+{
+ pixpat_buffer buf{};
+ fill_pixpat_buffer(buf, fb);
+
+ pixpat_pattern_opts popts{};
+ fill_pattern_opts(popts, options);
const char* pattern = options.pattern.empty() ? nullptr : options.pattern.c_str();
std::string params;
@@ -66,4 +77,20 @@ void draw_test_pattern(IFramebuffer& fb, const TestPatternOptions& options)
throw std::runtime_error("pixpat_draw_pattern failed");
}
+void draw_vbar_pattern(IFramebuffer& fb, unsigned x, unsigned width,
+ const TestPatternOptions& options)
+{
+ pixpat_buffer buf{};
+ fill_pixpat_buffer(buf, fb);
+
+ pixpat_pattern_opts popts{};
+ fill_pattern_opts(popts, options);
+
+ std::string params = std::format("pos={},width={}", x, width);
+ popts.params = params.c_str();
+
+ if (pixpat_draw_pattern(&buf, "vbar", &popts) != 0)
+ throw std::runtime_error("pixpat_draw_pattern failed");
+}
+
} // namespace kms
diff --git a/utils/kmstest.cpp b/utils/kmstest.cpp
index cc21b92..a5adbe2 100644
--- a/utils/kmstest.cpp
+++ b/utils/kmstest.cpp
@@ -1034,10 +1034,9 @@ private:
static void draw_bar(Framebuffer* fb, unsigned frame_num)
{
- int old_xpos = frame_num < s_num_buffers ? -1 : get_bar_pos(fb, frame_num - s_num_buffers);
- int new_xpos = get_bar_pos(fb, frame_num);
+ unsigned xpos = get_bar_pos(fb, frame_num);
- draw_color_bar(*fb, old_xpos, new_xpos, bar_width);
+ draw_vbar_pattern(*fb, xpos, bar_width);
draw_text(*fb, fb->width() / 2, 0, to_string(frame_num), RGB(255, 255, 255));
}