blob: 3d4abbddacfd0b322178a751a3a492298e838ac9 [file] [log] [blame]
Luke Song7f386dc2017-07-13 15:10:35 -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
17#ifndef HEALTHD_DRAW_H
18#define HEALTHD_DRAW_H
19
20#include <linux/input.h>
21#include <minui/minui.h>
22
23#include "animation.h"
24
25using namespace android;
26
27class HealthdDraw {
28 public:
Luke Song7f386dc2017-07-13 15:10:35 -070029 virtual ~HealthdDraw();
30
31 // Redraws screen.
32 void redraw_screen(const animation* batt_anim, GRSurface* surf_unknown);
33
Jack Wuc1b17112021-09-29 22:27:56 +080034 // According to the index of Direct Rendering Manager,
Luke Song7f386dc2017-07-13 15:10:35 -070035 // Blanks screen if true, unblanks if false.
Jack Wuc1b17112021-09-29 22:27:56 +080036 virtual void blank_screen(bool blank, int drm);
Luke Song7f386dc2017-07-13 15:10:35 -070037
Jack Wu56540a02021-10-22 17:10:37 +080038 // Rotate screen.
39 virtual void rotate_screen(int drm);
40
Xiaohui Niua40d8722021-08-31 16:22:25 +080041 static std::unique_ptr<HealthdDraw> Create(animation *anim);
42
Luke Song7f386dc2017-07-13 15:10:35 -070043 protected:
44 virtual void clear_screen();
45
46 // returns the last y-offset of where the surface ends.
47 virtual int draw_surface_centered(GRSurface* surface);
48 // Negative x or y coordinates center text.
49 virtual int draw_text(const GRFont* font, int x, int y, const char* str);
50
51 // Negative x or y coordinates position the text away from the opposite edge
52 // that positive ones do.
53 virtual void determine_xy(const animation::text_field& field,
54 const int length, int* x, int* y);
55
56 // Draws battery animation, if it exists.
57 virtual void draw_battery(const animation* anim);
58 // Draws clock text, if animation contains text_field data.
59 virtual void draw_clock(const animation* anim);
60 // Draws battery percentage text if animation contains text_field data.
61 virtual void draw_percent(const animation* anim);
62 // Draws charger->surf_unknown or basic text.
63 virtual void draw_unknown(GRSurface* surf_unknown);
64
65 // Pixel sizes of characters for default font.
66 int char_width_;
67 int char_height_;
68
69 // Width and height of screen in pixels.
70 int screen_width_;
71 int screen_height_;
72
73 // Device screen is split vertically.
74 const bool kSplitScreen;
75 // Pixels to offset graphics towards center split.
76 const int kSplitOffset;
Todd Poynore5d1b622018-06-01 11:09:58 -070077
78 // system text font, may be nullptr
79 const GRFont* sys_font;
80
81 // true if minui init'ed OK, false if minui init failed
82 bool graphics_available;
Xiaohui Niua40d8722021-08-31 16:22:25 +080083
84 private:
85 // Configures font using given animation.
86 HealthdDraw(animation* anim);
Luke Song7f386dc2017-07-13 15:10:35 -070087};
88
89#endif // HEALTHD_DRAW_H