mirror of
https://github.com/swaywm/sway.git
synced 2024-11-14 06:24:20 +01:00
improve endianess handeling
This commit is contained in:
parent
4885a6c423
commit
3953b064f5
@ -8,21 +8,16 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "client/pango.h"
|
#include "client/pango.h"
|
||||||
|
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
|
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
|
||||||
int endian = 1;
|
color = htonl(color);
|
||||||
if (*(char *)&endian == 1) { // little endian
|
|
||||||
cairo_set_source_rgba(cairo,
|
cairo_set_source_rgba(cairo,
|
||||||
|
(color >> (2*8) & 0xFF) / 255.0,
|
||||||
(color >> (1*8) & 0xFF) / 255.0,
|
(color >> (1*8) & 0xFF) / 255.0,
|
||||||
(color >> (2*8) & 0xFF) / 255.0,
|
|
||||||
(color >> (3*8) & 0xFF) / 255.0,
|
|
||||||
(color >> (0*8) & 0xFF) / 255.0);
|
|
||||||
} else { // big endian
|
|
||||||
cairo_set_source_rgba(cairo,
|
|
||||||
(color >> (0*8) & 0xFF) / 255.0,
|
(color >> (0*8) & 0xFF) / 255.0,
|
||||||
(color >> (3*8) & 0xFF) / 255.0,
|
(color >> (3*8) & 0xFF) / 255.0);
|
||||||
(color >> (2*8) & 0xFF) / 255.0,
|
|
||||||
(color >> (1*8) & 0xFF) / 255.0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry geo, cairo_surface_t **surface) {
|
static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry geo, cairo_surface_t **surface) {
|
||||||
|
Loading…
Reference in New Issue
Block a user