From f95e686dd04056db2ff0a6b2933cce07eba54e14 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Thu, 29 Jun 2017 14:32:05 -0700 Subject: screen_ui: Compute the top and bottom gaps. We're not actually following the gaps as in the comments. For example, Nexus 6P is supposed to use 220dp and 194dp gaps (top and bottom respectively), but the actual numbers are 185dp and 194dp. Because the animation icon and text sizes don't match the ones claimed (animation: expected 200dp or 700px, actual 800px; text: claimed 14sp, actual 76px). The top gap changes (shrinks) as we compute the baselines bottom-up. This CL switches to using computed gaps: the major UI elements always stay vertically centered, with identical top and bottom gaps. Bug: 63093285 Test: 'Run graphics test' on angler/volantis/fugu/ryu. Change-Id: I3cadbb34f728cf034afa47ac02a6deba8cb6b4e7 (cherry picked from commit 3250f723602244cd3a87327a14755dcde2f4e5dc) --- screen_ui.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/screen_ui.cpp b/screen_ui.cpp index 4ca96a9b2..7334b713e 100644 --- a/screen_ui.cpp +++ b/screen_ui.cpp @@ -107,24 +107,24 @@ int ScreenRecoveryUI::PixelsFromDp(int dp) const { // | portrait large landscape large // ---------+------------------------------------------------- -// gap | 220dp 366dp 142dp 284dp +// gap | // icon | (200dp) // gap | 68dp 68dp 56dp 112dp // text | (14sp) // gap | 32dp 32dp 26dp 52dp // progress | (2dp) -// gap | 194dp 340dp 131dp 262dp +// gap | -// Note that "baseline" is actually the *top* of each icon (because that's how our drawing -// routines work), so that's the more useful measurement for calling code. +// Note that "baseline" is actually the *top* of each icon (because that's how our drawing routines +// work), so that's the more useful measurement for calling code. We use even top and bottom gaps. enum Layout { PORTRAIT = 0, PORTRAIT_LARGE = 1, LANDSCAPE = 2, LANDSCAPE_LARGE = 3, LAYOUT_MAX }; -enum Dimension { PROGRESS = 0, TEXT = 1, ICON = 2, DIMENSION_MAX }; +enum Dimension { TEXT = 0, ICON = 1, DIMENSION_MAX }; static constexpr int kLayouts[LAYOUT_MAX][DIMENSION_MAX] = { - { 194, 32, 68, }, // PORTRAIT - { 340, 32, 68, }, // PORTRAIT_LARGE - { 131, 26, 56, }, // LANDSCAPE - { 262, 52, 112, }, // LANDSCAPE_LARGE + { 32, 68, }, // PORTRAIT + { 32, 68, }, // PORTRAIT_LARGE + { 26, 56, }, // LANDSCAPE + { 52, 112, }, // LANDSCAPE_LARGE }; int ScreenRecoveryUI::GetAnimationBaseline() { @@ -138,8 +138,11 @@ int ScreenRecoveryUI::GetTextBaseline() { } int ScreenRecoveryUI::GetProgressBaseline() { - return gr_fb_height() - PixelsFromDp(kLayouts[layout_][PROGRESS]) - - gr_get_height(progressBarFill); + int elements_sum = gr_get_height(loopFrames[0]) + PixelsFromDp(kLayouts[layout_][ICON]) + + gr_get_height(installing_text) + PixelsFromDp(kLayouts[layout_][TEXT]) + + gr_get_height(progressBarFill); + int bottom_gap = (gr_fb_height() - elements_sum) / 2; + return gr_fb_height() - bottom_gap - gr_get_height(progressBarFill); } // Clear the screen and draw the currently selected background icon (if any). -- cgit v1.2.3