The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [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 | |
Tao Bao | 0ecbd76 | 2017-01-16 21:16:58 -0800 | [diff] [blame] | 17 | #include "graphics.h" |
| 18 | |
Tao Bao | e8020f4 | 2017-02-03 09:30:07 -0800 | [diff] [blame] | 19 | #include <stdio.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 20 | #include <stdlib.h> |
Elliott Hughes | cd3c55a | 2015-01-29 20:50:08 -0800 | [diff] [blame] | 21 | #include <string.h> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 22 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 23 | #include <memory> |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 24 | |
maxwen | 39624d4 | 2015-12-01 22:02:07 +0100 | [diff] [blame] | 25 | #ifdef BOARD_USE_CUSTOM_RECOVERY_FONT |
| 26 | #include BOARD_USE_CUSTOM_RECOVERY_FONT |
| 27 | #else |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 28 | #include "font_10x18.h" |
maxwen | 39624d4 | 2015-12-01 22:02:07 +0100 | [diff] [blame] | 29 | #endif |
| 30 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 31 | #include "graphics_adf.h" |
| 32 | #include "graphics_drm.h" |
| 33 | #include "graphics_fbdev.h" |
Ethan Yonker | 8373cfe | 2017-09-08 06:50:54 -0500 | [diff] [blame] | 34 | #include "graphics_overlay.h" |
Tao Bao | 0ecbd76 | 2017-01-16 21:16:58 -0800 | [diff] [blame] | 35 | #include "minui/minui.h" |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 36 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 37 | static GRFont* gr_font = NULL; |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 38 | static MinuiBackend* gr_backend = nullptr; |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 39 | |
Doug Zongker | c560a67 | 2012-12-18 16:31:27 -0800 | [diff] [blame] | 40 | static int overscan_percent = OVERSCAN_PERCENT; |
| 41 | static int overscan_offset_x = 0; |
| 42 | static int overscan_offset_y = 0; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 43 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 44 | static unsigned char gr_current_r = 255; |
| 45 | static unsigned char gr_current_g = 255; |
| 46 | static unsigned char gr_current_b = 255; |
| 47 | static unsigned char gr_current_a = 255; |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 48 | static unsigned char rgb_555[2]; |
| 49 | static unsigned char gr_current_r5 = 31; |
| 50 | static unsigned char gr_current_g5 = 63; |
| 51 | static unsigned char gr_current_b5 = 31; |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 52 | |
Doug Zongker | 5290f20 | 2014-03-11 13:22:04 -0700 | [diff] [blame] | 53 | static GRSurface* gr_draw = NULL; |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 54 | |
| 55 | static bool outside(int x, int y) |
| 56 | { |
| 57 | return x < 0 || x >= gr_draw->width || y < 0 || y >= gr_draw->height; |
| 58 | } |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 59 | |
| 60 | #ifdef TW_NO_MINUI_CUSTOM_FONTS |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 61 | int gr_measure(const char *s) |
| 62 | { |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 63 | return gr_font->char_width * strlen(s); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 64 | } |
| 65 | |
Dima Zavin | 3c7f00e | 2011-08-30 11:58:24 -0700 | [diff] [blame] | 66 | void gr_font_size(int *x, int *y) |
| 67 | { |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 68 | *x = gr_font->char_width; |
| 69 | *y = gr_font->char_height; |
Dima Zavin | 3c7f00e | 2011-08-30 11:58:24 -0700 | [diff] [blame] | 70 | } |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 71 | #else // TW_USE_MINUI_CUSTOM_FONTS |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 72 | const GRFont* gr_sys_font() |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 73 | { |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 74 | return gr_font; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 75 | } |
| 76 | |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 77 | int gr_measure(const GRFont* font, const char *s) |
Dima Zavin | 3c7f00e | 2011-08-30 11:58:24 -0700 | [diff] [blame] | 78 | { |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 79 | return font->char_width * strlen(s); |
| 80 | } |
| 81 | |
| 82 | void gr_font_size(const GRFont* font, int *x, int *y) |
| 83 | { |
| 84 | *x = font->char_width; |
| 85 | *y = font->char_height; |
Dima Zavin | 3c7f00e | 2011-08-30 11:58:24 -0700 | [diff] [blame] | 86 | } |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 87 | #endif // TW_NO_MINUI_CUSTOM_FONTS |
Dima Zavin | 3c7f00e | 2011-08-30 11:58:24 -0700 | [diff] [blame] | 88 | |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 89 | void blend_16bpp(unsigned char* px, unsigned r5, unsigned g5, unsigned b5, unsigned char a) |
| 90 | { |
| 91 | unsigned char orig[2]; |
| 92 | orig[0] = px[0]; |
| 93 | orig[1] = px[1]; |
| 94 | |
| 95 | /* This code is a little easier to read |
| 96 | unsigned oldred = (orig[1] >> 3); |
| 97 | unsigned oldgreen = (((orig[0] >> 5) << 3) + (orig[1] & 0x7)); |
| 98 | unsigned oldblue = (orig[0] & 0x1F); |
| 99 | |
| 100 | unsigned newred = (oldred * (255-a) + r5 * a) / 255; |
| 101 | unsigned newgreen = (oldgreen * (255-a) + g5 * a) / 255; |
| 102 | unsigned newblue = (oldblue * (255-a) + b5 * a) / 255; |
| 103 | */ |
| 104 | |
| 105 | unsigned newred = ((orig[1] >> 3) * (255-a) + r5 * a) / 255; |
| 106 | unsigned newgreen = ((((orig[0] >> 5) << 3) + (orig[1] & 0x7)) * (255-a) + g5 * a) / 255; |
| 107 | unsigned newblue = ((orig[0] & 0x1F) * (255-a) + b5 * a) / 255; |
| 108 | |
| 109 | *px++ = (newgreen << 5) + (newblue); |
| 110 | *px++ = (newred << 3) + (newgreen >> 3); |
| 111 | } |
| 112 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 113 | static void text_blend(unsigned char* src_p, int src_row_bytes, |
| 114 | unsigned char* dst_p, int dst_row_bytes, |
| 115 | int width, int height) |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 116 | { |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 117 | for (int j = 0; j < height; ++j) { |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 118 | unsigned char* sx = src_p; |
| 119 | unsigned char* px = dst_p; |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 120 | for (int i = 0; i < width; ++i) { |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 121 | unsigned char a = *sx++; |
| 122 | if (gr_current_a < 255) a = ((int)a * gr_current_a) / 255; |
| 123 | if (a == 255) { |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 124 | if (gr_draw->pixel_bytes == 2) { |
| 125 | *px++ = rgb_555[0]; |
| 126 | *px++ = rgb_555[1]; |
| 127 | } else { |
| 128 | *px++ = gr_current_r; |
| 129 | *px++ = gr_current_g; |
| 130 | *px++ = gr_current_b; |
| 131 | px++; |
| 132 | } |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 133 | } else if (a > 0) { |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 134 | if (gr_draw->pixel_bytes == 2) { |
| 135 | blend_16bpp(px, gr_current_r5, gr_current_g5, gr_current_b5, a); |
| 136 | px += gr_draw->pixel_bytes; |
| 137 | } else { |
| 138 | *px = (*px * (255-a) + gr_current_r * a) / 255; |
| 139 | ++px; |
| 140 | *px = (*px * (255-a) + gr_current_g * a) / 255; |
| 141 | ++px; |
| 142 | *px = (*px * (255-a) + gr_current_b * a) / 255; |
| 143 | ++px; |
| 144 | ++px; |
| 145 | } |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 146 | } else { |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 147 | px += gr_draw->pixel_bytes; |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | src_p += src_row_bytes; |
| 151 | dst_p += dst_row_bytes; |
| 152 | } |
| 153 | } |
| 154 | |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 155 | #ifdef TW_NO_MINUI_CUSTOM_FONTS |
Elliott Hughes | 8fd86d7 | 2015-04-13 14:36:02 -0700 | [diff] [blame] | 156 | void gr_text(int x, int y, const char *s, bool bold) |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 157 | { |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 158 | GRFont* font = gr_font; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 159 | |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 160 | if (!font->texture || gr_current_a == 0) return; |
Doug Zongker | 55a36ac | 2013-03-04 15:49:02 -0800 | [diff] [blame] | 161 | |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 162 | bold = bold && (font->texture->height != font->char_height); |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 163 | |
Doug Zongker | c560a67 | 2012-12-18 16:31:27 -0800 | [diff] [blame] | 164 | x += overscan_offset_x; |
| 165 | y += overscan_offset_y; |
| 166 | |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 167 | unsigned char ch; |
| 168 | while ((ch = *s++)) { |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 169 | if (outside(x, y) || outside(x+font->char_width-1, y+font->char_height-1)) break; |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 170 | |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 171 | if (ch < ' ' || ch > '~') { |
| 172 | ch = '?'; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 173 | } |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 174 | |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 175 | unsigned char* src_p = font->texture->data + ((ch - ' ') * font->char_width) + |
| 176 | (bold ? font->char_height * font->texture->row_bytes : 0); |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 177 | unsigned char* dst_p = gr_draw->data + y*gr_draw->row_bytes + x*gr_draw->pixel_bytes; |
| 178 | |
| 179 | text_blend(src_p, font->texture->row_bytes, |
| 180 | dst_p, gr_draw->row_bytes, |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 181 | font->char_width, font->char_height); |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 182 | |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 183 | x += font->char_width; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 184 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 185 | } |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 186 | #else //TW_NO_MINUI_CUSTOM_FONTS |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 187 | void gr_text(const GRFont* font, int x, int y, const char *s, bool bold) |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 188 | { |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 189 | if (!font->texture || gr_current_a == 0) return; |
| 190 | |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 191 | bold = bold && (font->texture->height != font->char_height); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 192 | |
| 193 | x += overscan_offset_x; |
| 194 | y += overscan_offset_y; |
| 195 | |
| 196 | unsigned char ch; |
| 197 | while ((ch = *s++)) { |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 198 | if (outside(x, y) || outside(x+font->char_width-1, y+font->char_height-1)) break; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 199 | |
| 200 | if (ch < ' ' || ch > '~') { |
| 201 | ch = '?'; |
| 202 | } |
| 203 | |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 204 | unsigned char* src_p = font->texture->data + ((ch - ' ') * font->char_width) + |
| 205 | (bold ? font->char_height * font->texture->row_bytes : 0); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 206 | unsigned char* dst_p = gr_draw->data + y*gr_draw->row_bytes + x*gr_draw->pixel_bytes; |
| 207 | |
| 208 | text_blend(src_p, font->texture->row_bytes, |
| 209 | dst_p, gr_draw->row_bytes, |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 210 | font->char_width, font->char_height); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 211 | |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 212 | x += font->char_width; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 213 | } |
| 214 | } |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 215 | #endif //TW_NO_MINUI_CUSTOM_FONTS |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 216 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 217 | void gr_texticon(int x, int y, GRSurface* icon) { |
| 218 | if (icon == NULL) return; |
| 219 | |
| 220 | if (icon->pixel_bytes != 1) { |
| 221 | printf("gr_texticon: source has wrong format\n"); |
Doug Zongker | 52eeea4f | 2012-09-04 14:28:25 -0700 | [diff] [blame] | 222 | return; |
| 223 | } |
Doug Zongker | 02ec6b8 | 2012-08-22 17:26:40 -0700 | [diff] [blame] | 224 | |
Doug Zongker | c560a67 | 2012-12-18 16:31:27 -0800 | [diff] [blame] | 225 | x += overscan_offset_x; |
| 226 | y += overscan_offset_y; |
| 227 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 228 | if (outside(x, y) || outside(x+icon->width-1, y+icon->height-1)) return; |
Doug Zongker | 02ec6b8 | 2012-08-22 17:26:40 -0700 | [diff] [blame] | 229 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 230 | unsigned char* src_p = icon->data; |
| 231 | unsigned char* dst_p = gr_draw->data + y*gr_draw->row_bytes + x*gr_draw->pixel_bytes; |
Doug Zongker | 02ec6b8 | 2012-08-22 17:26:40 -0700 | [diff] [blame] | 232 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 233 | text_blend(src_p, icon->row_bytes, |
| 234 | dst_p, gr_draw->row_bytes, |
| 235 | icon->width, icon->height); |
| 236 | } |
| 237 | |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 238 | void gr_convert_rgb_555() |
| 239 | { |
| 240 | gr_current_r5 = (((gr_current_r & 0xFF) * 0x1F) + 0x7F) / 0xFF; |
| 241 | gr_current_g5 = (((gr_current_g & 0xFF) * 0x3F) + 0x7F) / 0xFF; |
| 242 | gr_current_b5 = (((gr_current_b & 0xFF) * 0x1F) + 0x7F) / 0xFF; |
| 243 | |
| 244 | rgb_555[0] = (gr_current_g5 << 5) + (gr_current_b5); |
| 245 | rgb_555[1] = (gr_current_r5 << 3) + (gr_current_g5 >> 3); |
| 246 | } |
| 247 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 248 | void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) |
| 249 | { |
Tony Kuo | fd778e3 | 2015-02-05 21:25:56 +0800 | [diff] [blame] | 250 | #if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA) |
| 251 | gr_current_r = b; |
| 252 | gr_current_g = g; |
| 253 | gr_current_b = r; |
| 254 | gr_current_a = a; |
| 255 | #else |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 256 | gr_current_r = r; |
| 257 | gr_current_g = g; |
| 258 | gr_current_b = b; |
| 259 | gr_current_a = a; |
Tony Kuo | fd778e3 | 2015-02-05 21:25:56 +0800 | [diff] [blame] | 260 | #endif |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 261 | if (gr_draw->pixel_bytes == 2) { |
| 262 | gr_convert_rgb_555(); |
| 263 | } |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | void gr_clear() |
| 267 | { |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 268 | if (gr_draw->pixel_bytes == 2) { |
| 269 | gr_fill(0, 0, gr_fb_width(), gr_fb_height()); |
| 270 | return; |
| 271 | } |
| 272 | |
| 273 | // This code only works on 32bpp devices |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 274 | if (gr_current_r == gr_current_g && gr_current_r == gr_current_b) { |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 275 | memset(gr_draw->data, gr_current_r, gr_draw->height * gr_draw->row_bytes); |
| 276 | } else { |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 277 | unsigned char* px = gr_draw->data; |
Elliott Hughes | 01a4d08 | 2015-03-24 15:21:48 -0700 | [diff] [blame] | 278 | for (int y = 0; y < gr_draw->height; ++y) { |
| 279 | for (int x = 0; x < gr_draw->width; ++x) { |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 280 | *px++ = gr_current_r; |
| 281 | *px++ = gr_current_g; |
| 282 | *px++ = gr_current_b; |
| 283 | px++; |
| 284 | } |
| 285 | px += gr_draw->row_bytes - (gr_draw->width * gr_draw->pixel_bytes); |
| 286 | } |
| 287 | } |
Doug Zongker | 02ec6b8 | 2012-08-22 17:26:40 -0700 | [diff] [blame] | 288 | } |
| 289 | |
Doug Zongker | c560a67 | 2012-12-18 16:31:27 -0800 | [diff] [blame] | 290 | void gr_fill(int x1, int y1, int x2, int y2) |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 291 | { |
Doug Zongker | c560a67 | 2012-12-18 16:31:27 -0800 | [diff] [blame] | 292 | x1 += overscan_offset_x; |
| 293 | y1 += overscan_offset_y; |
| 294 | |
| 295 | x2 += overscan_offset_x; |
| 296 | y2 += overscan_offset_y; |
| 297 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 298 | if (outside(x1, y1) || outside(x2-1, y2-1)) return; |
| 299 | |
| 300 | unsigned char* p = gr_draw->data + y1 * gr_draw->row_bytes + x1 * gr_draw->pixel_bytes; |
| 301 | if (gr_current_a == 255) { |
| 302 | int x, y; |
| 303 | for (y = y1; y < y2; ++y) { |
| 304 | unsigned char* px = p; |
| 305 | for (x = x1; x < x2; ++x) { |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 306 | if (gr_draw->pixel_bytes == 2) { |
| 307 | *px++ = rgb_555[0]; |
| 308 | *px++ = rgb_555[1]; |
| 309 | } else { |
| 310 | *px++ = gr_current_r; |
| 311 | *px++ = gr_current_g; |
| 312 | *px++ = gr_current_b; |
| 313 | px++; |
| 314 | } |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 315 | } |
| 316 | p += gr_draw->row_bytes; |
| 317 | } |
| 318 | } else if (gr_current_a > 0) { |
| 319 | int x, y; |
| 320 | for (y = y1; y < y2; ++y) { |
| 321 | unsigned char* px = p; |
| 322 | for (x = x1; x < x2; ++x) { |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 323 | if (gr_draw->pixel_bytes == 2) { |
| 324 | blend_16bpp(px, gr_current_r5, gr_current_g5, gr_current_b5, gr_current_a); |
| 325 | px += gr_draw->row_bytes; |
| 326 | } else { |
| 327 | *px = (*px * (255-gr_current_a) + gr_current_r * gr_current_a) / 255; |
| 328 | ++px; |
| 329 | *px = (*px * (255-gr_current_a) + gr_current_g * gr_current_a) / 255; |
| 330 | ++px; |
| 331 | *px = (*px * (255-gr_current_a) + gr_current_b * gr_current_a) / 255; |
| 332 | ++px; |
| 333 | ++px; |
| 334 | } |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 335 | } |
| 336 | p += gr_draw->row_bytes; |
| 337 | } |
| 338 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 339 | } |
| 340 | |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 341 | void gr_blit_32to16(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy) { |
| 342 | dx += overscan_offset_x; |
| 343 | dy += overscan_offset_y; |
| 344 | |
| 345 | if (outside(dx, dy) || outside(dx+w-1, dy+h-1)) return; |
| 346 | |
| 347 | unsigned char* src_p = source->data + sy*source->row_bytes + sx*source->pixel_bytes; |
| 348 | unsigned char* dst_p = gr_draw->data + dy*gr_draw->row_bytes + dx*gr_draw->pixel_bytes; |
| 349 | |
| 350 | int i, j; |
| 351 | for (i = 0; i < h; ++i) { |
| 352 | unsigned char* spx = src_p; |
| 353 | unsigned char* dpx = dst_p; |
| 354 | |
| 355 | for (j = 0; j < w; ++j) { |
| 356 | unsigned a = spx[3]; |
| 357 | |
| 358 | if (a == 0) { |
| 359 | spx += source->pixel_bytes; |
| 360 | dpx += gr_draw->pixel_bytes; |
| 361 | } else { |
| 362 | unsigned r5 = (((*spx++ & 0xFF) * 0x1F) + 0x7F) / 0xFF; |
| 363 | unsigned g5 = (((*spx++ & 0xFF) * 0x3F) + 0x7F) / 0xFF; |
| 364 | unsigned b5 = (((*spx++ & 0xFF) * 0x1F) + 0x7F) / 0xFF; |
| 365 | spx++; |
| 366 | if (a == 255) { |
| 367 | *dpx++ = (g5 << 5) + (b5); |
| 368 | *dpx++ = (r5 << 3) + (g5 >> 3); |
| 369 | } else { |
| 370 | blend_16bpp(dpx, r5, g5, b5, a); |
| 371 | spx += source->pixel_bytes; |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | src_p += source->row_bytes; |
| 376 | dst_p += gr_draw->row_bytes; |
| 377 | } |
| 378 | } |
| 379 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 380 | void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy) { |
| 381 | if (source == NULL) return; |
| 382 | |
| 383 | if (gr_draw->pixel_bytes != source->pixel_bytes) { |
Ethan Yonker | e96182e | 2015-10-13 19:32:03 -0500 | [diff] [blame] | 384 | if (gr_draw->pixel_bytes == 2 && source->pixel_bytes == 4) { |
| 385 | gr_blit_32to16(source, sx, sy, w, h, dx, dy); |
| 386 | return; |
| 387 | } else { |
| 388 | printf("gr_blit: source has wrong format\n"); |
| 389 | return; |
| 390 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 391 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 392 | |
Doug Zongker | c560a67 | 2012-12-18 16:31:27 -0800 | [diff] [blame] | 393 | dx += overscan_offset_x; |
| 394 | dy += overscan_offset_y; |
| 395 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 396 | if (outside(dx, dy) || outside(dx+w-1, dy+h-1)) return; |
| 397 | |
| 398 | unsigned char* src_p = source->data + sy*source->row_bytes + sx*source->pixel_bytes; |
| 399 | unsigned char* dst_p = gr_draw->data + dy*gr_draw->row_bytes + dx*gr_draw->pixel_bytes; |
| 400 | |
| 401 | int i; |
| 402 | for (i = 0; i < h; ++i) { |
| 403 | memcpy(dst_p, src_p, w * source->pixel_bytes); |
| 404 | src_p += source->row_bytes; |
| 405 | dst_p += gr_draw->row_bytes; |
| 406 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 407 | } |
| 408 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 409 | unsigned int gr_get_width(GRSurface* surface) { |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 410 | if (surface == NULL) { |
| 411 | return 0; |
| 412 | } |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 413 | return surface->width; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 414 | } |
| 415 | |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 416 | unsigned int gr_get_height(GRSurface* surface) { |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 417 | if (surface == NULL) { |
| 418 | return 0; |
| 419 | } |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 420 | return surface->height; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 421 | } |
| 422 | |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 423 | #ifdef TW_NO_MINUI_CUSTOM_FONTS |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 424 | static void gr_init_font(void) |
| 425 | { |
Elliott Hughes | 07cfb8f | 2015-04-10 13:12:05 -0700 | [diff] [blame] | 426 | gr_font = reinterpret_cast<GRFont*>(calloc(sizeof(*gr_font), 1)); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 427 | |
Doug Zongker | a418aa7 | 2014-03-17 12:10:02 -0700 | [diff] [blame] | 428 | int res = res_create_alpha_surface("font", &(gr_font->texture)); |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 429 | if (res == 0) { |
| 430 | // The font image should be a 96x2 array of character images. The |
| 431 | // columns are the printable ASCII characters 0x20 - 0x7f. The |
| 432 | // top row is regular text; the bottom row is bold. |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 433 | gr_font->char_width = gr_font->texture->width / 96; |
| 434 | gr_font->char_height = gr_font->texture->height / 2; |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 435 | } else { |
Doug Zongker | 55a36ac | 2013-03-04 15:49:02 -0800 | [diff] [blame] | 436 | printf("failed to read font: res=%d\n", res); |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 437 | |
| 438 | // fall back to the compiled-in font. |
Elliott Hughes | 07cfb8f | 2015-04-10 13:12:05 -0700 | [diff] [blame] | 439 | gr_font->texture = reinterpret_cast<GRSurface*>(malloc(sizeof(*gr_font->texture))); |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 440 | gr_font->texture->width = font.width; |
| 441 | gr_font->texture->height = font.height; |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 442 | gr_font->texture->row_bytes = font.width; |
| 443 | gr_font->texture->pixel_bytes = 1; |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 444 | |
Elliott Hughes | 07cfb8f | 2015-04-10 13:12:05 -0700 | [diff] [blame] | 445 | unsigned char* bits = reinterpret_cast<unsigned char*>(malloc(font.width * font.height)); |
| 446 | gr_font->texture->data = reinterpret_cast<unsigned char*>(bits); |
Doug Zongker | 6fd59ac | 2013-03-06 15:01:11 -0800 | [diff] [blame] | 447 | |
| 448 | unsigned char data; |
| 449 | unsigned char* in = font.rundata; |
| 450 | while((data = *in++)) { |
| 451 | memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f); |
| 452 | bits += (data & 0x7f); |
| 453 | } |
| 454 | |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 455 | gr_font->char_width = font.char_width; |
| 456 | gr_font->char_height = font.char_height; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 457 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 458 | } |
| 459 | |
Ethan Yonker | 84d61ce | 2017-05-10 16:11:35 -0500 | [diff] [blame] | 460 | void gr_set_font(__attribute__ ((unused))const char* name) { |
| 461 | //this cm function is made to change font. Don't care, just init the font: |
| 462 | gr_init_font(); |
| 463 | return; |
| 464 | } |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 465 | #else // TW_NO_MINUI_CUSTOM_FONTS |
Damien Bargiacchi | d00f5eb | 2016-09-09 07:14:08 -0700 | [diff] [blame] | 466 | int gr_init_font(const char* name, GRFont** dest) { |
Rahul Chaudhry | 4f7faac | 2016-11-08 16:06:13 -0800 | [diff] [blame] | 467 | GRFont* font = static_cast<GRFont*>(calloc(1, sizeof(*gr_font))); |
Damien Bargiacchi | d00f5eb | 2016-09-09 07:14:08 -0700 | [diff] [blame] | 468 | if (font == nullptr) { |
| 469 | return -1; |
| 470 | } |
| 471 | |
| 472 | int res = res_create_alpha_surface(name, &(font->texture)); |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 473 | if (res < 0) { |
Damien Bargiacchi | d00f5eb | 2016-09-09 07:14:08 -0700 | [diff] [blame] | 474 | free(font); |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 475 | return res; |
| 476 | } |
| 477 | |
| 478 | // The font image should be a 96x2 array of character images. The |
| 479 | // columns are the printable ASCII characters 0x20 - 0x7f. The |
| 480 | // top row is regular text; the bottom row is bold. |
Damien Bargiacchi | d00f5eb | 2016-09-09 07:14:08 -0700 | [diff] [blame] | 481 | font->char_width = font->texture->width / 96; |
| 482 | font->char_height = font->texture->height / 2; |
| 483 | |
| 484 | *dest = font; |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 485 | |
| 486 | return 0; |
| 487 | } |
| 488 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 489 | static void gr_init_font(void) |
| 490 | { |
Damien Bargiacchi | d00f5eb | 2016-09-09 07:14:08 -0700 | [diff] [blame] | 491 | int res = gr_init_font("font", &gr_font); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 492 | if (res == 0) { |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 493 | return; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 494 | } |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 495 | |
| 496 | printf("failed to read font: res=%d\n", res); |
| 497 | |
Damien Bargiacchi | d00f5eb | 2016-09-09 07:14:08 -0700 | [diff] [blame] | 498 | |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 499 | // fall back to the compiled-in font. |
Rahul Chaudhry | 4f7faac | 2016-11-08 16:06:13 -0800 | [diff] [blame] | 500 | gr_font = static_cast<GRFont*>(calloc(1, sizeof(*gr_font))); |
| 501 | gr_font->texture = static_cast<GRSurface*>(malloc(sizeof(*gr_font->texture))); |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 502 | gr_font->texture->width = font.width; |
| 503 | gr_font->texture->height = font.height; |
| 504 | gr_font->texture->row_bytes = font.width; |
| 505 | gr_font->texture->pixel_bytes = 1; |
| 506 | |
Rahul Chaudhry | 4f7faac | 2016-11-08 16:06:13 -0800 | [diff] [blame] | 507 | unsigned char* bits = static_cast<unsigned char*>(malloc(font.width * font.height)); |
Rahul Chaudhry | 1cf93f5 | 2016-11-08 16:35:22 -0800 | [diff] [blame] | 508 | gr_font->texture->data = bits; |
Damien Bargiacchi | 35fff61 | 2016-08-11 15:57:03 -0700 | [diff] [blame] | 509 | |
| 510 | unsigned char data; |
| 511 | unsigned char* in = font.rundata; |
| 512 | while((data = *in++)) { |
| 513 | memset(bits, (data & 0x80) ? 255 : 0, data & 0x7f); |
| 514 | bits += (data & 0x7f); |
| 515 | } |
| 516 | |
| 517 | gr_font->char_width = font.char_width; |
| 518 | gr_font->char_height = font.char_height; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 519 | } |
Ethan Yonker | 39662b2 | 2017-05-23 08:34:02 -0500 | [diff] [blame] | 520 | #endif // TW_NO_MINUI_CUSTOM_FONTS |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 521 | |
Doug Zongker | 5290f20 | 2014-03-11 13:22:04 -0700 | [diff] [blame] | 522 | void gr_flip() { |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 523 | gr_draw = gr_backend->Flip(); |
Doug Zongker | 5290f20 | 2014-03-11 13:22:04 -0700 | [diff] [blame] | 524 | } |
| 525 | |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 526 | int gr_init(void) |
| 527 | { |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 528 | gr_init_font(); |
Doug Zongker | 16f97c3 | 2014-03-06 16:16:05 -0800 | [diff] [blame] | 529 | |
Ethan Yonker | 8373cfe | 2017-09-08 06:50:54 -0500 | [diff] [blame] | 530 | auto backend = std::unique_ptr<MinuiBackend>{ std::make_unique<MinuiBackendOverlay>() }; |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 531 | gr_draw = backend->Init(); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 532 | |
Ethan Yonker | b386f71 | 2017-01-20 14:30:28 -0600 | [diff] [blame] | 533 | #ifdef MSM_BSP |
Ethan Yonker | 8373cfe | 2017-09-08 06:50:54 -0500 | [diff] [blame] | 534 | if (gr_draw) { |
| 535 | printf("Using overlay graphics.\n"); |
Ethan Yonker | a59da09 | 2015-10-13 19:35:05 -0500 | [diff] [blame] | 536 | } |
Ethan Yonker | b386f71 | 2017-01-20 14:30:28 -0600 | [diff] [blame] | 537 | #endif |
Ethan Yonker | a59da09 | 2015-10-13 19:35:05 -0500 | [diff] [blame] | 538 | |
| 539 | #ifndef MSM_BSP |
Ethan Yonker | 8373cfe | 2017-09-08 06:50:54 -0500 | [diff] [blame] | 540 | if (!gr_draw) { |
| 541 | backend = std::make_unique<MinuiBackendAdf>(); |
| 542 | gr_draw = backend->Init(); |
| 543 | if (gr_draw) |
| 544 | printf("Using adf graphics.\n"); |
Greg Hackmann | 41909dd | 2014-04-25 10:39:50 -0700 | [diff] [blame] | 545 | } |
Ethan Yonker | a59da09 | 2015-10-13 19:35:05 -0500 | [diff] [blame] | 546 | #else |
| 547 | printf("Skipping adf graphics because TW_TARGET_USES_QCOM_BSP := true\n"); |
| 548 | #endif |
Greg Hackmann | 41909dd | 2014-04-25 10:39:50 -0700 | [diff] [blame] | 549 | |
Ethan Yonker | 8373cfe | 2017-09-08 06:50:54 -0500 | [diff] [blame] | 550 | if (!gr_draw) { |
| 551 | backend = std::make_unique<MinuiBackendDrm>(); |
| 552 | gr_draw = backend->Init(); |
Ethan Yonker | a59da09 | 2015-10-13 19:35:05 -0500 | [diff] [blame] | 553 | if (gr_draw) |
| 554 | printf("Using drm graphics.\n"); |
Stéphane Marchesin | 1a92c44 | 2015-06-29 20:05:48 -0700 | [diff] [blame] | 555 | } |
| 556 | |
Ethan Yonker | 8373cfe | 2017-09-08 06:50:54 -0500 | [diff] [blame] | 557 | if (!gr_draw) { |
| 558 | backend = std::make_unique<MinuiBackendFbdev>(); |
| 559 | gr_draw = backend->Init(); |
| 560 | if (gr_draw) |
Ethan Yonker | a59da09 | 2015-10-13 19:35:05 -0500 | [diff] [blame] | 561 | printf("Using fbdev graphics.\n"); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 562 | } |
| 563 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 564 | if (!gr_draw) { |
| 565 | return -1; |
| 566 | } |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 567 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 568 | gr_backend = backend.release(); |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 569 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 570 | overscan_offset_x = gr_draw->width * overscan_percent / 100; |
| 571 | overscan_offset_y = gr_draw->height * overscan_percent / 100; |
| 572 | |
| 573 | gr_flip(); |
| 574 | gr_flip(); |
| 575 | |
| 576 | return 0; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 577 | } |
| 578 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 579 | void gr_exit() { |
| 580 | delete gr_backend; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 581 | } |
| 582 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 583 | int gr_fb_width() { |
| 584 | return gr_draw->width - 2 * overscan_offset_x; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 585 | } |
| 586 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 587 | int gr_fb_height() { |
| 588 | return gr_draw->height - 2 * overscan_offset_y; |
The Android Open Source Project | c24a8e6 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 589 | } |
Dima Zavin | 4daf48a | 2011-08-30 11:59:20 -0700 | [diff] [blame] | 590 | |
Tao Bao | 557fa1f | 2017-02-07 12:51:00 -0800 | [diff] [blame] | 591 | void gr_fb_blank(bool blank) { |
| 592 | gr_backend->Blank(blank); |
Dima Zavin | 4daf48a | 2011-08-30 11:59:20 -0700 | [diff] [blame] | 593 | } |