
From: Simon Glass <sjg@chromium.org> Create a variant of fill_pixel_and_goto_next() function which returns the old pixel value. This will make it easy to save the framebuffer pixels as they are overwritten by drawing the cursor. Leave the current function alone, since it increases code size about 16 bytes and may slow down blitting. Signed-off-by: Simon Glass <sjg@chromium.org> --- drivers/video/console_core.c | 25 +++++++++++++++++++++++++ drivers/video/vidconsole_internal.h | 12 ++++++++++++ 2 files changed, 37 insertions(+) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index b1688e717c9..4fab5a2605e 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -61,6 +61,31 @@ inline void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int ste *dstp = dst_byte + step; } +inline u32 swap_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step) +{ + u8 *dst_byte = *dstp; + u32 old_value = 0; + + if (pbytes == 4) { + u32 *dst = *dstp; + old_value = *dst; + *dst = value; + } + if (pbytes == 2) { + u16 *dst = *dstp; + old_value = *dst; + *dst = value; + } + if (pbytes == 1) { + u8 *dst = *dstp; + old_value = *dst; + *dst = value; + } + *dstp = dst_byte + step; + + return old_value; +} + int fill_char_vertically(uchar *pfont, void **line, struct video_priv *vid_priv, struct video_fontdata *fontdata, bool direction) { diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 4cb6ba4e15f..93f9c7b4e56 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -45,6 +45,18 @@ int check_bpix_support(int bpix); */ void fill_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step); +/** + * swap_pixel_and_goto_next() - Swap 1 pixel in framebuffer, and go to next one + * + * @param dstp a pointer to pointer to framebuffer. + * @param value value to write to framebuffer. + * @param pbytes framebuffer bytes per pixel. + * @param step framebuffer pointer increment. Usually is equal to pbytes, + * and may be negative to control filling direction. + * Return: old value of the pixel + */ +u32 swap_pixel_and_goto_next(void **dstp, u32 value, int pbytes, int step); + /** * Fills 1 character in framebuffer vertically. Vertically means we're filling char font data rows * across the lines. -- 2.43.0