From 877916138390d30be00df0acb47ce37c48aa337c Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 14 Jan 2018 20:39:10 +0100 Subject: [PATCH] yaft: simplify pointer arithmetics Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/c3cd2f68c6d0c24674e30a73f5278af1217276b9 Author: Stefan Seyfried Date: 2018-01-14 (Sun, 14 Jan 2018) --- src/gui/widget/yaft/fb/common.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gui/widget/yaft/fb/common.h b/src/gui/widget/yaft/fb/common.h index a5ff026d8..030ada6da 100644 --- a/src/gui/widget/yaft/fb/common.h +++ b/src/gui/widget/yaft/fb/common.h @@ -69,7 +69,7 @@ struct fb_info_t { struct framebuffer_t { int fd; /* file descriptor of framebuffer */ - uint8_t *buf; /* copy of framebuffer */ + uint32_t *buf; /* copy of framebuffer */ #if 0 uint8_t *fp; /* pointer of framebuffer */ uint8_t *wall; /* buffer for wallpaper */ @@ -333,7 +333,7 @@ bool fb_init(struct framebuffer_t *fb) return false; #endif - fb->buf = (uint8_t *)fb->info.cfb->getBackBufferPointer(); + fb->buf = (uint32_t *)fb->info.cfb->getBackBufferPointer(); /* os dependent initialize */ if (!set_fbinfo(fb->fd, &fb->info)) return false; //goto set_fbinfo_failed; @@ -476,8 +476,8 @@ static inline void draw_line(struct framebuffer_t *fb, struct terminal_t *term, color_pair.bg = color_pair.fg; for (w = 0; w < CELL_WIDTH; w++) { - pos = (term->width - 1 - margin_right - w) * fb->info.bytes_per_pixel - + (line * CELL_HEIGHT + h) * fb->info.line_length; + pos = (term->width - 1 - margin_right - w) + + (line * CELL_HEIGHT + h) * fb->info.width; /* set color palette */ if (cellp->glyphp->bitmap[h] & (0x01 << (bdf_padding + w))) @@ -490,7 +490,8 @@ static inline void draw_line(struct framebuffer_t *fb, struct terminal_t *term, pixel = fb->real_palette[color_pair.bg]; /* update copy buffer only */ - memcpy(fb->buf + pos, &pixel, fb->info.bytes_per_pixel); + //memcpy(fb->buf + pos, &pixel, fb->info.bytes_per_pixel); + fb->buf[pos] = pixel; } } }