summaryrefslogtreecommitdiffstats
path: root/minui/graphics_adf.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-10-23 19:06:35 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-10-23 19:06:35 +0200
commit66a576b79c6cf629c439f02a37b824a1ec35ec19 (patch)
tree516cc6ee57b32a0354a9895e85d7238e6496b7fd /minui/graphics_adf.cpp
parentMerge "Recovery now expects public keys in zipfile" (diff)
parentminui: Move GRSurface into a class. (diff)
downloadandroid_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.gz
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.bz2
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.lz
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.xz
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.tar.zst
android_bootable_recovery-66a576b79c6cf629c439f02a37b824a1ec35ec19.zip
Diffstat (limited to 'minui/graphics_adf.cpp')
-rw-r--r--minui/graphics_adf.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/minui/graphics_adf.cpp b/minui/graphics_adf.cpp
index 7439df9ac..6fc193f74 100644
--- a/minui/graphics_adf.cpp
+++ b/minui/graphics_adf.cpp
@@ -45,14 +45,14 @@ int MinuiBackendAdf::SurfaceInit(const drm_mode_modeinfo* mode, GRSurfaceAdf* su
surf->row_bytes = surf->pitch;
surf->pixel_bytes = (format == DRM_FORMAT_RGB565) ? 2 : 4;
- surf->data = static_cast<uint8_t*>(
- mmap(nullptr, surf->pitch * surf->height, PROT_WRITE, MAP_SHARED, surf->fd, surf->offset));
- if (surf->data == MAP_FAILED) {
+ auto mmapped =
+ mmap(nullptr, surf->pitch * surf->height, PROT_WRITE, MAP_SHARED, surf->fd, surf->offset);
+ if (mmapped == MAP_FAILED) {
int saved_errno = errno;
close(surf->fd);
return -saved_errno;
}
-
+ surf->mmapped_buffer_ = static_cast<uint8_t*>(mmapped);
return 0;
}
@@ -185,7 +185,9 @@ void MinuiBackendAdf::Blank(bool blank) {
}
void MinuiBackendAdf::SurfaceDestroy(GRSurfaceAdf* surf) {
- munmap(surf->data, surf->pitch * surf->height);
+ if (surf->mmapped_buffer_) {
+ munmap(surf->mmapped_buffer_, surf->pitch * surf->height);
+ }
close(surf->fence_fd);
close(surf->fd);
}