summaryrefslogtreecommitdiffstats
path: root/minui
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-12-18 23:20:20 +0100
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-12-18 23:20:20 +0100
commit29b0fbe160f815a142fa0d056c1ce10186cea516 (patch)
treec311d658de7ac03080583b24e9157cc6f502f1b4 /minui
parentMerge "updater: Use O_SYNC and fsync() for package_extract_file()." (diff)
parentres: Embed FPS into icon_installing.png. (diff)
downloadandroid_bootable_recovery-29b0fbe160f815a142fa0d056c1ce10186cea516.tar
android_bootable_recovery-29b0fbe160f815a142fa0d056c1ce10186cea516.tar.gz
android_bootable_recovery-29b0fbe160f815a142fa0d056c1ce10186cea516.tar.bz2
android_bootable_recovery-29b0fbe160f815a142fa0d056c1ce10186cea516.tar.lz
android_bootable_recovery-29b0fbe160f815a142fa0d056c1ce10186cea516.tar.xz
android_bootable_recovery-29b0fbe160f815a142fa0d056c1ce10186cea516.tar.zst
android_bootable_recovery-29b0fbe160f815a142fa0d056c1ce10186cea516.zip
Diffstat (limited to 'minui')
-rw-r--r--minui/minui.h4
-rw-r--r--minui/resources.cpp21
2 files changed, 17 insertions, 8 deletions
diff --git a/minui/minui.h b/minui/minui.h
index bdde083f3..e3bc00548 100644
--- a/minui/minui.h
+++ b/minui/minui.h
@@ -101,8 +101,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..63a0dff28 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -237,14 +237,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 +257,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 +287,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 +316,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);