File tree Expand file tree Collapse file tree 1 file changed +8
-24
lines changed Expand file tree Collapse file tree 1 file changed +8
-24
lines changed Original file line number Diff line number Diff line change @@ -173,29 +173,13 @@ void common_hal_displayio_bitmap_fill(displayio_bitmap_t *self, uint32_t value)
173
173
self -> dirty_area .y1 = 0 ;
174
174
self -> dirty_area .y2 = self -> height ;
175
175
176
- // Update our data
177
- int32_t row_start ;
178
- uint32_t bytes_per_value = self -> bits_per_value / 8 ;
179
- for (uint32_t x = 0 ; x < self -> width ; x ++ ) {
180
- for (uint32_t y = 0 ; y < self -> height ; y ++ ) {
181
- row_start = y * self -> stride ;
182
- if (bytes_per_value < 1 ) {
183
- uint32_t bit_position = (sizeof (size_t ) * 8 - ((x & self -> x_mask ) + 1 ) * self -> bits_per_value );
184
- uint32_t index = row_start + (x >> self -> x_shift );
185
- uint32_t word = self -> data [index ];
186
- word &= ~(self -> bitmask << bit_position );
187
- word |= (value & self -> bitmask ) << bit_position ;
188
- self -> data [index ] = word ;
189
- } else {
190
- size_t * row = self -> data + row_start ;
191
- if (bytes_per_value == 1 ) {
192
- ((uint8_t * ) row )[x ] = value ;
193
- } else if (bytes_per_value == 2 ) {
194
- ((uint16_t * ) row )[x ] = value ;
195
- } else if (bytes_per_value == 4 ) {
196
- ((uint32_t * ) row )[x ] = value ;
197
- }
198
- }
199
- }
176
+ // build the packed word
177
+ uint32_t word = 0 ;
178
+ for (uint8_t i = 0 ; i < 32 / self -> bits_per_value ; i ++ ) {
179
+ word |= (value & self -> bitmask ) << (32 - ((i + 1 )* self -> bits_per_value ));
180
+ }
181
+ // copy it in
182
+ for (uint32_t i = 0 ; i < self -> stride * self -> height ; i ++ ) {
183
+ self -> data [i ] = word ;
200
184
}
201
185
}
You can’t perform that action at this time.
0 commit comments