Merge pull request #854 from 0x0203/x11_rawfb_fixes
Fix nits (see PR #851) to clean up x11_rawfbmaster
commit
e41c07802f
|
@ -92,11 +92,11 @@ nk_rawfb_color2int(const struct nk_color c, rawfb_pl pl)
|
||||||
res |= c.a << 24;
|
res |= c.a << 24;
|
||||||
res |= c.r << 16;
|
res |= c.r << 16;
|
||||||
res |= c.g << 8;
|
res |= c.g << 8;
|
||||||
res |= c.b << 0;
|
res |= c.b;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
perror("Unsupported pixel layout.\n");
|
perror("nk_rawfb_color2int(): Unsupported pixel layout.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return (res);
|
return (res);
|
||||||
|
@ -112,17 +112,17 @@ nk_rawfb_int2color(const unsigned int i, rawfb_pl pl)
|
||||||
col.r = (i >> 24) & 0xff;
|
col.r = (i >> 24) & 0xff;
|
||||||
col.g = (i >> 16) & 0xff;
|
col.g = (i >> 16) & 0xff;
|
||||||
col.b = (i >> 8) & 0xff;
|
col.b = (i >> 8) & 0xff;
|
||||||
col.a = (i >> 0) & 0xff;
|
col.a = i & 0xff;
|
||||||
break;
|
break;
|
||||||
case PIXEL_LAYOUT_XRGB_8888:
|
case PIXEL_LAYOUT_XRGB_8888:
|
||||||
col.a = (i >> 24) & 0xff;
|
col.a = (i >> 24) & 0xff;
|
||||||
col.r = (i >> 16) & 0xff;
|
col.r = (i >> 16) & 0xff;
|
||||||
col.g = (i >> 8) & 0xff;
|
col.g = (i >> 8) & 0xff;
|
||||||
col.b = (i >> 0) & 0xff;
|
col.b = i & 0xff;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
perror("Unsupported pixel layout.\n");
|
perror("nk_rawfb_int2color(): Unsupported pixel layout.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return col;
|
return col;
|
||||||
|
@ -137,8 +137,7 @@ nk_rawfb_ctx_setpixel(const struct rawfb_context *rawfb,
|
||||||
unsigned int *ptr;
|
unsigned int *ptr;
|
||||||
|
|
||||||
pixels += y0 * rawfb->fb.pitch;
|
pixels += y0 * rawfb->fb.pitch;
|
||||||
ptr = (unsigned int *)pixels;
|
ptr = (unsigned int *)pixels + x0;
|
||||||
ptr += x0;
|
|
||||||
|
|
||||||
if (y0 < rawfb->scissors.h && y0 >= rawfb->scissors.y &&
|
if (y0 < rawfb->scissors.h && y0 >= rawfb->scissors.y &&
|
||||||
x0 >= rawfb->scissors.x && x0 < rawfb->scissors.w)
|
x0 >= rawfb->scissors.x && x0 < rawfb->scissors.w)
|
||||||
|
@ -158,8 +157,7 @@ nk_rawfb_line_horizontal(const struct rawfb_context *rawfb,
|
||||||
unsigned int *ptr;
|
unsigned int *ptr;
|
||||||
|
|
||||||
pixels += y * rawfb->fb.pitch;
|
pixels += y * rawfb->fb.pitch;
|
||||||
ptr = (unsigned int *)pixels;
|
ptr = (unsigned int *)pixels + x0;
|
||||||
ptr += x0;
|
|
||||||
|
|
||||||
n = x1 - x0;
|
n = x1 - x0;
|
||||||
for (i = 0; i < sizeof(c) / sizeof(c[0]); i++)
|
for (i = 0; i < sizeof(c) / sizeof(c[0]); i++)
|
||||||
|
@ -181,8 +179,7 @@ nk_rawfb_img_setpixel(const struct rawfb_image *img,
|
||||||
unsigned int *pixel;
|
unsigned int *pixel;
|
||||||
NK_ASSERT(img);
|
NK_ASSERT(img);
|
||||||
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
|
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
|
||||||
ptr = img->pixels;
|
ptr = img->pixels + (img->pitch * y0);
|
||||||
ptr += img->pitch * y0;
|
|
||||||
pixel = (unsigned int *)ptr;
|
pixel = (unsigned int *)ptr;
|
||||||
|
|
||||||
if (img->format == NK_FONT_ATLAS_ALPHA8) {
|
if (img->format == NK_FONT_ATLAS_ALPHA8) {
|
||||||
|
@ -198,19 +195,17 @@ nk_rawfb_img_getpixel(const struct rawfb_image *img, const int x0, const int y0)
|
||||||
{
|
{
|
||||||
struct nk_color col = {0, 0, 0, 0};
|
struct nk_color col = {0, 0, 0, 0};
|
||||||
unsigned char *ptr;
|
unsigned char *ptr;
|
||||||
unsigned int *pixel;
|
unsigned int pixel;
|
||||||
NK_ASSERT(img);
|
NK_ASSERT(img);
|
||||||
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
|
if (y0 < img->h && y0 >= 0 && x0 >= 0 && x0 < img->w) {
|
||||||
ptr = img->pixels;
|
ptr = img->pixels + (img->pitch * y0);
|
||||||
ptr += img->pitch * y0;
|
|
||||||
|
|
||||||
if (img->format == NK_FONT_ATLAS_ALPHA8) {
|
if (img->format == NK_FONT_ATLAS_ALPHA8) {
|
||||||
col.a = ptr[x0];
|
col.a = ptr[x0];
|
||||||
col.b = col.g = col.r = 0xff;
|
col.b = col.g = col.r = 0xff;
|
||||||
} else {
|
} else {
|
||||||
pixel = ptr;
|
pixel = ((unsigned int *)ptr)[x0];
|
||||||
pixel += x0;
|
col = nk_rawfb_int2color(pixel, img->pl);
|
||||||
col = nk_rawfb_int2color(*pixel, img->pl);
|
|
||||||
}
|
}
|
||||||
} return col;
|
} return col;
|
||||||
}
|
}
|
||||||
|
@ -841,7 +836,7 @@ nk_rawfb_init(void *fb, void *tex_mem, const unsigned int w, const unsigned int
|
||||||
rawfb->fb.pitch = pitch;
|
rawfb->fb.pitch = pitch;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
perror("Unsupported pixel layout.\n");
|
perror("nk_rawfb_init(): Unsupported pixel layout.\n");
|
||||||
free(rawfb);
|
free(rawfb);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ nk_xlib_init(Display *dpy, Visual *vis, int screen, Window root,
|
||||||
*pl = PIXEL_LAYOUT_RGBX_8888;
|
*pl = PIXEL_LAYOUT_RGBX_8888;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printf("Unrecognized pixel layout.\n");
|
perror("nk_xlib_init(): Unrecognized pixel layout.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue