Skip to content

Commit 5b37315

Browse files
committed
Use a bitmap about pony, it's much faster.
Signed-off-by: Katharine Berry <ktbry@google.com>
1 parent 7612c3d commit 5b37315

File tree

5 files changed

+29
-9
lines changed

5 files changed

+29
-9
lines changed

app/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,24 @@
468468
"file": "images/fence_pony.pdc",
469469
"name": "FENCE_PONY",
470470
"type": "raw"
471+
},
472+
{
473+
"file": "images/fence_pony_color.png",
474+
"name": "FENCE_PONY_BITMAP",
475+
"type": "bitmap",
476+
"memoryFormat": "2BitPalette",
477+
"targetPlatforms": [
478+
"basalt"
479+
]
480+
},
481+
{
482+
"file": "images/fence_pony_bw.png",
483+
"name": "FENCE_PONY_BITMAP",
484+
"type": "bitmap",
485+
"memoryFormat": "1BitPalette",
486+
"targetPlatforms": [
487+
"diorite"
488+
]
471489
}
472490
]
473491
}
-390 Bytes
Binary file not shown.
2.53 KB
Loading
2.59 KB
Loading

app/src/c/menus/about_window.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ typedef struct {
2828
FormattedTextLayer *text_layer;
2929
ScrollLayer *scroll_layer;
3030
StatusBarLayer *status_bar;
31-
VectorLayer *vector_layer;
32-
GDrawCommandImage *bobby_image;
31+
BitmapLayer *bitmap_layer;
32+
GBitmap *bobby_image;
3333
} AboutWindowData;
3434

3535
static void prv_window_load(Window* window);
@@ -78,14 +78,16 @@ static void prv_window_load(Window* window) {
7878
formatted_text_layer_set_text(data->text_layer, data->about_text);
7979
GSize text_size = formatted_text_layer_get_content_size(data->text_layer);
8080

81-
data->bobby_image = gdraw_command_image_create_with_resource(RESOURCE_ID_FENCE_PONY);
82-
GSize image_size = gdraw_command_image_get_bounds_size(data->bobby_image);
83-
data->vector_layer = vector_layer_create(GRect((window_bounds.size.w - image_size.w) / 2, text_size.h, image_size.w, image_size.h));
84-
vector_layer_set_vector(data->vector_layer, data->bobby_image);
81+
data->bobby_image = gbitmap_create_with_resource(RESOURCE_ID_FENCE_PONY_BITMAP);
82+
GSize image_size = gbitmap_get_bounds(data->bobby_image).size;
83+
image_size.h += 40; // add back the space at the top
84+
data->bitmap_layer = bitmap_layer_create(GRect((window_bounds.size.w - image_size.w) / 2, text_size.h, image_size.w, image_size.h));
85+
bitmap_layer_set_bitmap(data->bitmap_layer, data->bobby_image);
86+
bitmap_layer_set_alignment(data->bitmap_layer, GAlignBottom);
8587

8688
scroll_layer_set_content_size(data->scroll_layer, GSize(window_bounds.size.w, text_size.h + image_size.h));
8789
scroll_layer_add_child(data->scroll_layer, formatted_text_layer_get_layer(data->text_layer));
88-
scroll_layer_add_child(data->scroll_layer, vector_layer_get_layer(data->vector_layer));
90+
scroll_layer_add_child(data->scroll_layer, bitmap_layer_get_layer(data->bitmap_layer));
8991
}
9092

9193
static void prv_window_unload(Window* window) {
@@ -94,8 +96,8 @@ static void prv_window_unload(Window* window) {
9496
formatted_text_layer_destroy(data->text_layer);
9597
scroll_layer_destroy(data->scroll_layer);
9698
status_bar_layer_destroy(data->status_bar);
97-
vector_layer_destroy(data->vector_layer);
98-
gdraw_command_image_destroy(data->bobby_image);
99+
bitmap_layer_destroy(data->bitmap_layer);
100+
gbitmap_destroy(data->bobby_image);
99101
free(data);
100102
window_destroy(window);
101103
}

0 commit comments

Comments
 (0)