summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker2014-03-11 10:42:09 -0500
committerDoug Zongker2014-03-11 14:25:41 -0500
commitee6ef15e677fd3168b4a0d221175fbf0ecd96ff5 (patch)
tree93a89a6d6156fde4aced59f0f1bcf6f094c12b78 /healthd/healthd_mode_charger.cpp
parent0631bf3ddbc850d8a21795ac9b35b6cc21ec2c66 (diff)
downloadplatform-system-core-ee6ef15e677fd3168b4a0d221175fbf0ecd96ff5.tar.gz
platform-system-core-ee6ef15e677fd3168b4a0d221175fbf0ecd96ff5.tar.xz
platform-system-core-ee6ef15e677fd3168b4a0d221175fbf0ecd96ff5.zip
remove pixelflinger from healthd
The minui library has changed to no longer use libpixelflinger. It also offers a more efficient way of storing and loading frames of animation; use it to represent the battery-full state images. Also removes the unused battery_charge.png image. Bug: 12131110 Change-Id: I6cc8b19f36a806c99cda30cc47b5968daf6b333b
Diffstat (limited to 'healthd/healthd_mode_charger.cpp')
-rw-r--r--healthd/healthd_mode_charger.cpp42
1 files changed, 20 insertions, 22 deletions
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index 33a179bf8..fc3ac67c4 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -81,7 +81,6 @@ struct key_state {
81}; 81};
82 82
83struct frame { 83struct frame {
84 const char *name;
85 int disp_time; 84 int disp_time;
86 int min_capacity; 85 int min_capacity;
87 bool level_only; 86 bool level_only;
@@ -119,42 +118,36 @@ struct charger {
119 118
120static struct frame batt_anim_frames[] = { 119static struct frame batt_anim_frames[] = {
121 { 120 {
122 .name = "charger/battery_0",
123 .disp_time = 750, 121 .disp_time = 750,
124 .min_capacity = 0, 122 .min_capacity = 0,
125 .level_only = false, 123 .level_only = false,
126 .surface = NULL, 124 .surface = NULL,
127 }, 125 },
128 { 126 {
129 .name = "charger/battery_1",
130 .disp_time = 750, 127 .disp_time = 750,
131 .min_capacity = 20, 128 .min_capacity = 20,
132 .level_only = false, 129 .level_only = false,
133 .surface = NULL, 130 .surface = NULL,
134 }, 131 },
135 { 132 {
136 .name = "charger/battery_2",
137 .disp_time = 750, 133 .disp_time = 750,
138 .min_capacity = 40, 134 .min_capacity = 40,
139 .level_only = false, 135 .level_only = false,
140 .surface = NULL, 136 .surface = NULL,
141 }, 137 },
142 { 138 {
143 .name = "charger/battery_3",
144 .disp_time = 750, 139 .disp_time = 750,
145 .min_capacity = 60, 140 .min_capacity = 60,
146 .level_only = false, 141 .level_only = false,
147 .surface = NULL, 142 .surface = NULL,
148 }, 143 },
149 { 144 {
150 .name = "charger/battery_4",
151 .disp_time = 750, 145 .disp_time = 750,
152 .min_capacity = 80, 146 .min_capacity = 80,
153 .level_only = true, 147 .level_only = true,
154 .surface = NULL, 148 .surface = NULL,
155 }, 149 },
156 { 150 {
157 .name = "charger/battery_5",
158 .disp_time = 750, 151 .disp_time = 750,
159 .min_capacity = BATTERY_FULL_THRESH, 152 .min_capacity = BATTERY_FULL_THRESH,
160 .level_only = false, 153 .level_only = false,
@@ -188,8 +181,8 @@ static int64_t curr_time_ms(void)
188static void clear_screen(void) 181static void clear_screen(void)
189{ 182{
190 gr_color(0, 0, 0, 255); 183 gr_color(0, 0, 0, 255);
191 gr_fill(0, 0, gr_fb_width(), gr_fb_height()); 184 gr_clear();
192}; 185}
193 186
194#define MAX_KLOG_WRITE_BUF_SZ 256 187#define MAX_KLOG_WRITE_BUF_SZ 256
195 188
@@ -317,8 +310,8 @@ static void draw_battery(struct charger *charger)
317 310
318 if (batt_anim->num_frames != 0) { 311 if (batt_anim->num_frames != 0) {
319 draw_surface_centered(charger, frame->surface); 312 draw_surface_centered(charger, frame->surface);
320 LOGV("drawing frame #%d name=%s min_cap=%d time=%d\n", 313 LOGV("drawing frame #%d min_cap=%d time=%d\n",
321 batt_anim->cur_frame, frame->name, frame->min_capacity, 314 batt_anim->cur_frame, frame->min_capacity,
322 frame->disp_time); 315 frame->disp_time);
323 } 316 }
324} 317}
@@ -655,22 +648,27 @@ void healthd_mode_charger_init(struct healthd_config *config)
655 648
656 ret = res_create_surface("charger/battery_fail", &charger->surf_unknown); 649 ret = res_create_surface("charger/battery_fail", &charger->surf_unknown);
657 if (ret < 0) { 650 if (ret < 0) {
658 LOGE("Cannot load image\n"); 651 LOGE("Cannot load battery_fail image\n");
659 charger->surf_unknown = NULL; 652 charger->surf_unknown = NULL;
660 } 653 }
661 654
662 charger->batt_anim = &battery_animation; 655 charger->batt_anim = &battery_animation;
663 656
664 for (i = 0; i < charger->batt_anim->num_frames; i++) { 657 gr_surface* scale_frames;
665 struct frame *frame = &charger->batt_anim->frames[i]; 658 int scale_count;
666 659 ret = res_create_multi_surface("charger/battery_scale", &scale_count, &scale_frames);
667 ret = res_create_surface(frame->name, &frame->surface); 660 if (ret < 0) {
668 if (ret < 0) { 661 LOGE("Cannot load battery_scale image\n");
669 LOGE("Cannot load image %s\n", frame->name); 662 charger->batt_anim->num_frames = 0;
670 /* TODO: free the already allocated surfaces... */ 663 charger->batt_anim->num_cycles = 1;
671 charger->batt_anim->num_frames = 0; 664 } else if (scale_count != charger->batt_anim->num_frames) {
672 charger->batt_anim->num_cycles = 1; 665 LOGE("battery_scale image has unexpected frame count (%d, expected %d)\n",
673 break; 666 scale_count, charger->batt_anim->num_frames);
667 charger->batt_anim->num_frames = 0;
668 charger->batt_anim->num_cycles = 1;
669 } else {
670 for (i = 0; i < charger->batt_anim->num_frames; i++) {
671 charger->batt_anim->frames[i].surface = scale_frames[i];
674 } 672 }
675 } 673 }
676 674