Luke Song | 7f386dc | 2017-07-13 15:10:35 -0700 | [diff] [blame] | 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 | #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 | |
| 25 | using namespace android; |
| 26 | |
| 27 | class HealthdDraw { |
| 28 | public: |
Luke Song | 7f386dc | 2017-07-13 15:10:35 -0700 | [diff] [blame] | 29 | virtual ~HealthdDraw(); |
| 30 | |
| 31 | // Redraws screen. |
| 32 | void redraw_screen(const animation* batt_anim, GRSurface* surf_unknown); |
| 33 | |
Jack Wu | c1b1711 | 2021-09-29 22:27:56 +0800 | [diff] [blame] | 34 | // According to the index of Direct Rendering Manager, |
Luke Song | 7f386dc | 2017-07-13 15:10:35 -0700 | [diff] [blame] | 35 | // Blanks screen if true, unblanks if false. |
Jack Wu | c1b1711 | 2021-09-29 22:27:56 +0800 | [diff] [blame] | 36 | virtual void blank_screen(bool blank, int drm); |
Luke Song | 7f386dc | 2017-07-13 15:10:35 -0700 | [diff] [blame] | 37 | |
Jack Wu | 56540a0 | 2021-10-22 17:10:37 +0800 | [diff] [blame] | 38 | // Rotate screen. |
| 39 | virtual void rotate_screen(int drm); |
| 40 | |
Jack Wu | 20b8a01 | 2022-08-29 17:59:09 +0800 | [diff] [blame] | 41 | // Detect dual display |
| 42 | virtual bool has_multiple_connectors(); |
| 43 | |
Xiaohui Niu | a40d872 | 2021-08-31 16:22:25 +0800 | [diff] [blame] | 44 | static std::unique_ptr<HealthdDraw> Create(animation *anim); |
| 45 | |
Luke Song | 7f386dc | 2017-07-13 15:10:35 -0700 | [diff] [blame] | 46 | protected: |
| 47 | virtual void clear_screen(); |
| 48 | |
| 49 | // returns the last y-offset of where the surface ends. |
| 50 | virtual int draw_surface_centered(GRSurface* surface); |
| 51 | // Negative x or y coordinates center text. |
| 52 | virtual int draw_text(const GRFont* font, int x, int y, const char* str); |
| 53 | |
| 54 | // Negative x or y coordinates position the text away from the opposite edge |
| 55 | // that positive ones do. |
| 56 | virtual void determine_xy(const animation::text_field& field, |
| 57 | const int length, int* x, int* y); |
| 58 | |
| 59 | // Draws battery animation, if it exists. |
| 60 | virtual void draw_battery(const animation* anim); |
| 61 | // Draws clock text, if animation contains text_field data. |
| 62 | virtual void draw_clock(const animation* anim); |
| 63 | // Draws battery percentage text if animation contains text_field data. |
| 64 | virtual void draw_percent(const animation* anim); |
| 65 | // Draws charger->surf_unknown or basic text. |
| 66 | virtual void draw_unknown(GRSurface* surf_unknown); |
| 67 | |
| 68 | // Pixel sizes of characters for default font. |
| 69 | int char_width_; |
| 70 | int char_height_; |
| 71 | |
| 72 | // Width and height of screen in pixels. |
| 73 | int screen_width_; |
| 74 | int screen_height_; |
| 75 | |
| 76 | // Device screen is split vertically. |
| 77 | const bool kSplitScreen; |
| 78 | // Pixels to offset graphics towards center split. |
| 79 | const int kSplitOffset; |
Todd Poynor | e5d1b62 | 2018-06-01 11:09:58 -0700 | [diff] [blame] | 80 | |
| 81 | // system text font, may be nullptr |
| 82 | const GRFont* sys_font; |
| 83 | |
| 84 | // true if minui init'ed OK, false if minui init failed |
| 85 | bool graphics_available; |
Xiaohui Niu | a40d872 | 2021-08-31 16:22:25 +0800 | [diff] [blame] | 86 | |
| 87 | private: |
| 88 | // Configures font using given animation. |
| 89 | HealthdDraw(animation* anim); |
Luke Song | 7f386dc | 2017-07-13 15:10:35 -0700 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | #endif // HEALTHD_DRAW_H |