Remove duplicate code
This commit is contained in:
parent
a6b146dfdd
commit
2960aa54e2
@ -2894,27 +2894,17 @@ WORD GetColorAttribute(GTestColor color) {
|
||||
}
|
||||
}
|
||||
|
||||
int GetBgOffset(WORD background_mask) {
|
||||
if (background_mask == 0) return 0;
|
||||
int GetBitOffset(WORD color_mask) {
|
||||
if (color_mask == 0) return 0;
|
||||
|
||||
int bitOffset = 0;
|
||||
while((background_mask & 1) == 0) {
|
||||
background_mask >>= 1;
|
||||
while((color_mask & 1) == 0) {
|
||||
color_mask >>= 1;
|
||||
++bitOffset;
|
||||
}
|
||||
return bitOffset;
|
||||
}
|
||||
|
||||
int GetFgOffset(WORD foreground_mask) {
|
||||
if (foreground_mask == 0) return 0;
|
||||
|
||||
int bitOffset = 0;
|
||||
while((foreground_mask & 1) == 0) {
|
||||
foreground_mask >>= 1;
|
||||
++bitOffset;
|
||||
}
|
||||
return bitOffset;
|
||||
}
|
||||
WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
|
||||
// Let's reuse the BG
|
||||
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY;
|
||||
@ -2922,8 +2912,8 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) {
|
||||
const WORD existing_bg = old_color_attrs & background_mask;
|
||||
|
||||
WORD new_color = GetColorAttribute(color) | existing_bg | FOREGROUND_INTENSITY;
|
||||
static const int bg_bitOffset = GetBgOffset(background_mask);
|
||||
static const int fg_bitOffset = GetFgOffset(foreground_mask);
|
||||
static const int bg_bitOffset = GetBitOffset(background_mask);
|
||||
static const int fg_bitOffset = GetBitOffset(foreground_mask);
|
||||
|
||||
if (((new_color & background_mask) >> bg_bitOffset) == ((new_color & foreground_mask) >> fg_bitOffset)) {
|
||||
new_color ^= FOREGROUND_INTENSITY; //invert intensity
|
||||
|
Loading…
Reference in New Issue
Block a user