14
14
#include "shared-bindings/vectorio/Rectangle.h"
15
15
16
16
// Lifecycle actions.
17
- // #define VECTORIO_SHAPE_DEBUG(...) (void)0
18
- #define VECTORIO_SHAPE_DEBUG (...) mp_printf(&mp_plat_print, __VA_ARGS__)
17
+ #define VECTORIO_SHAPE_DEBUG (...) (void)0
18
+ // #define VECTORIO_SHAPE_DEBUG(...) mp_printf(&mp_plat_print, __VA_ARGS__)
19
19
20
20
21
21
// Used in both logging and ifdefs, for extra variables
22
22
// #define VECTORIO_PERF(...) mp_printf(&mp_plat_print, __VA_ARGS__)
23
23
24
24
25
25
// Really verbose.
26
- // #define VECTORIO_SHAPE_PIXEL_DEBUG(...) (void)0
27
- #define VECTORIO_SHAPE_PIXEL_DEBUG (...) mp_printf(&mp_plat_print, __VA_ARGS__)
26
+ #define VECTORIO_SHAPE_PIXEL_DEBUG (...) (void)0
27
+ // #define VECTORIO_SHAPE_PIXEL_DEBUG(...) mp_printf(&mp_plat_print, __VA_ARGS__)
28
28
29
29
#define U32_TO_BINARY_FMT "%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c"
30
30
#define U32_TO_BINARY (u32 ) \
@@ -96,8 +96,19 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
96
96
if (self -> absolute_transform -> transpose_xy ) {
97
97
x = self -> absolute_transform -> x + self -> absolute_transform -> dx * self -> y ;
98
98
y = self -> absolute_transform -> y + self -> absolute_transform -> dy * self -> x ;
99
+ if (self -> absolute_transform -> dx < 1 ) {
100
+ out_area -> y1 = out_area -> y1 * -1 + 1 ;
101
+ out_area -> y2 = out_area -> y2 * -1 + 1 ;
102
+ }
103
+ if (self -> absolute_transform -> dy < 1 ) {
104
+ out_area -> x1 = out_area -> x1 * -1 + 1 ;
105
+ out_area -> x2 = out_area -> x2 * -1 + 1 ;
106
+ }
99
107
area_transpose (out_area );
100
108
} else {
109
+ x = self -> absolute_transform -> x + self -> absolute_transform -> dx * self -> x ;
110
+ y = self -> absolute_transform -> y + self -> absolute_transform -> dy * self -> y ;
111
+
101
112
if (self -> absolute_transform -> dx < 1 ) {
102
113
out_area -> x1 = out_area -> x1 * -1 + 1 ;
103
114
out_area -> x2 = out_area -> x2 * -1 + 1 ;
@@ -106,8 +117,6 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
106
117
out_area -> y1 = out_area -> y1 * -1 + 1 ;
107
118
out_area -> y2 = out_area -> y2 * -1 + 1 ;
108
119
}
109
- x = self -> absolute_transform -> x + self -> absolute_transform -> dx * self -> x ;
110
- y = self -> absolute_transform -> y + self -> absolute_transform -> dy * self -> y ;
111
120
}
112
121
displayio_area_canon (out_area );
113
122
displayio_area_shift (out_area , x , y );
@@ -307,25 +316,35 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ
307
316
if (self -> absolute_transform -> transpose_xy ) {
308
317
pixel_to_get_x = input_pixel .y - self -> absolute_transform -> y - self -> absolute_transform -> dy * self -> x ;
309
318
pixel_to_get_y = input_pixel .x - self -> absolute_transform -> x - self -> absolute_transform -> dx * self -> y ;
310
- VECTORIO_SHAPE_PIXEL_DEBUG (" a(%3d, %3d)" , pixel_to_get_x , pixel_to_get_y );
311
319
312
- if (self -> absolute_transform -> mirror_x ) {
313
- pixel_to_get_y = shape_area .y2 - 1 - pixel_to_get_y ;
320
+ VECTORIO_SHAPE_PIXEL_DEBUG (" a(%3d, %3d)" , pixel_to_get_x , pixel_to_get_y );
321
+ if (self -> absolute_transform -> dx < 1 ) {
322
+ pixel_to_get_y *= -1 ;
314
323
}
315
- if (self -> absolute_transform -> mirror_y ) {
316
- pixel_to_get_x = shape_area . x2 - 1 - pixel_to_get_x ;
324
+ if (self -> absolute_transform -> dy < 1 ) {
325
+ pixel_to_get_x *= -1 ;
317
326
}
327
+ VECTORIO_SHAPE_PIXEL_DEBUG (" b(%3d, %3d)" , pixel_to_get_x , pixel_to_get_y );
318
328
} else {
319
329
pixel_to_get_x = input_pixel .x - self -> absolute_transform -> x - self -> absolute_transform -> dx * self -> x ;
320
330
pixel_to_get_y = input_pixel .y - self -> absolute_transform -> y - self -> absolute_transform -> dy * self -> y ;
321
- VECTORIO_SHAPE_PIXEL_DEBUG (" a(%3d, %3d)" , pixel_to_get_x , pixel_to_get_y );
322
331
323
- if (self -> absolute_transform -> mirror_x ) {
324
- pixel_to_get_x = (shape_area .x2 - shape_area .x1 ) - (pixel_to_get_x + shape_area .x1 ) + shape_area .x1 - 1 ;
332
+ VECTORIO_SHAPE_PIXEL_DEBUG (" a(%3d, %3d)" , pixel_to_get_x , pixel_to_get_y );
333
+ if (self -> absolute_transform -> dx < 1 ) {
334
+ pixel_to_get_x *= -1 ;
325
335
}
326
- if (self -> absolute_transform -> mirror_y ) {
327
- pixel_to_get_y = ( shape_area . y2 - shape_area . y1 ) - ( pixel_to_get_y + shape_area . y1 ) + + shape_area . y1 - 1 ;
336
+ if (self -> absolute_transform -> dy < 1 ) {
337
+ pixel_to_get_y *= - 1 ;
328
338
}
339
+ VECTORIO_SHAPE_PIXEL_DEBUG (" b(%3d, %3d)" , pixel_to_get_x , pixel_to_get_y );
340
+
341
+ // It's mirrored via dx. Maybe we need to add support for also separately mirroring?
342
+ // if (self->absolute_transform->mirror_x) {
343
+ // pixel_to_get_x = (shape_area.x2 - shape_area.x1) - (pixel_to_get_x - shape_area.x1) + shape_area.x1 - 1;
344
+ // }
345
+ // if (self->absolute_transform->mirror_y) {
346
+ // pixel_to_get_y = (shape_area.y2 - shape_area.y1) - (pixel_to_get_y - shape_area.y1) + +shape_area.y1 - 1;
347
+ // }
329
348
}
330
349
331
350
VECTORIO_SHAPE_PIXEL_DEBUG (" get_pixel %p (%3d, %3d) -> ( %3d, %3d )" , self -> ishape .shape , input_pixel .x , input_pixel .y , pixel_to_get_x , pixel_to_get_y );
@@ -407,7 +426,7 @@ bool vectorio_vector_shape_fill_area(vectorio_vector_shape_t *self, const _displ
407
426
408
427
409
428
void vectorio_vector_shape_finish_refresh (vectorio_vector_shape_t * self ) {
410
- if (displayio_area_empty (& self -> ephemeral_dirty_area )) {
429
+ if (displayio_area_empty (& self -> ephemeral_dirty_area ) && ! self -> current_area_dirty ) {
411
430
return ;
412
431
}
413
432
VECTORIO_SHAPE_DEBUG ("%p finish_refresh was:{(%3d,%3d), (%3d,%3d)}\n" , self , self -> ephemeral_dirty_area .x1 , self -> ephemeral_dirty_area .y1 , self -> ephemeral_dirty_area .x2 , self -> ephemeral_dirty_area .y2 );
@@ -484,6 +503,6 @@ displayio_area_t *vectorio_vector_shape_get_refresh_areas(vectorio_vector_shape_
484
503
}
485
504
486
505
void vectorio_vector_shape_update_transform (vectorio_vector_shape_t * self , displayio_buffer_transform_t * group_transform ) {
487
- common_hal_vectorio_vector_shape_set_dirty (self );
488
506
self -> absolute_transform = group_transform == NULL ? & null_transform : group_transform ;
507
+ common_hal_vectorio_vector_shape_set_dirty (self );
489
508
}
0 commit comments