Added DrawString in Display

This commit is contained in:
Alex 2022-12-26 08:40:34 +02:00
parent 18f05c6d83
commit c0a3d3dd24
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
2 changed files with 15 additions and 5 deletions

View File

@ -160,6 +160,15 @@ namespace Video
return Char;
}
void Display::DrawString(const char *String, uint32_t X, uint32_t Y, int Index, bool WriteToUART)
{
this->Buffers[Index]->CursorX = X;
this->Buffers[Index]->CursorY = Y;
for (int i = 0; String[i] != '\0'; i++)
this->Print(String[i], Index, WriteToUART);
}
Display::Display(BootInfo::FramebufferInfo Info, bool LoadDefaultFont)
{
this->framebuffer = Info;

View File

@ -154,19 +154,19 @@ namespace Video
*Y = this->Buffers[Index]->CursorY;
}
void SetPixel(uint32_t X, uint32_t Y, uint32_t Color, int Index)
inline void SetPixel(uint32_t X, uint32_t Y, uint32_t Color, int Index)
{
if (X >= this->Buffers[Index]->Width)
if (unlikely(X >= this->Buffers[Index]->Width))
X = this->Buffers[Index]->Width - 1;
if (Y >= this->Buffers[Index]->Height)
if (unlikely(Y >= this->Buffers[Index]->Height))
Y = this->Buffers[Index]->Height - 1;
uint32_t *Pixel = (uint32_t *)((uintptr_t)this->Buffers[Index]->Buffer + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8));
*Pixel = Color;
}
uint32_t GetPixel(uint32_t X, uint32_t Y, int Index)
inline uint32_t GetPixel(uint32_t X, uint32_t Y, int Index)
{
if (X >= this->Buffers[Index]->Width || Y >= this->Buffers[Index]->Height)
if (unlikely(X >= this->Buffers[Index]->Width || Y >= this->Buffers[Index]->Height))
return 0;
uint32_t *Pixel = (uint32_t *)((uintptr_t)this->Buffers[Index]->Buffer + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8));
return *Pixel;
@ -193,6 +193,7 @@ namespace Video
}
char Print(char Char, int Index, bool WriteToUART = false);
void DrawString(const char *String, uint32_t X, uint32_t Y, int Index, bool WriteToUART = false);
Display(BootInfo::FramebufferInfo Info, bool LoadDefaultFont = true);
~Display();
};