graphics: make SetPixel() an inline instead of a function pointer
graphics_Init() happens before relocation, so the function breaks once the identity mapping is removed (or flagged NX)
This commit is contained in:
parent
b361c6830b
commit
218e5c2c96
@ -110,9 +110,7 @@ void graphics_Init() {
|
|||||||
case v: io_Printf(#v "\r\n");
|
case v: io_Printf(#v "\r\n");
|
||||||
switch (gop->Mode->Info->PixelFormat) {
|
switch (gop->Mode->Info->PixelFormat) {
|
||||||
CASE(PixelRedGreenBlueReserved8BitPerColor)
|
CASE(PixelRedGreenBlueReserved8BitPerColor)
|
||||||
graphics_SetPixel = graphics_SetPixel_RGB;
|
|
||||||
CASE(PixelBlueGreenRedReserved8BitPerColor)
|
CASE(PixelBlueGreenRedReserved8BitPerColor)
|
||||||
graphics_SetPixel = graphics_SetPixel_BGR;
|
|
||||||
CASE(PixelBitMask)
|
CASE(PixelBitMask)
|
||||||
CASE(PixelBltOnly)
|
CASE(PixelBltOnly)
|
||||||
CASE(PixelFormatMax)
|
CASE(PixelFormatMax)
|
||||||
@ -131,8 +129,6 @@ void graphics_Init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
graphics_SetPixel_Type *graphics_SetPixel;
|
|
||||||
|
|
||||||
void graphics_SetPixel_RGB(int posX, int posY, const HelosGraphics_Color *color) {
|
void graphics_SetPixel_RGB(int posX, int posY, const HelosGraphics_Color *color) {
|
||||||
struct {
|
struct {
|
||||||
uint8_t R, G, B;
|
uint8_t R, G, B;
|
||||||
|
@ -43,14 +43,18 @@ void graphics_SwapBuffer();
|
|||||||
void graphics_Invalidate(int left, int top, int width, int height); // Invalidates a rectangular region
|
void graphics_Invalidate(int left, int top, int width, int height); // Invalidates a rectangular region
|
||||||
|
|
||||||
|
|
||||||
// graphics_SetPixel is set by Init() to match one of SetPixel_RGB/BGR according to the framebuffer format.
|
|
||||||
typedef void(graphics_SetPixel_Type)(int posX, int posY, const HelosGraphics_Color *color);
|
|
||||||
extern graphics_SetPixel_Type *graphics_SetPixel;
|
|
||||||
|
|
||||||
// graphics_SetPixel_RGB/BGR writes the given pixel to the framebuffer in RGB/BGR format.
|
// graphics_SetPixel_RGB/BGR writes the given pixel to the framebuffer in RGB/BGR format.
|
||||||
void graphics_SetPixel_RGB(int posX, int posY, const HelosGraphics_Color *color);
|
void graphics_SetPixel_RGB(int posX, int posY, const HelosGraphics_Color *color);
|
||||||
void graphics_SetPixel_BGR(int posX, int posY, const HelosGraphics_Color *color);
|
void graphics_SetPixel_BGR(int posX, int posY, const HelosGraphics_Color *color);
|
||||||
|
|
||||||
|
// graphics_SetPixel calls one of SetPixel_RGB/BGR according to the framebuffer format.
|
||||||
|
static inline void graphics_SetPixel(int posX, int posY, const HelosGraphics_Color *color) {
|
||||||
|
if (graphics_SystemVideoMode.PixelFormat == PixelBlueGreenRedReserved8BitPerColor)
|
||||||
|
graphics_SetPixel_BGR(posX, posY, color);
|
||||||
|
else if (graphics_SystemVideoMode.PixelFormat == PixelRedGreenBlueReserved8BitPerColor)
|
||||||
|
graphics_SetPixel_RGB(posX, posY, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void graphics_FillPixel(int startX, int startY, int endX, int endY, const HelosGraphics_Color *color);
|
void graphics_FillPixel(int startX, int startY, int endX, int endY, const HelosGraphics_Color *color);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user