summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2018-06-07 02:33:47 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-06-07 02:33:47 +0200
commita8900ef91ee8cf1adbb9d969b76f260d9ff93701 (patch)
tree8b937b17021b63bea6ec9558f73e025819afd7b1
parentMerge "ui: join only if joinable." am: 2454b2493a am: ccff03d196 (diff)
parentMerge "minui: Handle the failures from the drm backend in gr_init" am: 0e2d900739 (diff)
downloadandroid_bootable_recovery-a8900ef91ee8cf1adbb9d969b76f260d9ff93701.tar
android_bootable_recovery-a8900ef91ee8cf1adbb9d969b76f260d9ff93701.tar.gz
android_bootable_recovery-a8900ef91ee8cf1adbb9d969b76f260d9ff93701.tar.bz2
android_bootable_recovery-a8900ef91ee8cf1adbb9d969b76f260d9ff93701.tar.lz
android_bootable_recovery-a8900ef91ee8cf1adbb9d969b76f260d9ff93701.tar.xz
android_bootable_recovery-a8900ef91ee8cf1adbb9d969b76f260d9ff93701.tar.zst
android_bootable_recovery-a8900ef91ee8cf1adbb9d969b76f260d9ff93701.zip
-rw-r--r--minui/graphics.cpp4
-rw-r--r--minui/graphics_drm.cpp17
-rw-r--r--minui/graphics_drm.h2
3 files changed, 16 insertions, 7 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index 3b386015a..c1aab412d 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -356,6 +356,10 @@ int gr_init() {
gr_flip();
gr_flip();
+ if (!gr_draw) {
+ printf("gr_init: gr_draw becomes nullptr after gr_flip\n");
+ return -1;
+ }
gr_rotate(DEFAULT_ROTATION);
diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp
index e7d4b38ef..4c98507f6 100644
--- a/minui/graphics_drm.cpp
+++ b/minui/graphics_drm.cpp
@@ -45,15 +45,17 @@ void MinuiBackendDrm::DrmDisableCrtc(int drm_fd, drmModeCrtc* crtc) {
}
}
-void MinuiBackendDrm::DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, GRSurfaceDrm* surface) {
- int32_t ret = drmModeSetCrtc(drm_fd, crtc->crtc_id, surface->fb_id, 0, 0, // x,y
- &main_monitor_connector->connector_id,
- 1, // connector_count
- &main_monitor_crtc->mode);
+int MinuiBackendDrm::DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, GRSurfaceDrm* surface) {
+ int ret = drmModeSetCrtc(drm_fd, crtc->crtc_id, surface->fb_id, 0, 0, // x,y
+ &main_monitor_connector->connector_id,
+ 1, // connector_count
+ &main_monitor_crtc->mode);
if (ret) {
printf("drmModeSetCrtc failed ret=%d\n", ret);
}
+
+ return ret;
}
void MinuiBackendDrm::Blank(bool blank) {
@@ -368,7 +370,10 @@ GRSurface* MinuiBackendDrm::Init() {
current_buffer = 0;
- DrmEnableCrtc(drm_fd, main_monitor_crtc, GRSurfaceDrms[1]);
+ // We will likely encounter errors in the backend functions (i.e. Flip) if EnableCrtc fails.
+ if (DrmEnableCrtc(drm_fd, main_monitor_crtc, GRSurfaceDrms[1]) != 0) {
+ return nullptr;
+ }
return GRSurfaceDrms[0];
}
diff --git a/minui/graphics_drm.h b/minui/graphics_drm.h
index de9621205..756625b03 100644
--- a/minui/graphics_drm.h
+++ b/minui/graphics_drm.h
@@ -42,7 +42,7 @@ class MinuiBackendDrm : public MinuiBackend {
private:
void DrmDisableCrtc(int drm_fd, drmModeCrtc* crtc);
- void DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, GRSurfaceDrm* surface);
+ int DrmEnableCrtc(int drm_fd, drmModeCrtc* crtc, GRSurfaceDrm* surface);
GRSurfaceDrm* DrmCreateSurface(int width, int height);
void DrmDestroySurface(GRSurfaceDrm* surface);
void DisableNonMainCrtcs(int fd, drmModeRes* resources, drmModeCrtc* main_crtc);