py: Framebuffer: Add flush and __repr__
authorNoralf Trønnes <noralf@tronnes.org>
Mon, 19 Jul 2021 16:17:54 +0000 (18:17 +0200)
committerNoralf Trønnes <noralf@tronnes.org>
Mon, 19 Jul 2021 16:26:43 +0000 (18:26 +0200)
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
py/pykms/pykmsbase.cpp

index 382ef6f..b3ada1b 100644 (file)
@@ -148,6 +148,9 @@ void init_pykmsbase(py::module& m)
                .def("offset", &Framebuffer::offset)
                .def("fd", &Framebuffer::prime_fd)
 
+               .def("flush", (void (Framebuffer::*)(void)) & Framebuffer::flush)
+               .def("flush", (void (Framebuffer::*)(uint32_t x, uint32_t y, uint32_t width, uint32_t height)) & Framebuffer::flush)
+
                // XXX pybind11 doesn't support a base object (DrmObject) with custom holder-type,
                // and a subclass with standard holder-type.
                // So we just copy the DrmObject members here.
@@ -161,6 +164,7 @@ void init_pykmsbase(py::module& m)
                     py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
                .def(py::init<Card&, uint32_t, uint32_t, PixelFormat>(),
                     py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
+               .def("__repr__", [](const DumbFramebuffer& o) { return "<pykms.DumbFramebuffer " + to_string(o.id()) + ">"; })
                ;
 
        py::class_<DmabufFramebuffer, Framebuffer>(m, "DmabufFramebuffer")
@@ -168,6 +172,7 @@ void init_pykmsbase(py::module& m)
                     py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
                .def(py::init<Card&, uint32_t, uint32_t, PixelFormat, vector<int>, vector<uint32_t>, vector<uint32_t>>(),
                     py::keep_alive<1, 2>()) // Keep Card alive until this is destructed
+               .def("__repr__", [](const DmabufFramebuffer& o) { return "<pykms.DmabufFramebuffer " + to_string(o.id()) + ">"; })
                ;
 
        py::enum_<PixelFormat>(m, "PixelFormat")