fb: store fb.pitch in words, not bytes
This commit is contained in:
parent
494ef6de81
commit
d03a34ab3e
14
src/fb.c
14
src/fb.c
@ -16,12 +16,12 @@ static inline uint32_t build_pixel(uint8_t r, uint8_t g, uint8_t b)
|
|||||||
|
|
||||||
static inline void fb_set_pixel(int x, int y, uint8_t r, uint8_t g, uint8_t b)
|
static inline void fb_set_pixel(int x, int y, uint8_t r, uint8_t g, uint8_t b)
|
||||||
{
|
{
|
||||||
fb.addr[fb.pitch * y / 4u + x] = build_pixel(r, g, b);
|
fb.addr[fb.pitch * y + x] = build_pixel(r, g, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fb_clear(void)
|
static void fb_clear(void)
|
||||||
{
|
{
|
||||||
memset32(fb.addr, 0x002C55u, fb.pitch * fb.height / 4u);
|
memset32(fb.addr, 0x002C55u, fb.pitch * fb.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fb_init(uint32_t * addr, uint32_t width, uint32_t height, uint32_t pitch)
|
void fb_init(uint32_t * addr, uint32_t width, uint32_t height, uint32_t pitch)
|
||||||
@ -29,7 +29,7 @@ void fb_init(uint32_t * addr, uint32_t width, uint32_t height, uint32_t pitch)
|
|||||||
fb.addr = addr;
|
fb.addr = addr;
|
||||||
fb.width = width;
|
fb.width = width;
|
||||||
fb.height = height;
|
fb.height = height;
|
||||||
fb.pitch = pitch;
|
fb.pitch = pitch / 4u;
|
||||||
fb_clear();
|
fb_clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ void fb_blend_alpha8(const uint8_t * bitmap, int width, int height, int pitch, i
|
|||||||
{
|
{
|
||||||
height = (int)fb.height - y;
|
height = (int)fb.height - y;
|
||||||
}
|
}
|
||||||
uint32_t * target = &fb.addr[fb.pitch * y / 4u + x];
|
uint32_t * target = &fb.addr[fb.pitch * y + x];
|
||||||
for (int row = 0; row < height; row++)
|
for (int row = 0; row < height; row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < width; col++)
|
for (int col = 0; col < width; col++)
|
||||||
@ -95,17 +95,17 @@ void fb_blend_alpha8(const uint8_t * bitmap, int width, int height, int pitch, i
|
|||||||
target[col] = pixel;
|
target[col] = pixel;
|
||||||
}
|
}
|
||||||
bitmap += pitch;
|
bitmap += pitch;
|
||||||
target += (fb.pitch / 4u);
|
target += fb.pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fb_fill(int x, int y, int width, int height, uint8_t r, uint8_t g, uint8_t b)
|
void fb_fill(int x, int y, int width, int height, uint8_t r, uint8_t g, uint8_t b)
|
||||||
{
|
{
|
||||||
uint32_t * target = &fb.addr[fb.pitch * y / 4u + x];
|
uint32_t * target = &fb.addr[fb.pitch * y + x];
|
||||||
uint32_t pixel = build_pixel(r, g, b);
|
uint32_t pixel = build_pixel(r, g, b);
|
||||||
for (int row = 0; row < height; row++)
|
for (int row = 0; row < height; row++)
|
||||||
{
|
{
|
||||||
memset32(target, pixel, width);
|
memset32(target, pixel, width);
|
||||||
target += fb.pitch / 4u;
|
target += fb.pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user