diff options
Diffstat (limited to 'kms++util')
| -rw-r--r-- | kms++util/inc/kms++util/kms++util.h | 2 | ||||
| -rw-r--r-- | kms++util/src/testpat.cpp | 33 |
2 files changed, 32 insertions, 3 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 |
