summaryrefslogtreecommitdiffstats
path: root/minui/graphics_adf.cpp
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-10-24 05:11:46 +0200
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-10-24 05:11:46 +0200
commit36c6222be4084180e7dc5a9ff3283c86fdcdc3a7 (patch)
treea911f5de7d3972133283298037554308d5ad5c0d /minui/graphics_adf.cpp
parentSnap for 5082210 from 3d5a941b0b1671c3ccc3dd25faa2cd7de738b0b0 to qt-release (diff)
parentMerge "Add a function to construct the GRSurface in test" am: ee9c65a38e am: e100c9f491 (diff)
downloadandroid_bootable_recovery-36c6222be4084180e7dc5a9ff3283c86fdcdc3a7.tar
android_bootable_recovery-36c6222be4084180e7dc5a9ff3283c86fdcdc3a7.tar.gz
android_bootable_recovery-36c6222be4084180e7dc5a9ff3283c86fdcdc3a7.tar.bz2
android_bootable_recovery-36c6222be4084180e7dc5a9ff3283c86fdcdc3a7.tar.lz
android_bootable_recovery-36c6222be4084180e7dc5a9ff3283c86fdcdc3a7.tar.xz
android_bootable_recovery-36c6222be4084180e7dc5a9ff3283c86fdcdc3a7.tar.zst
android_bootable_recovery-36c6222be4084180e7dc5a9ff3283c86fdcdc3a7.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);
}