blob: 5b9b1b4e502bd626924a99fba0aab8a9b70e20ea [file] [log] [blame]
Luke Songe2bd8762017-06-12 16:08:33 -07001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Tianjie Xub5108c32018-08-20 13:40:47 -070017#include "recovery_ui/vr_ui.h"
Luke Songe2bd8762017-06-12 16:08:33 -070018
Tao Bao0bc88de2018-07-31 14:53:16 -070019#include <android-base/properties.h>
Luke Songe2bd8762017-06-12 16:08:33 -070020
Tao Bao0bc88de2018-07-31 14:53:16 -070021#include "minui/minui.h"
22
23constexpr int kDefaultStereoOffset = 0;
24
25VrRecoveryUI::VrRecoveryUI()
26 : stereo_offset_(
27 android::base::GetIntProperty("ro.recovery.ui.stereo_offset", kDefaultStereoOffset)) {}
Luke Songe2bd8762017-06-12 16:08:33 -070028
Luke Song92eda4d2017-09-19 10:51:35 -070029int VrRecoveryUI::ScreenWidth() const {
30 return gr_fb_width() / 2;
31}
32
33int VrRecoveryUI::ScreenHeight() const {
34 return gr_fb_height();
35}
36
Tao Bao65815b62018-10-23 10:54:02 -070037void VrRecoveryUI::DrawSurface(const GRSurface* surface, int sx, int sy, int w, int h, int dx,
Luke Song92eda4d2017-09-19 10:51:35 -070038 int dy) const {
Tao Bao0bc88de2018-07-31 14:53:16 -070039 gr_blit(surface, sx, sy, w, h, dx + stereo_offset_, dy);
40 gr_blit(surface, sx, sy, w, h, dx - stereo_offset_ + ScreenWidth(), dy);
Luke Song92eda4d2017-09-19 10:51:35 -070041}
42
Tao Bao65815b62018-10-23 10:54:02 -070043void VrRecoveryUI::DrawTextIcon(int x, int y, const GRSurface* surface) const {
Tao Bao0bc88de2018-07-31 14:53:16 -070044 gr_texticon(x + stereo_offset_, y, surface);
45 gr_texticon(x - stereo_offset_ + ScreenWidth(), y, surface);
Luke Songe2bd8762017-06-12 16:08:33 -070046}
47
Tao Bao93e46ad2018-05-02 14:57:21 -070048int VrRecoveryUI::DrawTextLine(int x, int y, const std::string& line, bool bold) const {
Tao Bao0bc88de2018-07-31 14:53:16 -070049 gr_text(gr_sys_font(), x + stereo_offset_, y, line.c_str(), bold);
50 gr_text(gr_sys_font(), x - stereo_offset_ + ScreenWidth(), y, line.c_str(), bold);
Tao Baoea78d862017-06-28 14:52:17 -070051 return char_height_ + 4;
Luke Songe2bd8762017-06-12 16:08:33 -070052}
Luke Song92eda4d2017-09-19 10:51:35 -070053
54int VrRecoveryUI::DrawHorizontalRule(int y) const {
55 y += 4;
Tao Bao0bc88de2018-07-31 14:53:16 -070056 gr_fill(margin_width_ + stereo_offset_, y, ScreenWidth() - margin_width_ + stereo_offset_, y + 2);
57 gr_fill(ScreenWidth() + margin_width_ - stereo_offset_, y,
58 gr_fb_width() - margin_width_ - stereo_offset_, y + 2);
Luke Song92eda4d2017-09-19 10:51:35 -070059 return y + 4;
60}
61
Tao Bao99f0d9e2016-10-13 12:46:38 -070062void VrRecoveryUI::DrawHighlightBar(int /* x */, int y, int /* width */, int height) const {
Tao Bao0bc88de2018-07-31 14:53:16 -070063 gr_fill(margin_width_ + stereo_offset_, y, ScreenWidth() - margin_width_ + stereo_offset_,
64 y + height);
65 gr_fill(ScreenWidth() + margin_width_ - stereo_offset_, y,
66 gr_fb_width() - margin_width_ - stereo_offset_, y + height);
Luke Song92eda4d2017-09-19 10:51:35 -070067}
68
69void VrRecoveryUI::DrawFill(int x, int y, int w, int h) const {
Tao Bao0bc88de2018-07-31 14:53:16 -070070 gr_fill(x + stereo_offset_, y, w, h);
71 gr_fill(x - stereo_offset_ + ScreenWidth(), y, w, h);
Luke Song92eda4d2017-09-19 10:51:35 -070072}