| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 3 | |
| 4 | use std::rc::Rc; |
| 5 | |
| 6 | use i_slint_core::platform::PlatformError; |
| 7 | |
| 8 | pub trait SoftwareBufferDisplay { |
| 9 | fn size(&self) -> (u32, u32); |
| 10 | fn map_back_buffer( |
| 11 | &self, |
| 12 | callback: &mut dyn FnMut( |
| 13 | &'_ mut [u8], |
| 14 | u8, |
| 15 | drm::buffer::DrmFourcc, |
| 16 | ) -> Result<(), PlatformError>, |
| 17 | ) -> Result<(), PlatformError>; |
| 18 | fn as_presenter(self: Rc<Self>) -> Rc<dyn super::Presenter>; |
| 19 | } |
| 20 | |
| 21 | mod dumbbuffer; |
| 22 | mod linuxfb; |
| 23 | |
| 24 | pub fn new( |
| 25 | device_opener: &crate::DeviceOpener, |
| 26 | ) -> Result<Rc<dyn SoftwareBufferDisplay>, PlatformError> { |
| 27 | dumbbuffer::DumbBufferDisplay::new(device_opener) |
| 28 | .or_else(|_| linuxfb::LinuxFBDisplay::new(device_opener)) |
| 29 | } |
| 30 | |