summaryrefslogtreecommitdiffstats
path: root/minui/graphics_drm.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-10-21 21:12:37 +0200
committerTao Bao <tbao@google.com>2018-10-23 03:18:02 +0200
commit92bdb5a38964baf8326a7d6f53926c30e250922c (patch)
tree23421d8b4d4bb98f9f8e0cfc20ec08889a14d22f /minui/graphics_drm.cpp
parentMerge "Fix instrumentation_for to refer to name of module" (diff)
downloadandroid_bootable_recovery-92bdb5a38964baf8326a7d6f53926c30e250922c.tar
android_bootable_recovery-92bdb5a38964baf8326a7d6f53926c30e250922c.tar.gz
android_bootable_recovery-92bdb5a38964baf8326a7d6f53926c30e250922c.tar.bz2
android_bootable_recovery-92bdb5a38964baf8326a7d6f53926c30e250922c.tar.lz
android_bootable_recovery-92bdb5a38964baf8326a7d6f53926c30e250922c.tar.xz
android_bootable_recovery-92bdb5a38964baf8326a7d6f53926c30e250922c.tar.zst
android_bootable_recovery-92bdb5a38964baf8326a7d6f53926c30e250922c.zip
Diffstat (limited to 'minui/graphics_drm.cpp')
-rw-r--r--minui/graphics_drm.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp
index 630b80180..81b49fd95 100644
--- a/minui/graphics_drm.cpp
+++ b/minui/graphics_drm.cpp
@@ -70,8 +70,8 @@ void MinuiBackendDrm::Blank(bool blank) {
void MinuiBackendDrm::DrmDestroySurface(GRSurfaceDrm* surface) {
if (!surface) return;
- if (surface->data) {
- munmap(surface->data, surface->row_bytes * surface->height);
+ if (surface->mmapped_buffer_) {
+ munmap(surface->mmapped_buffer_, surface->row_bytes * surface->height);
}
if (surface->fb_id) {
@@ -172,15 +172,14 @@ GRSurfaceDrm* MinuiBackendDrm::DrmCreateSurface(int width, int height) {
surface->width = width;
surface->row_bytes = create_dumb.pitch;
surface->pixel_bytes = create_dumb.bpp / 8;
- surface->data = static_cast<unsigned char*>(mmap(nullptr, surface->height * surface->row_bytes,
- PROT_READ | PROT_WRITE, MAP_SHARED, drm_fd,
- map_dumb.offset));
- if (surface->data == MAP_FAILED) {
+ auto mmapped = mmap(nullptr, surface->height * surface->row_bytes, PROT_READ | PROT_WRITE,
+ MAP_SHARED, drm_fd, map_dumb.offset);
+ if (mmapped == MAP_FAILED) {
perror("mmap() failed");
DrmDestroySurface(surface);
return nullptr;
}
-
+ surface->mmapped_buffer_ = static_cast<uint8_t*>(mmapped);
return surface;
}