diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2026-05-08 12:27:46 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2026-05-08 17:25:59 +0300 |
| commit | 6c7a9ada6113ea1f71bbc6780892fb3cb8c3ba3b (patch) | |
| tree | 8fb6f2370d95f204d7585713aa71e0610f97728b /kms++util/src | |
| parent | 549c347d6feb2e94a810a720c97a8bf0f57317a1 (diff) | |
kmstest: Use pixpat vbar for the moving flip bar
Replace the hand-rolled draw_color_bar call in FlipState::draw_bar with
pixpat's "vbar" pattern via a new draw_vbar_pattern helper in kms++util.
The pattern fills the full buffer, so the old_xpos bookkeeping for
clearing the previous bar is no longer needed.
Diffstat (limited to 'kms++util/src')
| -rw-r--r-- | kms++util/src/testpat.cpp | 33 |
1 files changed, 30 insertions, 3 deletions
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 |
