• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
17 #include "vr_ui.h"
18 
19 #include <minui/minui.h>
20 
VrRecoveryUI()21 VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {}
22 
ScreenWidth() const23 int VrRecoveryUI::ScreenWidth() const {
24   return gr_fb_width() / 2;
25 }
26 
ScreenHeight() const27 int VrRecoveryUI::ScreenHeight() const {
28   return gr_fb_height();
29 }
30 
DrawSurface(GRSurface * surface,int sx,int sy,int w,int h,int dx,int dy) const31 void VrRecoveryUI::DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
32                                int dy) const {
33   gr_blit(surface, sx, sy, w, h, dx + kStereoOffset, dy);
34   gr_blit(surface, sx, sy, w, h, dx - kStereoOffset + ScreenWidth(), dy);
35 }
36 
DrawTextIcon(int x,int y,GRSurface * surface) const37 void VrRecoveryUI::DrawTextIcon(int x, int y, GRSurface* surface) const {
38   gr_texticon(x + kStereoOffset, y, surface);
39   gr_texticon(x - kStereoOffset + ScreenWidth(), y, surface);
40 }
41 
DrawTextLine(int x,int y,const char * line,bool bold) const42 int VrRecoveryUI::DrawTextLine(int x, int y, const char* line, bool bold) const {
43   gr_text(gr_sys_font(), x + kStereoOffset, y, line, bold);
44   gr_text(gr_sys_font(), x - kStereoOffset + ScreenWidth(), y, line, bold);
45   return char_height_ + 4;
46 }
47 
DrawHorizontalRule(int y) const48 int VrRecoveryUI::DrawHorizontalRule(int y) const {
49   y += 4;
50   gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + 2);
51   gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
52           gr_fb_width() - kMarginWidth - kStereoOffset, y + 2);
53   return y + 4;
54 }
55 
DrawHighlightBar(int,int y,int,int height) const56 void VrRecoveryUI::DrawHighlightBar(int /* x */, int y, int /* width */, int height) const {
57   gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + height);
58   gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
59           gr_fb_width() - kMarginWidth - kStereoOffset, y + height);
60 }
61 
DrawFill(int x,int y,int w,int h) const62 void VrRecoveryUI::DrawFill(int x, int y, int w, int h) const {
63   gr_fill(x + kStereoOffset, y, w, h);
64   gr_fill(x - kStereoOffset + ScreenWidth(), y, w, h);
65 }
66