summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kms++util/inc/kms++util/kms++util.h2
-rw-r--r--kms++util/src/drawing.cpp7
-rw-r--r--py/pykms/pykmsutil.cpp3
3 files changed, 12 insertions, 0 deletions
diff --git a/kms++util/inc/kms++util/kms++util.h b/kms++util/inc/kms++util/kms++util.h
index f10968d..71a2479 100644
--- a/kms++util/inc/kms++util/kms++util.h
+++ b/kms++util/inc/kms++util/kms++util.h
@@ -40,6 +40,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 = {});
+
+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 df02485..80ff797 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>
@@ -621,4 +622,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
diff --git a/py/pykms/pykmsutil.cpp b/py/pykms/pykmsutil.cpp
index 53717e0..11784b7 100644
--- a/py/pykms/pykmsutil.cpp
+++ b/py/pykms/pykmsutil.cpp
@@ -59,4 +59,7 @@ void init_pykmsutils(py::module& m)
draw_circle(fb, xCenter, yCenter, radius, color);
});
m.def("draw_text", [](Framebuffer& fb, uint32_t x, uint32_t y, const string& str, RGB color) { draw_text(fb, x, y, str, color); });
+ m.def("dump_framebuffer", [](Framebuffer& fb, int fd) {
+ dump_framebuffer(fb, fd);
+ });
}