Merge pull request #1714 from dhalbert/pixel-shader-bug
TileGrid: pixel_shader is not always a Palette
This commit is contained in:
commit
94822ee208
|
@ -39,3 +39,11 @@ bool common_hal_displayio_colorconverter_convert(displayio_colorconverter_t *sel
|
|||
*output_color = __builtin_bswap16(packed);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Currently no refresh logic is needed for a ColorConverter.
|
||||
bool displayio_colorconverter_needs_refresh(displayio_colorconverter_t *self) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void displayio_colorconverter_finish_refresh(displayio_colorconverter_t *self) {
|
||||
}
|
||||
|
|
|
@ -36,4 +36,7 @@ typedef struct {
|
|||
mp_obj_base_t base;
|
||||
} displayio_colorconverter_t;
|
||||
|
||||
bool displayio_colorconverter_needs_refresh(displayio_colorconverter_t *self);
|
||||
void displayio_colorconverter_finish_refresh(displayio_colorconverter_t *self);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_DISPLAYIO_COLORCONVERTER_H
|
||||
|
|
|
@ -170,12 +170,24 @@ bool displayio_tilegrid_get_pixel(displayio_tilegrid_t *self, int16_t x, int16_t
|
|||
}
|
||||
|
||||
bool displayio_tilegrid_needs_refresh(displayio_tilegrid_t *self) {
|
||||
return self->needs_refresh || displayio_palette_needs_refresh(self->pixel_shader);
|
||||
if (self->needs_refresh) {
|
||||
return true;
|
||||
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) {
|
||||
return displayio_palette_needs_refresh(self->pixel_shader);
|
||||
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) {
|
||||
return displayio_colorconverter_needs_refresh(self->pixel_shader);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void displayio_tilegrid_finish_refresh(displayio_tilegrid_t *self) {
|
||||
self->needs_refresh = false;
|
||||
displayio_palette_finish_refresh(self->pixel_shader);
|
||||
if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_palette_type)) {
|
||||
displayio_palette_finish_refresh(self->pixel_shader);
|
||||
} else if (MP_OBJ_IS_TYPE(self->pixel_shader, &displayio_colorconverter_type)) {
|
||||
displayio_colorconverter_finish_refresh(self->pixel_shader);
|
||||
}
|
||||
// TODO(tannewt): We could double buffer changes to position and move them over here.
|
||||
// That way they won't change during a refresh and tear.
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue