blob: a6c2a712ceaf7b8847c8a36610dac9ac8b436475 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001/*
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 Yonkerb7a54a32015-10-05 10:16:27 -050020#include "../gui/placement.h"
Ethan Yonkerfbb43532015-12-28 21:54:50 +010021#include <stdbool.h>
22
23struct GRSurface {
24 int width;
25 int height;
26 int row_bytes;
27 int pixel_bytes;
28 unsigned char* data;
29 __u32 format;
30};
Ethan Yonkerb7a54a32015-10-05 10:16:27 -050031
Dees Troyf171e102014-11-06 22:19:58 +010032typedef void* gr_surface;
Dees_Troy51a0e822012-09-05 15:24:24 -040033typedef unsigned short gr_pixel;
34
Vojtech Bocek76ee9032014-09-07 15:01:56 +020035#define FONT_TYPE_TWRP 0
Vojtech Bocek76ee9032014-09-07 15:01:56 +020036#define FONT_TYPE_TTF 1
Vojtech Bocek76ee9032014-09-07 15:01:56 +020037
Dees_Troy51a0e822012-09-05 15:24:24 -040038int gr_init(void);
39void gr_exit(void);
40
41int gr_fb_width(void);
42int gr_fb_height(void);
43gr_pixel *gr_fb_data(void);
44void gr_flip(void);
Ethan Yonkerfbb43532015-12-28 21:54:50 +010045void gr_fb_blank(bool blank);
Dees_Troy51a0e822012-09-05 15:24:24 -040046
47void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
that9876ac32015-02-15 21:40:59 +010048void gr_clip(int x, int y, int w, int h);
49void gr_noclip();
Dees_Troy51a0e822012-09-05 15:24:24 -040050void gr_fill(int x, int y, int w, int h);
Vojtech Bocekdb378b62015-03-05 20:02:57 +010051void gr_line(int x0, int y0, int x1, int y1, int width);
52gr_surface gr_render_circle(int radius, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
Dees_Troy51a0e822012-09-05 15:24:24 -040053
Ethan Yonkerb7a54a32015-10-05 10:16:27 -050054int gr_textEx_scaleW(int x, int y, const char *s, void* pFont, int max_width, int placement, int scale);
Dees_Troy51a0e822012-09-05 15:24:24 -040055
Vojtech Bocek76ee9032014-09-07 15:01:56 +020056int gr_getMaxFontHeight(void *font);
Dees_Troy51a0e822012-09-05 15:24:24 -040057
Vojtech Bocek76ee9032014-09-07 15:01:56 +020058void *gr_ttf_loadFont(const char *filename, int size, int dpi);
Ethan Yonkerb7a54a32015-10-05 10:16:27 -050059void *gr_ttf_scaleFont(void *font, int max_width, int measured_width);
Vojtech Bocek76ee9032014-09-07 15:01:56 +020060void gr_ttf_freeFont(void *font);
Vladimir Olteand32b7eb2018-07-03 00:04:03 +030061int 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 Bocek76ee9032014-09-07 15:01:56 +020063int gr_ttf_measureEx(const char *s, void *font);
64int gr_ttf_maxExW(const char *s, void *font, int max_width);
65int gr_ttf_getMaxFontHeight(void *font);
66void gr_ttf_dump_stats(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040067
68void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
69unsigned int gr_get_width(gr_surface surface);
70unsigned int gr_get_height(gr_surface surface);
71int gr_get_surface(gr_surface* surface);
72int gr_free_surface(gr_surface surface);
73
Ethan Yonker63e414f2015-02-06 15:44:39 -060074// Functions in graphics_utils.c
Vojtech Bocek03fd6c52014-03-13 18:46:34 +010075int gr_save_screenshot(const char *dest);
76
Vladimir Olteand32b7eb2018-07-03 00:04:03 +030077// Transform minuitwrp API coordinates into display coordinates,
78// for panels that are hardware-mounted in a rotated manner.
Aaron Kling4eccd9a2019-06-30 12:20:09 -050079int ROTATION_X_DISP(int x, int y, int w);
80
81int ROTATION_Y_DISP(int x, int y, int h);
Vladimir Olteand32b7eb2018-07-03 00:04:03 +030082
83void surface_ROTATION_transform(gr_surface dst_ptr, const gr_surface src_ptr, size_t num_bytes_per_pixel);
84
Dees_Troy51a0e822012-09-05 15:24:24 -040085// input event structure, include <linux/input.h> for the definition.
86// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
87struct input_event;
88
89int ev_init(void);
90void ev_exit(void);
thatde72b6d2015-02-08 08:55:00 +010091int ev_get(struct input_event *ev, int timeout_ms);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010092int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040093
94// Resources
95
96// Returns 0 if no error, else negative.
97int res_create_surface(const char* name, gr_surface* pSurface);
98void res_free_surface(gr_surface surface);
Ethan Yonker63e414f2015-02-06 15:44:39 -060099int res_scale_surface(gr_surface source, gr_surface* destination, float scale_w, float scale_h);
Dees_Troy51a0e822012-09-05 15:24:24 -0400100
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +0000101int vibrate(int timeout_ms);
102
Dees_Troy51a0e822012-09-05 15:24:24 -0400103#endif