Fixed mirrored glyphs on big-endian machines

This commit is contained in:
Alexey 2022-06-24 15:12:54 +00:00 committed by Matt Turner
parent 893e9a3238
commit 4cf8922270
2 changed files with 16 additions and 0 deletions

View File

@ -102,7 +102,11 @@ glamor_poly_glyph_blt_gl(DrawablePtr drawable, GCPtr gc,
int pt_x_i = glyph_x + xx; int pt_x_i = glyph_x + xx;
int pt_y_i = glyph_y + yy; int pt_y_i = glyph_y + yy;
#if BITMAP_BIT_ORDER == MSBFirst
if (!(*glyph & (128 >> (xx & 7))))
#else
if (!(*glyph & (1 << (xx & 7)))) if (!(*glyph & (1 << (xx & 7))))
#endif
continue; continue;
if (!RegionContainsPoint(clip, pt_x_i, pt_y_i, NULL)) if (!RegionContainsPoint(clip, pt_x_i, pt_y_i, NULL))
@ -209,7 +213,11 @@ glamor_push_pixels_gl(GCPtr gc, PixmapPtr bitmap,
for (yy = 0; yy < h; yy++) { for (yy = 0; yy < h; yy++) {
uint8_t *bitmap_row = bitmap_data + yy * bitmap_stride; uint8_t *bitmap_row = bitmap_data + yy * bitmap_stride;
for (xx = 0; xx < w; xx++) { for (xx = 0; xx < w; xx++) {
#if BITMAP_BIT_ORDER == MSBFirst
if (bitmap_row[xx / 8] & (128 >> xx % 8) &&
#else
if (bitmap_row[xx / 8] & (1 << xx % 8) && if (bitmap_row[xx / 8] & (1 << xx % 8) &&
#endif
RegionContainsPoint(clip, RegionContainsPoint(clip,
x + xx, x + xx,
y + yy, y + yy,

View File

@ -235,7 +235,11 @@ static const char fs_vars_text[] =
static const char fs_exec_text[] = static const char fs_exec_text[] =
" ivec2 itile_texture = ivec2(glyph_pos);\n" " ivec2 itile_texture = ivec2(glyph_pos);\n"
#if BITMAP_BIT_ORDER == MSBFirst
" uint x = uint(7) - uint(itile_texture.x & 7);\n"
#else
" uint x = uint(itile_texture.x & 7);\n" " uint x = uint(itile_texture.x & 7);\n"
#endif
" itile_texture.x >>= 3;\n" " itile_texture.x >>= 3;\n"
" uint texel = texelFetch(font, itile_texture, 0).x;\n" " uint texel = texelFetch(font, itile_texture, 0).x;\n"
" uint bit = (texel >> x) & uint(1);\n" " uint bit = (texel >> x) & uint(1);\n"
@ -244,7 +248,11 @@ static const char fs_exec_text[] =
static const char fs_exec_te[] = static const char fs_exec_te[] =
" ivec2 itile_texture = ivec2(glyph_pos);\n" " ivec2 itile_texture = ivec2(glyph_pos);\n"
#if BITMAP_BIT_ORDER == MSBFirst
" uint x = uint(7) - uint(itile_texture.x & 7);\n"
#else
" uint x = uint(itile_texture.x & 7);\n" " uint x = uint(itile_texture.x & 7);\n"
#endif
" itile_texture.x >>= 3;\n" " itile_texture.x >>= 3;\n"
" uint texel = texelFetch(font, itile_texture, 0).x;\n" " uint texel = texelFetch(font, itile_texture, 0).x;\n"
" uint bit = (texel >> x) & uint(1);\n" " uint bit = (texel >> x) & uint(1);\n"