@@ -39,9 +39,8 @@ uint32_t displayio_colorconverter_dither_noise_2(uint32_t x, uint32_t y) {
39
39
return displayio_colorconverter_dither_noise_1 (x + y * 0xFFFF );
40
40
}
41
41
42
- void common_hal_displayio_colorconverter_construct (displayio_colorconverter_t * self , bool dither , uint32_t transparent_color ) {
42
+ void common_hal_displayio_colorconverter_construct (displayio_colorconverter_t * self , bool dither ) {
43
43
self -> dither = dither ;
44
- self -> transparent_color = transparent_color ;
45
44
}
46
45
47
46
uint16_t displayio_colorconverter_compute_rgb565 (uint32_t color_rgb888 ) {
@@ -129,9 +128,26 @@ bool common_hal_displayio_colorconverter_get_dither(displayio_colorconverter_t*
129
128
return self -> dither ;
130
129
}
131
130
131
+ void common_hal_displayio_colorconverter_make_transparent (displayio_colorconverter_t * self , uint32_t transparent_color ) {
132
+ self -> transparent_color = transparent_color ;
133
+ // TODO: Does this require refreshing like the other modules?
134
+ }
135
+
136
+ void common_hal_displayio_colorconverter_make_opaque (displayio_colorconverter_t * self , uint32_t transparent_color ) {
137
+ if (self -> transparent_color == transparent_color ) {
138
+ m_del (uint8_t , self , transparent_color );
139
+ }
140
+ // TODO: Does this require refreshing like the other modules?
141
+ }
142
+
132
143
void displayio_colorconverter_convert (displayio_colorconverter_t * self , const _displayio_colorspace_t * colorspace , const displayio_input_pixel_t * input_pixel , displayio_output_pixel_t * output_color ) {
133
144
uint32_t pixel = input_pixel -> pixel ;
134
145
146
+ if (self -> transparent_color == pixel ) {
147
+ output_color -> opaque = false;
148
+ return ;
149
+ }
150
+
135
151
if (self -> dither ){
136
152
uint8_t randr = (displayio_colorconverter_dither_noise_2 (input_pixel -> tile_x ,input_pixel -> tile_y ));
137
153
uint8_t randg = (displayio_colorconverter_dither_noise_2 (input_pixel -> tile_x + 33 ,input_pixel -> tile_y ));
@@ -162,9 +178,6 @@ void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _d
162
178
}
163
179
output_color -> pixel = packed ;
164
180
output_color -> opaque = true;
165
- if (self -> transparent_color == pixel ) {
166
- output_color -> opaque = false;
167
- }
168
181
return ;
169
182
} else if (colorspace -> tricolor ) {
170
183
uint8_t luma = displayio_colorconverter_compute_luma (pixel );
@@ -174,9 +187,6 @@ void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _d
174
187
output_color -> pixel = 0 ;
175
188
}
176
189
output_color -> opaque = true;
177
- if (self -> transparent_color == pixel ) {
178
- output_color -> opaque = false;
179
- }
180
190
return ;
181
191
}
182
192
uint8_t pixel_hue = displayio_colorconverter_compute_hue (pixel );
@@ -186,9 +196,6 @@ void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _d
186
196
uint8_t luma = displayio_colorconverter_compute_luma (pixel );
187
197
output_color -> pixel = luma >> (8 - colorspace -> depth );
188
198
output_color -> opaque = true;
189
- if (self -> transparent_color == pixel ) {
190
- output_color -> opaque = false;
191
- }
192
199
return ;
193
200
}
194
201
output_color -> opaque = false;
0 commit comments