Skip to content

Commit 16c8dad

Browse files
committed
Fix Pallete cache for grayscale and tricolor epd
1 parent a280c01 commit 16c8dad

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

shared-module/displayio/Palette.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ void displayio_palette_get_color(displayio_palette_t *self, const _displayio_col
8181
}
8282

8383
// Cache results when not dithering.
84-
if (!self->dither && self->colors[palette_index].cached_colorspace == colorspace) {
84+
_displayio_color_t *color = &self->colors[palette_index];
85+
// Check the grayscale settings because EPaperDisplay will change them on
86+
// the same object.
87+
if (!self->dither &&
88+
color->cached_colorspace == colorspace &&
89+
color->cached_colorspace_grayscale_bit == colorspace->grayscale_bit &&
90+
color->cached_colorspace_grayscale == colorspace->grayscale) {
8591
output_color->pixel = self->colors[palette_index].cached_color;
8692
return;
8793
}
@@ -90,8 +96,10 @@ void displayio_palette_get_color(displayio_palette_t *self, const _displayio_col
9096
rgb888_pixel.pixel = self->colors[palette_index].rgb888;
9197
displayio_convert_color(colorspace, self->dither, &rgb888_pixel, output_color);
9298
if (!self->dither) {
93-
self->colors[palette_index].cached_colorspace = colorspace;
94-
self->colors[palette_index].cached_color = output_color->pixel;
99+
color->cached_colorspace = colorspace;
100+
color->cached_color = output_color->pixel;
101+
color->cached_colorspace_grayscale = colorspace->grayscale;
102+
color->cached_colorspace_grayscale_bit = colorspace->grayscale_bit;
95103
}
96104
}
97105

shared-module/displayio/Palette.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ typedef struct {
5151
uint32_t rgb888;
5252
const _displayio_colorspace_t *cached_colorspace;
5353
uint32_t cached_color;
54+
uint8_t cached_colorspace_grayscale_bit;
55+
bool cached_colorspace_grayscale;
5456
bool transparent; // This may have additional bits added later for blending.
5557
} _displayio_color_t;
5658

0 commit comments

Comments
 (0)