summaryrefslogtreecommitdiffstats
path: root/minui
diff options
context:
space:
mode:
Diffstat (limited to 'minui')
-rw-r--r--minui/Android.mk1
-rw-r--r--minui/graphics_fbdev.cpp12
-rw-r--r--minui/minui.h6
-rw-r--r--minui/resources.cpp44
4 files changed, 28 insertions, 35 deletions
diff --git a/minui/Android.mk b/minui/Android.mk
index afe38ede2..1faaf6dcc 100644
--- a/minui/Android.mk
+++ b/minui/Android.mk
@@ -83,6 +83,7 @@ include $(BUILD_STATIC_LIBRARY)
# Used by OEMs for factory test images.
include $(CLEAR_VARS)
+LOCAL_CLANG := true
LOCAL_MODULE := libminui
LOCAL_WHOLE_STATIC_LIBRARIES += libminui
LOCAL_SHARED_LIBRARIES := libpng
diff --git a/minui/graphics_fbdev.cpp b/minui/graphics_fbdev.cpp
index 512a7d0e7..5f64e1e22 100644
--- a/minui/graphics_fbdev.cpp
+++ b/minui/graphics_fbdev.cpp
@@ -190,18 +190,6 @@ static GRSurface* fbdev_init(minui_backend* backend) {
static GRSurface* fbdev_flip(minui_backend* backend __unused) {
if (double_buffered) {
-#if defined(RECOVERY_BGRA)
- // In case of BGRA, do some byte swapping
- unsigned int idx;
- unsigned char tmp;
- unsigned char* ucfb_vaddr = (unsigned char*)gr_draw->data;
- for (idx = 0 ; idx < (gr_draw->height * gr_draw->row_bytes);
- idx += 4) {
- tmp = ucfb_vaddr[idx];
- ucfb_vaddr[idx ] = ucfb_vaddr[idx + 2];
- ucfb_vaddr[idx + 2] = tmp;
- }
-#endif
// Change gr_draw to point to the buffer currently displayed,
// then flip the driver so we're displaying the other buffer
// instead.
diff --git a/minui/minui.h b/minui/minui.h
index 098a041ef..5e49100cd 100644
--- a/minui/minui.h
+++ b/minui/minui.h
@@ -87,6 +87,8 @@ int ev_get_epollfd();
// Resources
//
+bool matches_locale(const char* prefix, const char* locale);
+
// res_create_*_surface() functions return 0 if no error, else
// negative.
//
@@ -104,8 +106,8 @@ int res_create_display_surface(const char* name, GRSurface** pSurface);
// 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, GRSurface*** pSurface);
+int res_create_multi_display_surface(const char* name, int* frames,
+ int* fps, GRSurface*** pSurface);
// Load a single alpha surface from a grayscale PNG image.
int res_create_alpha_surface(const char* name, GRSurface** pSurface);
diff --git a/minui/resources.cpp b/minui/resources.cpp
index 5e4789277..40d3c2c88 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -32,8 +32,6 @@
#include "minui.h"
-extern char* locale;
-
#define SURFACE_DATA_ALIGNMENT 8
static GRSurface* malloc_surface(size_t data_size) {
@@ -237,14 +235,14 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) {
return result;
}
-int res_create_multi_display_surface(const char* name, int* frames, GRSurface*** pSurface) {
+int res_create_multi_display_surface(const char* name, int* frames, int* fps,
+ GRSurface*** pSurface) {
GRSurface** surface = NULL;
int result = 0;
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
png_uint_32 width, height;
png_byte channels;
- int i;
png_textp text;
int num_text;
unsigned char* p_row;
@@ -257,14 +255,23 @@ int res_create_multi_display_surface(const char* name, int* frames, GRSurface***
if (result < 0) return result;
*frames = 1;
+ *fps = 20;
if (png_get_text(png_ptr, info_ptr, &text, &num_text)) {
- for (i = 0; i < num_text; ++i) {
+ for (int i = 0; i < num_text; ++i) {
if (text[i].key && strcmp(text[i].key, "Frames") == 0 && text[i].text) {
*frames = atoi(text[i].text);
- break;
+ } else if (text[i].key && strcmp(text[i].key, "FPS") == 0 && text[i].text) {
+ *fps = atoi(text[i].text);
}
}
printf(" found frames = %d\n", *frames);
+ printf(" found fps = %d\n", *fps);
+ }
+
+ if (frames <= 0 || fps <= 0) {
+ printf("bad number of frames (%d) and/or FPS (%d)\n", *frames, *fps);
+ result = -10;
+ goto exit;
}
if (height % *frames != 0) {
@@ -278,7 +285,7 @@ int res_create_multi_display_surface(const char* name, int* frames, GRSurface***
result = -8;
goto exit;
}
- for (i = 0; i < *frames; ++i) {
+ for (int i = 0; i < *frames; ++i) {
surface[i] = init_display_surface(width, height / *frames);
if (surface[i] == NULL) {
result = -8;
@@ -307,7 +314,7 @@ exit:
if (result < 0) {
if (surface) {
- for (i = 0; i < *frames; ++i) {
+ for (int i = 0; i < *frames; ++i) {
if (surface[i]) free(surface[i]);
}
free(surface);
@@ -363,21 +370,16 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
return result;
}
-static int matches_locale(const char* loc, const char* locale) {
- if (locale == NULL) return 0;
-
- if (strcmp(loc, locale) == 0) return 1;
-
- // if loc does *not* have an underscore, and it matches the start
- // of locale, and the next character in locale *is* an underscore,
- // that's a match. For instance, loc == "en" matches locale ==
- // "en_US".
+// This function tests if a locale string stored in PNG (prefix) matches
+// the locale string provided by the system (locale).
+bool matches_locale(const char* prefix, const char* locale) {
+ if (locale == NULL) return false;
- int i;
- for (i = 0; loc[i] != 0 && loc[i] != '_'; ++i);
- if (loc[i] == '_') return 0;
+ // Return true if the whole string of prefix matches the top part of
+ // locale. For instance, prefix == "en" matches locale == "en_US";
+ // and prefix == "zh_CN" matches locale == "zh_CN_#Hans".
- return (strncmp(locale, loc, i) == 0 && locale[i] == '_');
+ return (strncmp(prefix, locale, strlen(prefix)) == 0);
}
int res_create_localized_alpha_surface(const char* name,