Merge pull request #562 from fluxchief/border-endian

improve endianess handeling
This commit is contained in:
Drew DeVault 2016-04-02 16:29:48 -04:00
commit ef45bac131

View file

@ -8,21 +8,16 @@
#include "config.h"
#include "client/pango.h"
#include <arpa/inet.h>
void cairo_set_source_u32(cairo_t *cairo, uint32_t color) {
int endian = 1;
if (*(char *)&endian == 1) { // little endian
color = htonl(color);
cairo_set_source_rgba(cairo,
(color >> (2*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 >> (3*8) & 0xFF) / 255.0,
(color >> (2*8) & 0xFF) / 255.0,
(color >> (1*8) & 0xFF) / 255.0);
}
(color >> (3*8) & 0xFF) / 255.0);
}
static cairo_t *create_border_buffer(swayc_t *view, struct wlc_geometry geo, cairo_surface_t **surface) {