Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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 _MINUI_H_ |
| 18 | #define _MINUI_H_ |
| 19 | |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 20 | #include "../gui/placement.h" |
Ethan Yonker | fbb4353 | 2015-12-28 21:54:50 +0100 | [diff] [blame] | 21 | #include <stdbool.h> |
| 22 | |
| 23 | struct GRSurface { |
| 24 | int width; |
| 25 | int height; |
| 26 | int row_bytes; |
| 27 | int pixel_bytes; |
| 28 | unsigned char* data; |
| 29 | __u32 format; |
| 30 | }; |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 31 | |
Dees Troy | f171e10 | 2014-11-06 22:19:58 +0100 | [diff] [blame] | 32 | typedef void* gr_surface; |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 33 | typedef unsigned short gr_pixel; |
| 34 | |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 35 | #define FONT_TYPE_TWRP 0 |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 36 | #define FONT_TYPE_TTF 1 |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 37 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 38 | int gr_init(void); |
| 39 | void gr_exit(void); |
| 40 | |
| 41 | int gr_fb_width(void); |
| 42 | int gr_fb_height(void); |
| 43 | gr_pixel *gr_fb_data(void); |
| 44 | void gr_flip(void); |
Ethan Yonker | fbb4353 | 2015-12-28 21:54:50 +0100 | [diff] [blame] | 45 | void gr_fb_blank(bool blank); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 46 | |
| 47 | void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); |
that | 9876ac3 | 2015-02-15 21:40:59 +0100 | [diff] [blame] | 48 | void gr_clip(int x, int y, int w, int h); |
| 49 | void gr_noclip(); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 50 | void gr_fill(int x, int y, int w, int h); |
Vojtech Bocek | db378b6 | 2015-03-05 20:02:57 +0100 | [diff] [blame] | 51 | void gr_line(int x0, int y0, int x1, int y1, int width); |
| 52 | gr_surface gr_render_circle(int radius, unsigned char r, unsigned char g, unsigned char b, unsigned char a); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 53 | |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 54 | int gr_textEx_scaleW(int x, int y, const char *s, void* pFont, int max_width, int placement, int scale); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 55 | |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 56 | int gr_getMaxFontHeight(void *font); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 57 | |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 58 | void *gr_ttf_loadFont(const char *filename, int size, int dpi); |
Ethan Yonker | b7a54a3 | 2015-10-05 10:16:27 -0500 | [diff] [blame] | 59 | void *gr_ttf_scaleFont(void *font, int max_width, int measured_width); |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 60 | void gr_ttf_freeFont(void *font); |
Vladimir Oltean | d32b7eb | 2018-07-03 00:04:03 +0300 | [diff] [blame] | 61 | int gr_ttf_textExWH(void *context, int x, int y, const char *s, void *pFont, |
| 62 | int max_width, int max_height, const gr_surface gr_draw); |
Vojtech Bocek | 76ee903 | 2014-09-07 15:01:56 +0200 | [diff] [blame] | 63 | int gr_ttf_measureEx(const char *s, void *font); |
| 64 | int gr_ttf_maxExW(const char *s, void *font, int max_width); |
| 65 | int gr_ttf_getMaxFontHeight(void *font); |
| 66 | void gr_ttf_dump_stats(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 67 | |
| 68 | void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); |
| 69 | unsigned int gr_get_width(gr_surface surface); |
| 70 | unsigned int gr_get_height(gr_surface surface); |
| 71 | int gr_get_surface(gr_surface* surface); |
| 72 | int gr_free_surface(gr_surface surface); |
| 73 | |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 74 | // Functions in graphics_utils.c |
Vojtech Bocek | 03fd6c5 | 2014-03-13 18:46:34 +0100 | [diff] [blame] | 75 | int gr_save_screenshot(const char *dest); |
| 76 | |
Vladimir Oltean | d32b7eb | 2018-07-03 00:04:03 +0300 | [diff] [blame] | 77 | // Transform minuitwrp API coordinates into display coordinates, |
| 78 | // for panels that are hardware-mounted in a rotated manner. |
| 79 | #define ROTATION_X_DISP(x, y, surface) \ |
| 80 | ((TW_ROTATION == 0) ? (x) : \ |
| 81 | (TW_ROTATION == 90) ? ((surface)->width - (y) - 1) : \ |
| 82 | (TW_ROTATION == 180) ? ((surface)->width - (x) - 1) : \ |
| 83 | (TW_ROTATION == 270) ? (y) : -1) |
| 84 | #define ROTATION_Y_DISP(x, y, surface) \ |
| 85 | ((TW_ROTATION == 0) ? (y) : \ |
| 86 | (TW_ROTATION == 90) ? (x) : \ |
| 87 | (TW_ROTATION == 180) ? ((surface)->height - (y) - 1) : \ |
| 88 | (TW_ROTATION == 270) ? ((surface)->height - (x) - 1) : -1) |
| 89 | |
| 90 | void surface_ROTATION_transform(gr_surface dst_ptr, const gr_surface src_ptr, size_t num_bytes_per_pixel); |
| 91 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 92 | // input event structure, include <linux/input.h> for the definition. |
| 93 | // see http://www.mjmwired.net/kernel/Documentation/input/ for info. |
| 94 | struct input_event; |
| 95 | |
| 96 | int ev_init(void); |
| 97 | void ev_exit(void); |
that | de72b6d | 2015-02-08 08:55:00 +0100 | [diff] [blame] | 98 | int ev_get(struct input_event *ev, int timeout_ms); |
Vojtech Bocek | 1fc30fc | 2014-01-29 18:37:19 +0100 | [diff] [blame] | 99 | int ev_has_mouse(void); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 100 | |
| 101 | // Resources |
| 102 | |
| 103 | // Returns 0 if no error, else negative. |
| 104 | int res_create_surface(const char* name, gr_surface* pSurface); |
| 105 | void res_free_surface(gr_surface surface); |
Ethan Yonker | 63e414f | 2015-02-06 15:44:39 -0600 | [diff] [blame] | 106 | int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h); |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 107 | |
Samer Diab (S.a.M.e.R_d) | 71e9b04 | 2014-01-07 20:18:47 +0000 | [diff] [blame] | 108 | int vibrate(int timeout_ms); |
| 109 | |
Dees_Troy | 51a0e82 | 2012-09-05 15:24:24 -0400 | [diff] [blame] | 110 | #endif |