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