pykms/pykmsutil.cpp: Add binding for reserve_generic_plane()
[android/external-libkmsxx.git] / py / pykms / pykmsutil.cpp
1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
3 #include <kms++/kms++.h>
4 #include <kms++util/kms++util.h>
6 namespace py = pybind11;
8 using namespace kms;
9 using namespace std;
11 void init_pykmstest(py::module &m)
12 {
13         py::class_<RGB>(m, "RGB")
14                         .def(py::init<>())
15                         .def(py::init<uint8_t, uint8_t, uint8_t&>())
16                         .def(py::init<uint8_t, uint8_t, uint8_t, uint8_t&>())
17                         .def_property_readonly("rgb888", &RGB::rgb888)
18                         .def_property_readonly("argb8888", &RGB::argb8888)
19                         .def_property_readonly("abgr8888", &RGB::abgr8888)
20                         .def_property_readonly("rgb565", &RGB::rgb565)
21                         ;
23         py::class_<ResourceManager>(m, "ResourceManager")
24                         .def(py::init<Card&>())
25                         .def("reset", &ResourceManager::reset)
26                         .def("reserve_connector", (Connector* (ResourceManager::*)(const string& name))&ResourceManager::reserve_connector,
27                              py::arg("name") = string())
28                         .def("reserve_crtc", &ResourceManager::reserve_crtc)
29                         .def("reserve_plane", &ResourceManager::reserve_plane,
30                              py::arg("crtc"),
31                              py::arg("type"),
32                              py::arg("format") = PixelFormat::Undefined)
33                         .def("reserve_generic_plane", &ResourceManager::reserve_generic_plane,
34                              py::arg("crtc"),
35                              py::arg("format") = PixelFormat::Undefined)
36                         .def("reserve_primary_plane", &ResourceManager::reserve_primary_plane,
37                              py::arg("crtc"),
38                              py::arg("format") = PixelFormat::Undefined)
39                         .def("reserve_overlay_plane", &ResourceManager::reserve_overlay_plane,
40                              py::arg("crtc"),
41                              py::arg("format") = PixelFormat::Undefined)
42                         ;
44         // Use lambdas to handle IMappedFramebuffer
45         m.def("draw_test_pattern", [](MappedFramebuffer& fb) { draw_test_pattern(fb); } );
46         m.def("draw_color_bar", [](MappedFramebuffer& fb, int old_xpos, int xpos, int width) {
47                 draw_color_bar(fb, old_xpos, xpos, width);
48         } );
49         m.def("draw_rect", [](MappedFramebuffer& fb, uint32_t x, uint32_t y, uint32_t w, uint32_t h, RGB color) {
50                 draw_rect(fb, x, y, w, h, color);
51         } );
52 }