aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2015-04-15 12:58:56 -0500
committerElliott Hughes2015-04-15 12:58:56 -0500
commit0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9 (patch)
tree625c21a7688ed613dd22fc9fc9e6c68cec7c44bc
parent6e435abfeb7256b5ea82ca37166acf36e3f98085 (diff)
downloadplatform-bootable-recovery-0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9.tar.gz
platform-bootable-recovery-0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9.tar.xz
platform-bootable-recovery-0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9.zip
Don't use typedefs that hide *s.
gr_surface was causing confusion for no good reason. Change-Id: If7120187f9a00dd16297877fc49352185a4d4ea6
-rw-r--r--minui/graphics.cpp2
-rw-r--r--minui/graphics.h6
-rw-r--r--minui/graphics_adf.cpp8
-rw-r--r--minui/graphics_fbdev.cpp8
-rw-r--r--minui/minui.h21
-rw-r--r--minui/resources.cpp36
-rw-r--r--screen_ui.cpp12
-rw-r--r--screen_ui.h20
8 files changed, 54 insertions, 59 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index f240f4bb..f09f1c6b 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -326,7 +326,7 @@ static void gr_test() {
326 gr_clear(); 326 gr_clear();
327 327
328 gr_color(255, 0, 0, 255); 328 gr_color(255, 0, 0, 255);
329 gr_surface frame = images[x%frames]; 329 GRSurface* frame = images[x%frames];
330 gr_blit(frame, 0, 0, frame->width, frame->height, x, 0); 330 gr_blit(frame, 0, 0, frame->width, frame->height, x, 0);
331 331
332 gr_color(255, 0, 0, 128); 332 gr_color(255, 0, 0, 128);
diff --git a/minui/graphics.h b/minui/graphics.h
index ed229a0c..81a92338 100644
--- a/minui/graphics.h
+++ b/minui/graphics.h
@@ -21,13 +21,13 @@
21 21
22// TODO: lose the function pointers. 22// TODO: lose the function pointers.
23struct minui_backend { 23struct minui_backend {
24 // Initializes the backend and returns a gr_surface to draw into. 24 // Initializes the backend and returns a GRSurface* to draw into.
25 gr_surface (*init)(minui_backend*); 25 GRSurface* (*init)(minui_backend*);
26 26
27 // Causes the current drawing surface (returned by the most recent 27 // Causes the current drawing surface (returned by the most recent
28 // call to flip() or init()) to be displayed, and returns a new 28 // call to flip() or init()) to be displayed, and returns a new
29 // drawing surface. 29 // drawing surface.
30 gr_surface (*flip)(minui_backend*); 30 GRSurface* (*flip)(minui_backend*);
31 31
32 // Blank (or unblank) the screen. 32 // Blank (or unblank) the screen.
33 void (*blank)(minui_backend*, bool); 33 void (*blank)(minui_backend*, bool);
diff --git a/minui/graphics_adf.cpp b/minui/graphics_adf.cpp
index ea7c0abe..5d0867f5 100644
--- a/minui/graphics_adf.cpp
+++ b/minui/graphics_adf.cpp
@@ -47,7 +47,7 @@ struct adf_pdata {
47 adf_surface_pdata surfaces[2]; 47 adf_surface_pdata surfaces[2];
48}; 48};
49 49
50static gr_surface adf_flip(minui_backend *backend); 50static GRSurface* adf_flip(minui_backend *backend);
51static void adf_blank(minui_backend *backend, bool blank); 51static void adf_blank(minui_backend *backend, bool blank);
52 52
53static int adf_surface_init(adf_pdata *pdata, drm_mode_modeinfo *mode, adf_surface_pdata *surf) { 53static int adf_surface_init(adf_pdata *pdata, drm_mode_modeinfo *mode, adf_surface_pdata *surf) {
@@ -134,12 +134,12 @@ static int adf_device_init(adf_pdata *pdata, adf_device *dev)
134 return err; 134 return err;
135} 135}
136 136
137static gr_surface adf_init(minui_backend *backend) 137static GRSurface* adf_init(minui_backend *backend)
138{ 138{
139 adf_pdata *pdata = (adf_pdata *)backend; 139 adf_pdata *pdata = (adf_pdata *)backend;
140 adf_id_t *dev_ids = NULL; 140 adf_id_t *dev_ids = NULL;
141 ssize_t n_dev_ids, i; 141 ssize_t n_dev_ids, i;
142 gr_surface ret; 142 GRSurface* ret;
143 143
144#if defined(RECOVERY_ABGR) 144#if defined(RECOVERY_ABGR)
145 pdata->format = DRM_FORMAT_ABGR8888; 145 pdata->format = DRM_FORMAT_ABGR8888;
@@ -193,7 +193,7 @@ static gr_surface adf_init(minui_backend *backend)
193 return ret; 193 return ret;
194} 194}
195 195
196static gr_surface adf_flip(minui_backend *backend) 196static GRSurface* adf_flip(minui_backend *backend)
197{ 197{
198 adf_pdata *pdata = (adf_pdata *)backend; 198 adf_pdata *pdata = (adf_pdata *)backend;
199 adf_surface_pdata *surf = &pdata->surfaces[pdata->current_surface]; 199 adf_surface_pdata *surf = &pdata->surfaces[pdata->current_surface];
diff --git a/minui/graphics_fbdev.cpp b/minui/graphics_fbdev.cpp
index 9dbdde81..997e9cac 100644
--- a/minui/graphics_fbdev.cpp
+++ b/minui/graphics_fbdev.cpp
@@ -33,8 +33,8 @@
33#include "minui.h" 33#include "minui.h"
34#include "graphics.h" 34#include "graphics.h"
35 35
36static gr_surface fbdev_init(minui_backend*); 36static GRSurface* fbdev_init(minui_backend*);
37static gr_surface fbdev_flip(minui_backend*); 37static GRSurface* fbdev_flip(minui_backend*);
38static void fbdev_blank(minui_backend*, bool); 38static void fbdev_blank(minui_backend*, bool);
39static void fbdev_exit(minui_backend*); 39static void fbdev_exit(minui_backend*);
40 40
@@ -79,7 +79,7 @@ static void set_displayed_framebuffer(unsigned n)
79 displayed_buffer = n; 79 displayed_buffer = n;
80} 80}
81 81
82static gr_surface fbdev_init(minui_backend* backend) { 82static GRSurface* fbdev_init(minui_backend* backend) {
83 int fd = open("/dev/graphics/fb0", O_RDWR); 83 int fd = open("/dev/graphics/fb0", O_RDWR);
84 if (fd == -1) { 84 if (fd == -1) {
85 perror("cannot open fb0"); 85 perror("cannot open fb0");
@@ -174,7 +174,7 @@ static gr_surface fbdev_init(minui_backend* backend) {
174 return gr_draw; 174 return gr_draw;
175} 175}
176 176
177static gr_surface fbdev_flip(minui_backend* backend __unused) { 177static GRSurface* fbdev_flip(minui_backend* backend __unused) {
178 if (double_buffered) { 178 if (double_buffered) {
179#if defined(RECOVERY_BGRA) 179#if defined(RECOVERY_BGRA)
180 // In case of BGRA, do some byte swapping 180 // In case of BGRA, do some byte swapping
diff --git a/minui/minui.h b/minui/minui.h
index 936f7eec..bdde083f 100644
--- a/minui/minui.h
+++ b/minui/minui.h
@@ -33,9 +33,6 @@ struct GRSurface {
33 unsigned char* data; 33 unsigned char* data;
34}; 34};
35 35
36// TODO: remove this.
37typedef GRSurface* gr_surface;
38
39int gr_init(); 36int gr_init();
40void gr_exit(); 37void gr_exit();
41 38
@@ -49,13 +46,13 @@ void gr_clear(); // clear entire surface to current color
49void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); 46void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
50void gr_fill(int x1, int y1, int x2, int y2); 47void gr_fill(int x1, int y1, int x2, int y2);
51void gr_text(int x, int y, const char *s, bool bold); 48void gr_text(int x, int y, const char *s, bool bold);
52void gr_texticon(int x, int y, gr_surface icon); 49void gr_texticon(int x, int y, GRSurface* icon);
53int gr_measure(const char *s); 50int gr_measure(const char *s);
54void gr_font_size(int *x, int *y); 51void gr_font_size(int *x, int *y);
55 52
56void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); 53void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy);
57unsigned int gr_get_width(gr_surface surface); 54unsigned int gr_get_width(GRSurface* surface);
58unsigned int gr_get_height(gr_surface surface); 55unsigned int gr_get_height(GRSurface* surface);
59 56
60// 57//
61// Input events. 58// Input events.
@@ -98,17 +95,17 @@ int ev_get_epollfd();
98// All these functions load PNG images from "/res/images/${name}.png". 95// All these functions load PNG images from "/res/images/${name}.png".
99 96
100// Load a single display surface from a PNG image. 97// Load a single display surface from a PNG image.
101int res_create_display_surface(const char* name, gr_surface* pSurface); 98int res_create_display_surface(const char* name, GRSurface** pSurface);
102 99
103// Load an array of display surfaces from a single PNG image. The PNG 100// Load an array of display surfaces from a single PNG image. The PNG
104// should have a 'Frames' text chunk whose value is the number of 101// should have a 'Frames' text chunk whose value is the number of
105// frames this image represents. The pixel data itself is interlaced 102// frames this image represents. The pixel data itself is interlaced
106// by row. 103// by row.
107int res_create_multi_display_surface(const char* name, 104int res_create_multi_display_surface(const char* name,
108 int* frames, gr_surface** pSurface); 105 int* frames, GRSurface*** pSurface);
109 106
110// Load a single alpha surface from a grayscale PNG image. 107// Load a single alpha surface from a grayscale PNG image.
111int res_create_alpha_surface(const char* name, gr_surface* pSurface); 108int res_create_alpha_surface(const char* name, GRSurface** pSurface);
112 109
113// Load part of a grayscale PNG image that is the first match for the 110// Load part of a grayscale PNG image that is the first match for the
114// given locale. The image is expected to be a composite of multiple 111// given locale. The image is expected to be a composite of multiple
@@ -117,10 +114,10 @@ int res_create_alpha_surface(const char* name, gr_surface* pSurface);
117// development/tools/recovery_l10n for an app that will generate these 114// development/tools/recovery_l10n for an app that will generate these
118// specialized images from Android resources. 115// specialized images from Android resources.
119int res_create_localized_alpha_surface(const char* name, const char* locale, 116int res_create_localized_alpha_surface(const char* name, const char* locale,
120 gr_surface* pSurface); 117 GRSurface** pSurface);
121 118
122// Free a surface allocated by any of the res_create_*_surface() 119// Free a surface allocated by any of the res_create_*_surface()
123// functions. 120// functions.
124void res_free_surface(gr_surface surface); 121void res_free_surface(GRSurface* surface);
125 122
126#endif 123#endif
diff --git a/minui/resources.cpp b/minui/resources.cpp
index fa413b60..5e478927 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -36,11 +36,11 @@ extern char* locale;
36 36
37#define SURFACE_DATA_ALIGNMENT 8 37#define SURFACE_DATA_ALIGNMENT 8
38 38
39static gr_surface malloc_surface(size_t data_size) { 39static GRSurface* malloc_surface(size_t data_size) {
40 size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT; 40 size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT;
41 unsigned char* temp = reinterpret_cast<unsigned char*>(malloc(size)); 41 unsigned char* temp = reinterpret_cast<unsigned char*>(malloc(size));
42 if (temp == NULL) return NULL; 42 if (temp == NULL) return NULL;
43 gr_surface surface = (gr_surface) temp; 43 GRSurface* surface = reinterpret_cast<GRSurface*>(temp);
44 surface->data = temp + sizeof(GRSurface) + 44 surface->data = temp + sizeof(GRSurface) +
45 (SURFACE_DATA_ALIGNMENT - (sizeof(GRSurface) % SURFACE_DATA_ALIGNMENT)); 45 (SURFACE_DATA_ALIGNMENT - (sizeof(GRSurface) % SURFACE_DATA_ALIGNMENT));
46 return surface; 46 return surface;
@@ -138,12 +138,10 @@ static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr,
138// framebuffer pixel format; they need to be modified if the 138// framebuffer pixel format; they need to be modified if the
139// framebuffer format changes (but nothing else should). 139// framebuffer format changes (but nothing else should).
140 140
141// Allocate and return a gr_surface sufficient for storing an image of 141// Allocate and return a GRSurface* sufficient for storing an image of
142// the indicated size in the framebuffer pixel format. 142// the indicated size in the framebuffer pixel format.
143static gr_surface init_display_surface(png_uint_32 width, png_uint_32 height) { 143static GRSurface* init_display_surface(png_uint_32 width, png_uint_32 height) {
144 gr_surface surface; 144 GRSurface* surface = malloc_surface(width * height * 4);
145
146 surface = malloc_surface(width * height * 4);
147 if (surface == NULL) return NULL; 145 if (surface == NULL) return NULL;
148 146
149 surface->width = width; 147 surface->width = width;
@@ -199,8 +197,8 @@ static void transform_rgb_to_draw(unsigned char* input_row,
199 } 197 }
200} 198}
201 199
202int res_create_display_surface(const char* name, gr_surface* pSurface) { 200int res_create_display_surface(const char* name, GRSurface** pSurface) {
203 gr_surface surface = NULL; 201 GRSurface* surface = NULL;
204 int result = 0; 202 int result = 0;
205 png_structp png_ptr = NULL; 203 png_structp png_ptr = NULL;
206 png_infop info_ptr = NULL; 204 png_infop info_ptr = NULL;
@@ -239,8 +237,8 @@ int res_create_display_surface(const char* name, gr_surface* pSurface) {
239 return result; 237 return result;
240} 238}
241 239
242int res_create_multi_display_surface(const char* name, int* frames, gr_surface** pSurface) { 240int res_create_multi_display_surface(const char* name, int* frames, GRSurface*** pSurface) {
243 gr_surface* surface = NULL; 241 GRSurface** surface = NULL;
244 int result = 0; 242 int result = 0;
245 png_structp png_ptr = NULL; 243 png_structp png_ptr = NULL;
246 png_infop info_ptr = NULL; 244 png_infop info_ptr = NULL;
@@ -275,7 +273,7 @@ int res_create_multi_display_surface(const char* name, int* frames, gr_surface**
275 goto exit; 273 goto exit;
276 } 274 }
277 275
278 surface = reinterpret_cast<gr_surface*>(malloc(*frames * sizeof(gr_surface))); 276 surface = reinterpret_cast<GRSurface**>(malloc(*frames * sizeof(GRSurface*)));
279 if (surface == NULL) { 277 if (surface == NULL) {
280 result = -8; 278 result = -8;
281 goto exit; 279 goto exit;
@@ -302,7 +300,7 @@ int res_create_multi_display_surface(const char* name, int* frames, gr_surface**
302 } 300 }
303 free(p_row); 301 free(p_row);
304 302
305 *pSurface = (gr_surface*) surface; 303 *pSurface = reinterpret_cast<GRSurface**>(surface);
306 304
307exit: 305exit:
308 png_destroy_read_struct(&png_ptr, &info_ptr, NULL); 306 png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -318,8 +316,8 @@ exit:
318 return result; 316 return result;
319} 317}
320 318
321int res_create_alpha_surface(const char* name, gr_surface* pSurface) { 319int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
322 gr_surface surface = NULL; 320 GRSurface* surface = NULL;
323 int result = 0; 321 int result = 0;
324 png_structp png_ptr = NULL; 322 png_structp png_ptr = NULL;
325 png_infop info_ptr = NULL; 323 png_infop info_ptr = NULL;
@@ -384,8 +382,8 @@ static int matches_locale(const char* loc, const char* locale) {
384 382
385int res_create_localized_alpha_surface(const char* name, 383int res_create_localized_alpha_surface(const char* name,
386 const char* locale, 384 const char* locale,
387 gr_surface* pSurface) { 385 GRSurface** pSurface) {
388 gr_surface surface = NULL; 386 GRSurface* surface = NULL;
389 int result = 0; 387 int result = 0;
390 png_structp png_ptr = NULL; 388 png_structp png_ptr = NULL;
391 png_infop info_ptr = NULL; 389 png_infop info_ptr = NULL;
@@ -440,7 +438,7 @@ int res_create_localized_alpha_surface(const char* name,
440 memcpy(surface->data + i*w, row, w); 438 memcpy(surface->data + i*w, row, w);
441 } 439 }
442 440
443 *pSurface = (gr_surface) surface; 441 *pSurface = reinterpret_cast<GRSurface*>(surface);
444 break; 442 break;
445 } else { 443 } else {
446 int i; 444 int i;
@@ -456,6 +454,6 @@ exit:
456 return result; 454 return result;
457} 455}
458 456
459void res_free_surface(gr_surface surface) { 457void res_free_surface(GRSurface* surface) {
460 free(surface); 458 free(surface);
461} 459}
diff --git a/screen_ui.cpp b/screen_ui.cpp
index 52f22c24..5e73d37c 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -89,11 +89,11 @@ void ScreenRecoveryUI::draw_background_locked(Icon icon) {
89 gr_clear(); 89 gr_clear();
90 90
91 if (icon) { 91 if (icon) {
92 gr_surface surface = backgroundIcon[icon]; 92 GRSurface* surface = backgroundIcon[icon];
93 if (icon == INSTALLING_UPDATE || icon == ERASING) { 93 if (icon == INSTALLING_UPDATE || icon == ERASING) {
94 surface = installation[installingFrame]; 94 surface = installation[installingFrame];
95 } 95 }
96 gr_surface text_surface = backgroundText[icon]; 96 GRSurface* text_surface = backgroundText[icon];
97 97
98 int iconWidth = gr_get_width(surface); 98 int iconWidth = gr_get_width(surface);
99 int iconHeight = gr_get_height(surface); 99 int iconHeight = gr_get_height(surface);
@@ -132,7 +132,7 @@ void ScreenRecoveryUI::draw_progress_locked() {
132 if (currentIcon == ERROR) return; 132 if (currentIcon == ERROR) return;
133 133
134 if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) { 134 if (currentIcon == INSTALLING_UPDATE || currentIcon == ERASING) {
135 gr_surface icon = installation[installingFrame]; 135 GRSurface* icon = installation[installingFrame];
136 gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY); 136 gr_blit(icon, 0, 0, gr_get_width(icon), gr_get_height(icon), iconX, iconY);
137 } 137 }
138 138
@@ -357,21 +357,21 @@ void ScreenRecoveryUI::ProgressThreadLoop() {
357 } 357 }
358} 358}
359 359
360void ScreenRecoveryUI::LoadBitmap(const char* filename, gr_surface* surface) { 360void ScreenRecoveryUI::LoadBitmap(const char* filename, GRSurface** surface) {
361 int result = res_create_display_surface(filename, surface); 361 int result = res_create_display_surface(filename, surface);
362 if (result < 0) { 362 if (result < 0) {
363 LOGE("missing bitmap %s\n(Code %d)\n", filename, result); 363 LOGE("missing bitmap %s\n(Code %d)\n", filename, result);
364 } 364 }
365} 365}
366 366
367void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, gr_surface** surface) { 367void ScreenRecoveryUI::LoadBitmapArray(const char* filename, int* frames, GRSurface*** surface) {
368 int result = res_create_multi_display_surface(filename, frames, surface); 368 int result = res_create_multi_display_surface(filename, frames, surface);
369 if (result < 0) { 369 if (result < 0) {
370 LOGE("missing bitmap %s\n(Code %d)\n", filename, result); 370 LOGE("missing bitmap %s\n(Code %d)\n", filename, result);
371 } 371 }
372} 372}
373 373
374void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, gr_surface* surface) { 374void ScreenRecoveryUI::LoadLocalizedBitmap(const char* filename, GRSurface** surface) {
375 int result = res_create_localized_alpha_surface(filename, locale, surface); 375 int result = res_create_localized_alpha_surface(filename, locale, surface);
376 if (result < 0) { 376 if (result < 0) {
377 LOGE("missing bitmap %s\n(Code %d)\n", filename, result); 377 LOGE("missing bitmap %s\n(Code %d)\n", filename, result);
diff --git a/screen_ui.h b/screen_ui.h
index d473b8e9..46165d90 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -73,13 +73,13 @@ class ScreenRecoveryUI : public RecoveryUI {
73 bool rtl_locale; 73 bool rtl_locale;
74 74
75 pthread_mutex_t updateMutex; 75 pthread_mutex_t updateMutex;
76 gr_surface backgroundIcon[5]; 76 GRSurface* backgroundIcon[5];
77 gr_surface backgroundText[5]; 77 GRSurface* backgroundText[5];
78 gr_surface *installation; 78 GRSurface** installation;
79 gr_surface progressBarEmpty; 79 GRSurface* progressBarEmpty;
80 gr_surface progressBarFill; 80 GRSurface* progressBarFill;
81 gr_surface stageMarkerEmpty; 81 GRSurface* stageMarkerEmpty;
82 gr_surface stageMarkerFill; 82 GRSurface* stageMarkerFill;
83 83
84 ProgressType progressBarType; 84 ProgressType progressBarType;
85 85
@@ -127,9 +127,9 @@ class ScreenRecoveryUI : public RecoveryUI {
127 void DrawTextLine(int* y, const char* line, bool bold); 127 void DrawTextLine(int* y, const char* line, bool bold);
128 void DrawTextLines(int* y, const char* const* lines); 128 void DrawTextLines(int* y, const char* const* lines);
129 129
130 void LoadBitmap(const char* filename, gr_surface* surface); 130 void LoadBitmap(const char* filename, GRSurface** surface);
131 void LoadBitmapArray(const char* filename, int* frames, gr_surface** surface); 131 void LoadBitmapArray(const char* filename, int* frames, GRSurface*** surface);
132 void LoadLocalizedBitmap(const char* filename, gr_surface* surface); 132 void LoadLocalizedBitmap(const char* filename, GRSurface** surface);
133}; 133};
134 134
135#endif // RECOVERY_UI_H 135#endif // RECOVERY_UI_H