From b723f4f38f53a38502abb1a63165ac0749bc9cd9 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 11 Dec 2015 15:18:51 -0800 Subject: res: Embed FPS into icon_installing.png. We allow vendor-specific icon installing image but have defined private animation_fps that can't be overridden. This CL changes the image generator to optionally embed FPS (otherwise use the default value of 20) into the generated image. For wear devices, they are using individual images instead of the interlaced one. Change the animation_fps from private to protected so that it can be customized. Bug: 26009230 Change-Id: I9fbf64ec717029d4c54f72316f6cb079e8dbfb5e --- minui/resources.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'minui/resources.cpp') 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); -- cgit v1.2.3 From 498cda6ef6c610efb055221d6c689185d49447bb Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 14 Apr 2016 16:49:04 -0700 Subject: Update the system update animation. Switch to a Wear-like intro/loop system. We don't have an intro yet, but hopefully this will let Wear delete more code when they move to N. Unlike them, we don't hard-code the number of frames: we just look to see what we have available. We do hard-code the fps though. Also add a graphics test mode so you can see a demo of the UI components without having to actually apply an OTA. Also fix a bug where default locale is null rather than en-US: it's more useful to show _some_ text if we don't have a locale (which should only be during development anyway). Bug: http://b/26548285 Change-Id: I63422e3fef3c41109f924d96fb5ded0b3ae7815d --- minui/resources.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'minui/resources.cpp') diff --git a/minui/resources.cpp b/minui/resources.cpp index 63a0dff28..5d69ea2d0 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) { -- cgit v1.2.3 From 2430e2978b95ff364c304e0aeeeaeec6df929146 Mon Sep 17 00:00:00 2001 From: Tianjie Xu Date: Tue, 19 Apr 2016 15:02:41 -0700 Subject: Fix matches_locale function matches_locale was expecting input locale string to have at most one underscore; as a result "zh_CN_#Hans" ignores "zh_CN" and matches into "zh". Fix the match function and add unit tests. Bug: 27837319 Change-Id: I4e8a66f91cae6ac2a46b6bf21f670d5ea564c7c8 --- minui/resources.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'minui/resources.cpp') diff --git a/minui/resources.cpp b/minui/resources.cpp index 5d69ea2d0..40d3c2c88 100644 --- a/minui/resources.cpp +++ b/minui/resources.cpp @@ -370,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; +// 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; - if (strcmp(loc, locale) == 0) return 1; + // 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". - // 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". - - int i; - for (i = 0; loc[i] != 0 && loc[i] != '_'; ++i); - if (loc[i] == '_') return 0; - - return (strncmp(locale, loc, i) == 0 && locale[i] == '_'); + return (strncmp(prefix, locale, strlen(prefix)) == 0); } int res_create_localized_alpha_surface(const char* name, -- cgit v1.2.3