summaryrefslogtreecommitdiffstats
path: root/minui
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-10-24 16:59:49 +0200
committerTao Bao <tbao@google.com>2018-11-01 04:28:29 +0100
commit710bc535f45570428f0c7b36bb4f20744247cb38 (patch)
treef7ddeeb7d22e402a607f46802ecdd716471e546b /minui
parentminui: Refactor GRSurfaceAdf. (diff)
downloadandroid_bootable_recovery-710bc535f45570428f0c7b36bb4f20744247cb38.tar
android_bootable_recovery-710bc535f45570428f0c7b36bb4f20744247cb38.tar.gz
android_bootable_recovery-710bc535f45570428f0c7b36bb4f20744247cb38.tar.bz2
android_bootable_recovery-710bc535f45570428f0c7b36bb4f20744247cb38.tar.lz
android_bootable_recovery-710bc535f45570428f0c7b36bb4f20744247cb38.tar.xz
android_bootable_recovery-710bc535f45570428f0c7b36bb4f20744247cb38.tar.zst
android_bootable_recovery-710bc535f45570428f0c7b36bb4f20744247cb38.zip
Diffstat (limited to 'minui')
-rw-r--r--minui/graphics_drm.cpp10
-rw-r--r--minui/graphics_drm.h7
-rw-r--r--minui/include/minui/minui.h5
3 files changed, 10 insertions, 12 deletions
diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp
index f81fd9d5c..765e2625a 100644
--- a/minui/graphics_drm.cpp
+++ b/minui/graphics_drm.cpp
@@ -102,15 +102,15 @@ std::unique_ptr<GRSurfaceDrm> GRSurfaceDrm::Create(int drm_fd, int width, int he
return nullptr;
}
- std::unique_ptr<GRSurfaceDrm> surface = std::make_unique<GRSurfaceDrm>(drm_fd);
- surface->handle = create_dumb.handle;
+ // Cannot use std::make_unique to access non-public ctor.
+ auto surface = std::unique_ptr<GRSurfaceDrm>(new GRSurfaceDrm(
+ width, height, create_dumb.pitch, create_dumb.bpp / 8, drm_fd, create_dumb.handle));
uint32_t handles[4], pitches[4], offsets[4];
handles[0] = surface->handle;
pitches[0] = create_dumb.pitch;
offsets[0] = 0;
-
if (drmModeAddFB2(drm_fd, width, height, format, handles, pitches, offsets, &surface->fb_id, 0) !=
0) {
perror("Failed to drmModeAddFB2");
@@ -124,10 +124,6 @@ std::unique_ptr<GRSurfaceDrm> GRSurfaceDrm::Create(int drm_fd, int width, int he
return nullptr;
}
- surface->height = height;
- surface->width = width;
- surface->row_bytes = create_dumb.pitch;
- surface->pixel_bytes = create_dumb.bpp / 8;
auto mmapped = mmap(nullptr, surface->height * surface->row_bytes, PROT_READ | PROT_WRITE,
MAP_SHARED, drm_fd, map_dumb.offset);
if (mmapped == MAP_FAILED) {
diff --git a/minui/graphics_drm.h b/minui/graphics_drm.h
index 02db89f05..6ba46e60b 100644
--- a/minui/graphics_drm.h
+++ b/minui/graphics_drm.h
@@ -20,7 +20,6 @@
#include <memory>
-#include <android-base/macros.h>
#include <xf86drmMode.h>
#include "graphics.h"
@@ -28,7 +27,6 @@
class GRSurfaceDrm : public GRSurface {
public:
- explicit GRSurfaceDrm(int drm_fd) : drm_fd_(drm_fd) {}
~GRSurfaceDrm() override;
// Creates a GRSurfaceDrm instance.
@@ -41,13 +39,14 @@ class GRSurfaceDrm : public GRSurface {
private:
friend class MinuiBackendDrm;
+ GRSurfaceDrm(int width, int height, int row_bytes, int pixel_bytes, int drm_fd, uint32_t handle)
+ : GRSurface(width, height, row_bytes, pixel_bytes), drm_fd_(drm_fd), handle(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 {
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index 66d992b93..d6881e9a0 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -24,13 +24,14 @@
#include <string>
#include <vector>
+#include <android-base/macros.h>
+
//
// Graphics.
//
class GRSurface {
public:
- GRSurface() = default;
virtual ~GRSurface();
// Creates and returns a GRSurface instance that's sufficient for storing an image of the given
@@ -58,6 +59,8 @@ class GRSurface {
private:
uint8_t* data_{ nullptr };
+
+ DISALLOW_COPY_AND_ASSIGN(GRSurface);
};
struct GRFont {