Convert RGB colors to FrameBuffer format
This commit is contained in:
parent
e311cad8f7
commit
78424385fc
@ -14,7 +14,7 @@
|
|||||||
* Clears the screen by drawing a box filled with specified color.
|
* Clears the screen by drawing a box filled with specified color.
|
||||||
*
|
*
|
||||||
* @param Color
|
* @param Color
|
||||||
* Specifies the color of the box used to fill the screen.
|
* Specifies the color of the box used to fill the screen in (A)RGB format.
|
||||||
*
|
*
|
||||||
* @return This routine does not return any value.
|
* @return This routine does not return any value.
|
||||||
*
|
*
|
||||||
@ -25,18 +25,22 @@ VOID
|
|||||||
HlClearScreen(IN ULONG Color)
|
HlClearScreen(IN ULONG Color)
|
||||||
{
|
{
|
||||||
SIZE_T Line, PositionX, PositionY;
|
SIZE_T Line, PositionX, PositionY;
|
||||||
|
ULONG BackgroundColor;
|
||||||
PULONG FrameBuf;
|
PULONG FrameBuf;
|
||||||
|
|
||||||
/* Get pointer to frame buffer */
|
/* Get pointer to frame buffer */
|
||||||
FrameBuf = HlpFrameBufferData.Address;
|
FrameBuf = HlpFrameBufferData.Address;
|
||||||
|
|
||||||
|
/* Convert background color */
|
||||||
|
BackgroundColor = HlRGBColor(Color);
|
||||||
|
|
||||||
/* Fill the screen with a black box */
|
/* Fill the screen with a black box */
|
||||||
for(PositionY = 0; PositionY < HlpFrameBufferData.Height; PositionY++)
|
for(PositionY = 0; PositionY < HlpFrameBufferData.Height; PositionY++)
|
||||||
{
|
{
|
||||||
Line = PositionY * HlpFrameBufferData.PixelsPerScanLine;
|
Line = PositionY * HlpFrameBufferData.PixelsPerScanLine;
|
||||||
for(PositionX = 0; PositionX < HlpFrameBufferData.Width; PositionX++)
|
for(PositionX = 0; PositionX < HlpFrameBufferData.Width; PositionX++)
|
||||||
{
|
{
|
||||||
FrameBuf[Line + PositionX] = Color;
|
FrameBuf[Line + PositionX] = BackgroundColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,7 +55,7 @@ HlClearScreen(IN ULONG Color)
|
|||||||
* Supplies the Y coordinate of the pixel.
|
* Supplies the Y coordinate of the pixel.
|
||||||
*
|
*
|
||||||
* @param Color
|
* @param Color
|
||||||
* Specifies the color of the pixel.
|
* Specifies the color of the pixel in (A)RGB format.
|
||||||
*
|
*
|
||||||
* @return This routine does not return any value.
|
* @return This routine does not return any value.
|
||||||
*
|
*
|
||||||
@ -83,7 +87,7 @@ HlDrawPixel(IN ULONG PositionX,
|
|||||||
FrameBufferIndex = 4 * HlpFrameBufferData.PixelsPerScanLine * PositionY + 4 * PositionX;
|
FrameBufferIndex = 4 * HlpFrameBufferData.PixelsPerScanLine * PositionY + 4 * PositionX;
|
||||||
|
|
||||||
/* Set the color of the pixel by writing to the corresponding memory location */
|
/* Set the color of the pixel by writing to the corresponding memory location */
|
||||||
*((PULONG)(HlpFrameBufferData.Address + FrameBufferIndex)) = Color;
|
*((PULONG)(HlpFrameBufferData.Address + FrameBufferIndex)) = HlRGBColor(Color);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +162,7 @@ HlInitializeFrameBuffer(VOID)
|
|||||||
* Supplies the Y coordinate of the character.
|
* Supplies the Y coordinate of the character.
|
||||||
*
|
*
|
||||||
* @param Color
|
* @param Color
|
||||||
* Supplies the font color.
|
* Supplies the font color in (A)RGB format.
|
||||||
*
|
*
|
||||||
* @param WideCharacter
|
* @param WideCharacter
|
||||||
* Supplies the wide character to be drawn on the framebuffer.
|
* Supplies the wide character to be drawn on the framebuffer.
|
||||||
@ -178,6 +182,7 @@ HlPutCharacter(IN ULONG PositionX,
|
|||||||
PUCHAR Character, CharacterMapping, Fragment;
|
PUCHAR Character, CharacterMapping, Fragment;
|
||||||
UINT_PTR GlyphPixel, Pixel;
|
UINT_PTR GlyphPixel, Pixel;
|
||||||
PSSFN_FONT_HEADER FbFont;
|
PSSFN_FONT_HEADER FbFont;
|
||||||
|
ULONG FontColor;
|
||||||
|
|
||||||
/* Get pointers to font data */
|
/* Get pointers to font data */
|
||||||
FbFont = (PSSFN_FONT_HEADER)HlpFrameBufferData.Font;
|
FbFont = (PSSFN_FONT_HEADER)HlpFrameBufferData.Font;
|
||||||
@ -227,8 +232,9 @@ HlPutCharacter(IN ULONG PositionX,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find the glyph position on the frame buffer */
|
/* Find the glyph position on the frame buffer and set font color */
|
||||||
GlyphPixel = (UINT_PTR)HlpFrameBufferData.Address + PositionY * HlpFrameBufferData.Pitch + PositionX * 4;
|
GlyphPixel = (UINT_PTR)HlpFrameBufferData.Address + PositionY * HlpFrameBufferData.Pitch + PositionX * 4;
|
||||||
|
FontColor = HlRGBColor(Color);
|
||||||
|
|
||||||
/* Check all kerning fragments */
|
/* Check all kerning fragments */
|
||||||
Mapping = 0;
|
Mapping = 0;
|
||||||
@ -283,7 +289,7 @@ HlPutCharacter(IN ULONG PositionX,
|
|||||||
if(*Fragment & CurrentFragment)
|
if(*Fragment & CurrentFragment)
|
||||||
{
|
{
|
||||||
/* Draw glyph pixel */
|
/* Draw glyph pixel */
|
||||||
*((PULONG)Pixel) = Color;
|
*((PULONG)Pixel) = FontColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Advance pixel pointer */
|
/* Advance pixel pointer */
|
||||||
@ -300,3 +306,30 @@ HlPutCharacter(IN ULONG PositionX,
|
|||||||
CharacterMapping += Character[0] & 0x40 ? 6 : 5;
|
CharacterMapping += Character[0] & 0x40 ? 6 : 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts color format from (A)RGB one expected by current FrameBuffer.
|
||||||
|
*
|
||||||
|
* @param Color
|
||||||
|
* Specifies the color in (A)RGB format.
|
||||||
|
*
|
||||||
|
* @return Returns the color in FrameBuffer format.
|
||||||
|
*
|
||||||
|
* @since XT 1.0
|
||||||
|
*/
|
||||||
|
XTAPI
|
||||||
|
ULONG
|
||||||
|
HlRGBColor(IN ULONG Color)
|
||||||
|
{
|
||||||
|
USHORT Blue, Green, Red, Reserved;
|
||||||
|
|
||||||
|
/* Extract color components from (A)RGB value */
|
||||||
|
Blue = (USHORT)(Color & 0xFF);
|
||||||
|
Green = (USHORT)((Color >> 8) & 0xFF);
|
||||||
|
Red = (USHORT)((Color >> 16) & 0xFF);
|
||||||
|
Reserved = (USHORT)((Color >> 24) & 0xFF);
|
||||||
|
|
||||||
|
/* Return color in FrameBuffer pixel format */
|
||||||
|
return (ULONG)((Blue << HlpFrameBufferData.Pixels.BlueShift) | (Green << HlpFrameBufferData.Pixels.GreenShift) |
|
||||||
|
(Red << HlpFrameBufferData.Pixels.RedShift) | (Reserved << HlpFrameBufferData.Pixels.ReservedShift));
|
||||||
|
}
|
||||||
|
@ -62,6 +62,10 @@ HlPutCharacter(IN ULONG PositionX,
|
|||||||
IN ULONG Color,
|
IN ULONG Color,
|
||||||
IN WCHAR WideCharacter);
|
IN WCHAR WideCharacter);
|
||||||
|
|
||||||
|
XTAPI
|
||||||
|
ULONG
|
||||||
|
HlRGBColor(IN ULONG Color);
|
||||||
|
|
||||||
XTFASTCALL
|
XTFASTCALL
|
||||||
VOID
|
VOID
|
||||||
HlSetRunLevel(IN KRUNLEVEL RunLevel);
|
HlSetRunLevel(IN KRUNLEVEL RunLevel);
|
||||||
|
Loading…
Reference in New Issue
Block a user