summaryrefslogtreecommitdiffstats
path: root/minui/graphics_fbdev.h
diff options
context:
space:
mode:
Diffstat (limited to 'minui/graphics_fbdev.h')
-rw-r--r--minui/graphics_fbdev.h49
1 files changed, 38 insertions, 11 deletions
diff --git a/minui/graphics_fbdev.h b/minui/graphics_fbdev.h
index 107e19567..596ba74ea 100644
--- a/minui/graphics_fbdev.h
+++ b/minui/graphics_fbdev.h
@@ -14,31 +14,58 @@
* limitations under the License.
*/
-#ifndef _GRAPHICS_FBDEV_H_
-#define _GRAPHICS_FBDEV_H_
+#pragma once
#include <linux/fb.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <memory>
+#include <vector>
+
+#include <android-base/unique_fd.h>
#include "graphics.h"
#include "minui/minui.h"
+class GRSurfaceFbdev : public GRSurface {
+ public:
+ // Creates and returns a GRSurfaceFbdev instance, or nullptr on error.
+ static std::unique_ptr<GRSurfaceFbdev> Create(size_t width, size_t height, size_t row_bytes,
+ size_t pixel_bytes);
+
+ uint8_t* data() override {
+ return buffer_;
+ }
+
+ protected:
+ using GRSurface::GRSurface;
+
+ private:
+ friend class MinuiBackendFbdev;
+
+ // Points to the start of the buffer: either the mmap'd framebuffer or one allocated in-memory.
+ uint8_t* buffer_{ nullptr };
+};
+
class MinuiBackendFbdev : public MinuiBackend {
public:
+ MinuiBackendFbdev() = default;
+ ~MinuiBackendFbdev() override = default;
+
GRSurface* Init() override;
GRSurface* Flip() override;
void Blank(bool) override;
- ~MinuiBackendFbdev() override;
- MinuiBackendFbdev();
private:
- void SetDisplayedFramebuffer(unsigned n);
+ void SetDisplayedFramebuffer(size_t n);
- GRSurface gr_framebuffer[2];
+ std::unique_ptr<GRSurfaceFbdev> gr_framebuffer[2];
+ // Points to the current surface (i.e. one of the two gr_framebuffer's).
+ GRSurfaceFbdev* gr_draw{ nullptr };
bool double_buffered;
- GRSurface* gr_draw;
- int displayed_buffer;
+ std::vector<uint8_t> memory_buffer;
+ size_t displayed_buffer{ 0 };
fb_var_screeninfo vi;
- int fb_fd;
+ android::base::unique_fd fb_fd;
};
-
-#endif // _GRAPHICS_FBDEV_H_