summaryrefslogtreecommitdiffstats
path: root/minui
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-15 20:36:32 +0200
committerAndroid Git Automerger <android-git-automerger@android.com>2015-04-15 20:36:32 +0200
commit0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce (patch)
tree625c21a7688ed613dd22fc9fc9e6c68cec7c44bc /minui
parentam 6e435abf: Merge "Move the menu header out of the menu." (diff)
parentMerge "Don't use typedefs that hide *s." (diff)
downloadandroid_bootable_recovery-0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce.tar
android_bootable_recovery-0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce.tar.gz
android_bootable_recovery-0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce.tar.bz2
android_bootable_recovery-0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce.tar.lz
android_bootable_recovery-0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce.tar.xz
android_bootable_recovery-0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce.tar.zst
android_bootable_recovery-0a557b6bc2a26afd3cb3a2e3dd2fdaf175b09cce.zip
Diffstat (limited to 'minui')
-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
6 files changed, 38 insertions, 43 deletions
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index f240f4bbd..f09f1c6b0 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -326,7 +326,7 @@ static void gr_test() {
gr_clear();
gr_color(255, 0, 0, 255);
- gr_surface frame = images[x%frames];
+ GRSurface* frame = images[x%frames];
gr_blit(frame, 0, 0, frame->width, frame->height, x, 0);
gr_color(255, 0, 0, 128);
diff --git a/minui/graphics.h b/minui/graphics.h
index ed229a0c8..81a923383 100644
--- a/minui/graphics.h
+++ b/minui/graphics.h
@@ -21,13 +21,13 @@
// TODO: lose the function pointers.
struct minui_backend {
- // Initializes the backend and returns a gr_surface to draw into.
- gr_surface (*init)(minui_backend*);
+ // Initializes the backend and returns a GRSurface* to draw into.
+ GRSurface* (*init)(minui_backend*);
// Causes the current drawing surface (returned by the most recent
// call to flip() or init()) to be displayed, and returns a new
// drawing surface.
- gr_surface (*flip)(minui_backend*);
+ GRSurface* (*flip)(minui_backend*);
// Blank (or unblank) the screen.
void (*blank)(minui_backend*, bool);
diff --git a/minui/graphics_adf.cpp b/minui/graphics_adf.cpp
index ea7c0abe1..5d0867f58 100644
--- a/minui/graphics_adf.cpp
+++ b/minui/graphics_adf.cpp
@@ -47,7 +47,7 @@ struct adf_pdata {
adf_surface_pdata surfaces[2];
};
-static gr_surface adf_flip(minui_backend *backend);
+static GRSurface* adf_flip(minui_backend *backend);
static void adf_blank(minui_backend *backend, bool blank);
static 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)
return err;
}
-static gr_surface adf_init(minui_backend *backend)
+static GRSurface* adf_init(minui_backend *backend)
{
adf_pdata *pdata = (adf_pdata *)backend;
adf_id_t *dev_ids = NULL;
ssize_t n_dev_ids, i;
- gr_surface ret;
+ GRSurface* ret;
#if defined(RECOVERY_ABGR)
pdata->format = DRM_FORMAT_ABGR8888;
@@ -193,7 +193,7 @@ static gr_surface adf_init(minui_backend *backend)
return ret;
}
-static gr_surface adf_flip(minui_backend *backend)
+static GRSurface* adf_flip(minui_backend *backend)
{
adf_pdata *pdata = (adf_pdata *)backend;
adf_surface_pdata *surf = &pdata->surfaces[pdata->current_surface];
diff --git a/minui/graphics_fbdev.cpp b/minui/graphics_fbdev.cpp
index 9dbdde810..997e9cac2 100644
--- a/minui/graphics_fbdev.cpp
+++ b/minui/graphics_fbdev.cpp
@@ -33,8 +33,8 @@
#include "minui.h"
#include "graphics.h"
-static gr_surface fbdev_init(minui_backend*);
-static gr_surface fbdev_flip(minui_backend*);
+static GRSurface* fbdev_init(minui_backend*);
+static GRSurface* fbdev_flip(minui_backend*);
static void fbdev_blank(minui_backend*, bool);
static void fbdev_exit(minui_backend*);
@@ -79,7 +79,7 @@ static void set_displayed_framebuffer(unsigned n)
displayed_buffer = n;
}
-static gr_surface fbdev_init(minui_backend* backend) {
+static GRSurface* fbdev_init(minui_backend* backend) {
int fd = open("/dev/graphics/fb0", O_RDWR);
if (fd == -1) {
perror("cannot open fb0");
@@ -174,7 +174,7 @@ static gr_surface fbdev_init(minui_backend* backend) {
return gr_draw;
}
-static gr_surface fbdev_flip(minui_backend* backend __unused) {
+static GRSurface* fbdev_flip(minui_backend* backend __unused) {
if (double_buffered) {
#if defined(RECOVERY_BGRA)
// In case of BGRA, do some byte swapping
diff --git a/minui/minui.h b/minui/minui.h
index 936f7eec8..bdde083f3 100644
--- a/minui/minui.h
+++ b/minui/minui.h
@@ -33,9 +33,6 @@ struct GRSurface {
unsigned char* data;
};
-// TODO: remove this.
-typedef GRSurface* gr_surface;
-
int gr_init();
void gr_exit();
@@ -49,13 +46,13 @@ void gr_clear(); // clear entire surface to current color
void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
void gr_fill(int x1, int y1, int x2, int y2);
void gr_text(int x, int y, const char *s, bool bold);
-void gr_texticon(int x, int y, gr_surface icon);
+void gr_texticon(int x, int y, GRSurface* icon);
int gr_measure(const char *s);
void gr_font_size(int *x, int *y);
-void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
-unsigned int gr_get_width(gr_surface surface);
-unsigned int gr_get_height(gr_surface surface);
+void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy);
+unsigned int gr_get_width(GRSurface* surface);
+unsigned int gr_get_height(GRSurface* surface);
//
// Input events.
@@ -98,17 +95,17 @@ int ev_get_epollfd();
// All these functions load PNG images from "/res/images/${name}.png".
// Load a single display surface from a PNG image.
-int res_create_display_surface(const char* name, gr_surface* pSurface);
+int res_create_display_surface(const char* name, GRSurface** pSurface);
// Load an array of display surfaces from a single PNG image. The PNG
// should have a 'Frames' text chunk whose value is the number of
// frames this image represents. The pixel data itself is interlaced
// by row.
int res_create_multi_display_surface(const char* name,
- int* frames, gr_surface** pSurface);
+ int* frames, GRSurface*** pSurface);
// Load a single alpha surface from a grayscale PNG image.
-int res_create_alpha_surface(const char* name, gr_surface* pSurface);
+int res_create_alpha_surface(const char* name, GRSurface** pSurface);
// Load part of a grayscale PNG image that is the first match for the
// 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);
// development/tools/recovery_l10n for an app that will generate these
// specialized images from Android resources.
int res_create_localized_alpha_surface(const char* name, const char* locale,
- gr_surface* pSurface);
+ GRSurface** pSurface);
// Free a surface allocated by any of the res_create_*_surface()
// functions.
-void res_free_surface(gr_surface surface);
+void res_free_surface(GRSurface* surface);
#endif
diff --git a/minui/resources.cpp b/minui/resources.cpp
index fa413b608..5e4789277 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -36,11 +36,11 @@ extern char* locale;
#define SURFACE_DATA_ALIGNMENT 8
-static gr_surface malloc_surface(size_t data_size) {
+static GRSurface* malloc_surface(size_t data_size) {
size_t size = sizeof(GRSurface) + data_size + SURFACE_DATA_ALIGNMENT;
unsigned char* temp = reinterpret_cast<unsigned char*>(malloc(size));
if (temp == NULL) return NULL;
- gr_surface surface = (gr_surface) temp;
+ GRSurface* surface = reinterpret_cast<GRSurface*>(temp);
surface->data = temp + sizeof(GRSurface) +
(SURFACE_DATA_ALIGNMENT - (sizeof(GRSurface) % SURFACE_DATA_ALIGNMENT));
return surface;
@@ -138,12 +138,10 @@ static int open_png(const char* name, png_structp* png_ptr, png_infop* info_ptr,
// framebuffer pixel format; they need to be modified if the
// framebuffer format changes (but nothing else should).
-// Allocate and return a gr_surface sufficient for storing an image of
+// Allocate and return a GRSurface* sufficient for storing an image of
// the indicated size in the framebuffer pixel format.
-static gr_surface init_display_surface(png_uint_32 width, png_uint_32 height) {
- gr_surface surface;
-
- surface = malloc_surface(width * height * 4);
+static GRSurface* init_display_surface(png_uint_32 width, png_uint_32 height) {
+ GRSurface* surface = malloc_surface(width * height * 4);
if (surface == NULL) return NULL;
surface->width = width;
@@ -199,8 +197,8 @@ static void transform_rgb_to_draw(unsigned char* input_row,
}
}
-int res_create_display_surface(const char* name, gr_surface* pSurface) {
- gr_surface surface = NULL;
+int res_create_display_surface(const char* name, GRSurface** pSurface) {
+ GRSurface* surface = NULL;
int result = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
@@ -239,8 +237,8 @@ int res_create_display_surface(const char* name, gr_surface* pSurface) {
return result;
}
-int res_create_multi_display_surface(const char* name, int* frames, gr_surface** pSurface) {
- gr_surface* surface = NULL;
+int res_create_multi_display_surface(const char* name, int* frames, GRSurface*** pSurface) {
+ GRSurface** surface = NULL;
int result = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
@@ -275,7 +273,7 @@ int res_create_multi_display_surface(const char* name, int* frames, gr_surface**
goto exit;
}
- surface = reinterpret_cast<gr_surface*>(malloc(*frames * sizeof(gr_surface)));
+ surface = reinterpret_cast<GRSurface**>(malloc(*frames * sizeof(GRSurface*)));
if (surface == NULL) {
result = -8;
goto exit;
@@ -302,7 +300,7 @@ int res_create_multi_display_surface(const char* name, int* frames, gr_surface**
}
free(p_row);
- *pSurface = (gr_surface*) surface;
+ *pSurface = reinterpret_cast<GRSurface**>(surface);
exit:
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -318,8 +316,8 @@ exit:
return result;
}
-int res_create_alpha_surface(const char* name, gr_surface* pSurface) {
- gr_surface surface = NULL;
+int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
+ GRSurface* surface = NULL;
int result = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
@@ -384,8 +382,8 @@ static int matches_locale(const char* loc, const char* locale) {
int res_create_localized_alpha_surface(const char* name,
const char* locale,
- gr_surface* pSurface) {
- gr_surface surface = NULL;
+ GRSurface** pSurface) {
+ GRSurface* surface = NULL;
int result = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
@@ -440,7 +438,7 @@ int res_create_localized_alpha_surface(const char* name,
memcpy(surface->data + i*w, row, w);
}
- *pSurface = (gr_surface) surface;
+ *pSurface = reinterpret_cast<GRSurface*>(surface);
break;
} else {
int i;
@@ -456,6 +454,6 @@ exit:
return result;
}
-void res_free_surface(gr_surface surface) {
+void res_free_surface(GRSurface* surface) {
free(surface);
}