pkg/pixman: fix math for bpp calculation

This commit is contained in:
Mitchell Hashimoto
2022-11-23 20:20:52 -08:00
parent 894d36f28a
commit ac4a45bdf3

View File

@ -96,8 +96,8 @@ pub const FormatCode = enum(c_uint) {
const val = @enumToInt(self);
const v1 = val >> ofs;
const v2 = @as(c_uint, 1) << num;
const v3 = @intCast(u5, val >> 22);
return ((v1 & (v2 - 1)) << (v3 & 3));
const v3 = @intCast(u5, (val >> 22) & 3);
return ((v1 & (v2 - 1)) << v3);
}
};
@ -106,4 +106,5 @@ test "bpp" {
try testing.expectEqual(@as(u32, 1), FormatCode.g1.bpp());
try testing.expectEqual(@as(u32, 4), FormatCode.g4.bpp());
try testing.expectEqual(@as(u32, 8), FormatCode.g8.bpp());
}