summaryrefslogtreecommitdiff
path: root/kms++util
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2019-06-17 02:34:29 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-09-05 00:54:49 +0300
commit3d6262d56406e17163deddafbe2b928168784594 (patch)
tree2460283a35f02f1a882199f655f3996604eb4f52 /kms++util
parent70ed259ba057e629ad22ac93168a438dbd93113f (diff)
utils: Add a dump_framebuffer() methodHEADmaster
Add a new method to write the contents of a framebuffer to a file descriptor. This can be used to capture frames from writeback connectors. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'kms++util')
-rw-r--r--kms++util/inc/kms++util/kms++util.h1
-rw-r--r--kms++util/src/drawing.cpp7
2 files changed, 8 insertions, 0 deletions
diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h
index 52b6ce9..0d14c99 100644
--- a/kms++util/inc/kms++util/kms++util.h
+++ b/kms++util/inc/kms++util/kms++util.h
@@ -29,6 +29,7 @@ void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const std::string& str
void draw_color_bar(IFramebuffer& buf, int old_xpos, int xpos, int width);
void draw_test_pattern(IFramebuffer& fb, YUVType yuvt = YUVType::BT601_Lim);
+void dump_framebuffer(IFramebuffer& fb, int fd);
} // namespace kms
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
diff --git a/kms++util/src/drawing.cpp b/kms++util/src/drawing.cpp
index 79e0d90..8d82ca4 100644
--- a/kms++util/src/drawing.cpp
+++ b/kms++util/src/drawing.cpp
@@ -1,5 +1,6 @@
#include <cmath>
+#include <unistd.h>
#include <kms++/kms++.h>
#include <kms++util/kms++util.h>
@@ -554,4 +555,10 @@ void draw_text(IFramebuffer& buf, uint32_t x, uint32_t y, const string& str, RGB
draw_char(buf, (x + 8 * i), y, str[i], color);
}
+void dump_framebuffer(IFramebuffer& fb, int fd)
+{
+ for (unsigned int i = 0; i < fb.num_planes(); ++i)
+ ::write(fd, fb.map(i), fb.size(i));
+}
+
} // namespace kms