Skip to content

Commit 0f478d5

Browse files
committed
remove string import. use minimum sized dirty area
1 parent aeeba39 commit 0f478d5

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

shared-module/bitmaptools/__init__.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#include <string.h>
28-
2927
#include "shared-bindings/bitmaptools/__init__.h"
3028
#include "shared-bindings/displayio/Bitmap.h"
3129
#include "shared-module/displayio/Bitmap.h"
@@ -262,6 +260,9 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
262260
return;
263261
}
264262

263+
264+
265+
265266
uint32_t current_point_color_value;
266267

267268
// the list of points that we'll check
@@ -274,6 +275,11 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
274275
mp_obj_new_tuple(2, point)
275276
);
276277

278+
int16_t minx = x;
279+
int16_t miny = x;
280+
int16_t maxx = y;
281+
int16_t maxy = y;
282+
277283
if (replaced_color_value == INT_MAX) {
278284
current_point_color_value = common_hal_displayio_bitmap_get_pixel(
279285
destination,
@@ -288,10 +294,11 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
288294

289295
mp_obj_t current_point;
290296

291-
292297
size_t tuple_len = 0;
293298
mp_obj_t *tuple_items;
294299

300+
int cur_x, cur_y;
301+
295302
// while there are still points to check
296303
while (list_length > 0) {
297304
mp_obj_list_get(fill_area, &list_length, &fill_points);
@@ -308,6 +315,22 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
308315
continue;
309316
}
310317

318+
cur_x = mp_obj_int_get_checked(tuple_items[0]);
319+
cur_y = mp_obj_int_get_checked(tuple_items[1]);
320+
321+
if (cur_x < minx) {
322+
minx = (int16_t)cur_x;
323+
}
324+
if (cur_x > maxx) {
325+
maxx = (int16_t)cur_x;
326+
}
327+
if (cur_y < miny) {
328+
miny = (int16_t)cur_y;
329+
}
330+
if (cur_y > maxy) {
331+
maxy = (int16_t)cur_y;
332+
}
333+
311334
// fill the current point with fill color
312335
displayio_bitmap_write_pixel(
313336
destination,
@@ -365,7 +388,7 @@ void common_hal_bitmaptools_boundary_fill(displayio_bitmap_t *destination,
365388
}
366389

367390
// set dirty the area so displayio will draw
368-
displayio_area_t area = { 0, 0, destination->width, destination->height };
391+
displayio_area_t area = { minx, miny, maxx + 1, maxy + 1};
369392
displayio_bitmap_set_dirty_area(destination, &area);
370393

371394
}

0 commit comments

Comments
 (0)