summaryrefslogtreecommitdiffstats
path: root/minui/graphics_drm.h
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-10-25 04:36:21 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-10-25 04:36:21 +0200
commit769159d404566a468995af705b29e6444b992489 (patch)
treed9f15aa1ab79d6937523e40384fa2b50e65b529d /minui/graphics_drm.h
parent[automerger skipped] Merge pie-platform-release to aosp-master - DO NOT MERGE am: 0db98fa501 -s ours am: 5168a610d2 -s ours (diff)
parentMerge "minui: Cleanup GRSurfaceDrm and MinuiBackendDrm." am: c17c819693 (diff)
downloadandroid_bootable_recovery-769159d404566a468995af705b29e6444b992489.tar
android_bootable_recovery-769159d404566a468995af705b29e6444b992489.tar.gz
android_bootable_recovery-769159d404566a468995af705b29e6444b992489.tar.bz2
android_bootable_recovery-769159d404566a468995af705b29e6444b992489.tar.lz
android_bootable_recovery-769159d404566a468995af705b29e6444b992489.tar.xz
android_bootable_recovery-769159d404566a468995af705b29e6444b992489.tar.zst
android_bootable_recovery-769159d404566a468995af705b29e6444b992489.zip
Diffstat (limited to 'minui/graphics_drm.h')
-rw-r--r--minui/graphics_drm.h36
1 files changed, 24 insertions, 12 deletions
diff --git a/minui/graphics_drm.h b/minui/graphics_drm.h
index f3aad6bfc..02db89f05 100644
--- a/minui/graphics_drm.h
+++ b/minui/graphics_drm.h
@@ -18,6 +18,9 @@
#include <stdint.h>
+#include <memory>
+
+#include <android-base/macros.h>
#include <xf86drmMode.h>
#include "graphics.h"
@@ -25,6 +28,12 @@
class GRSurfaceDrm : public GRSurface {
public:
+ explicit GRSurfaceDrm(int drm_fd) : drm_fd_(drm_fd) {}
+ ~GRSurfaceDrm() override;
+
+ // Creates a GRSurfaceDrm instance.
+ static std::unique_ptr<GRSurfaceDrm> Create(int drm_fd, int width, int height);
+
uint8_t* data() override {
return mmapped_buffer_;
}
@@ -32,30 +41,33 @@ class GRSurfaceDrm : public GRSurface {
private:
friend class MinuiBackendDrm;
- uint32_t fb_id;
- uint32_t handle;
+ const int drm_fd_;
+
+ uint32_t fb_id{ 0 };
+ uint32_t handle{ 0 };
uint8_t* mmapped_buffer_{ nullptr };
+
+ DISALLOW_COPY_AND_ASSIGN(GRSurfaceDrm);
};
class MinuiBackendDrm : public MinuiBackend {
public:
+ MinuiBackendDrm() = default;
+ ~MinuiBackendDrm() override;
+
GRSurface* Init() override;
GRSurface* Flip() override;
void Blank(bool) override;
- ~MinuiBackendDrm() override;
- MinuiBackendDrm();
private:
void DrmDisableCrtc(int drm_fd, drmModeCrtc* crtc);
- int DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, GRSurfaceDrm* surface);
- GRSurfaceDrm* DrmCreateSurface(int width, int height);
- void DrmDestroySurface(GRSurfaceDrm* surface);
+ bool DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, const std::unique_ptr<GRSurfaceDrm>& surface);
void DisableNonMainCrtcs(int fd, drmModeRes* resources, drmModeCrtc* main_crtc);
drmModeConnector* FindMainMonitor(int fd, drmModeRes* resources, uint32_t* mode_index);
- GRSurfaceDrm* GRSurfaceDrms[2];
- int current_buffer;
- drmModeCrtc* main_monitor_crtc;
- drmModeConnector* main_monitor_connector;
- int drm_fd;
+ std::unique_ptr<GRSurfaceDrm> GRSurfaceDrms[2];
+ int current_buffer{ 0 };
+ drmModeCrtc* main_monitor_crtc{ nullptr };
+ drmModeConnector* main_monitor_connector{ nullptr };
+ int drm_fd{ -1 };
};