Merge pull request #1714 from dhalbert/pixel-shader-bug

TileGrid: pixel_shader is not always a Palette
This commit is contained in:
Scott Shawcroft 2019-03-27 10:58:07 -07:00 committed by GitHub
commit 94822ee208
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View File

@ -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) {
}

View File

@ -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

View File

@ -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.
}