CHANGE: Elimated variable overhead in glfwGetMonitorFromWindow.

This commit is contained in:
Carsten Tewes 2022-11-20 17:05:36 +01:00
parent e01fb0f6de
commit 47d2e58e48

View File

@ -981,16 +981,12 @@ GLFWAPI GLFWmonitor* glfwGetMonitorFromWindow(GLFWwindow* window)
GLFWmonitor** monitors; GLFWmonitor** monitors;
const GLFWvidmode* vidmode; const GLFWvidmode* vidmode;
int windowWidth, windowHeight;
int windowFrameLeft, windowFrameTop, windowFrameRight, windowFrameBottom;
unsigned int currentDim, overlapDim; unsigned int currentDim, overlapDim;
int overlapMonitor; int overlapMonitor, i;
int i;
_rect windowRect; _rect windowRect;
_rect monitorRect; _rect monitorRect;
_rect currentRect = { 0, 0, 0, 0 }; _rect scratchRect = { 0, 0, 0, 0 };
_rect overlapRect = { 0, 0, 0, 0 }; _rect overlapRect = { 0, 0, 0, 0 };
assert(window != NULL); assert(window != NULL);
@ -1006,17 +1002,15 @@ GLFWAPI GLFWmonitor* glfwGetMonitorFromWindow(GLFWwindow* window)
else if (monitorCount > 1) else if (monitorCount > 1)
{ {
glfwGetWindowPos(window, &windowRect.x, &windowRect.y); glfwGetWindowPos(window, &windowRect.x, &windowRect.y);
glfwGetWindowSize(window, &windowWidth, &windowHeight); glfwGetWindowSize(window, &windowRect.w, &windowRect.h);
windowRect.w = windowWidth;
windowRect.h = windowHeight;
glfwGetWindowFrameSize(window, &windowFrameLeft, &windowFrameTop, glfwGetWindowFrameSize(window, &scratchRect.x, &scratchRect.y,
&windowFrameRight, &windowFrameBottom); &scratchRect.w, &scratchRect.h);
windowRect.x -= windowFrameLeft; windowRect.x -= scratchRect.x;
windowRect.y -= windowFrameTop; windowRect.y -= scratchRect.y;
windowRect.w += windowFrameLeft + windowFrameRight; windowRect.w += scratchRect.x + scratchRect.w;
windowRect.h += windowFrameTop + windowFrameBottom; windowRect.h += scratchRect.y + scratchRect.h;
overlapMonitor = -1; overlapMonitor = -1;
@ -1028,14 +1022,14 @@ GLFWAPI GLFWmonitor* glfwGetMonitorFromWindow(GLFWwindow* window)
monitorRect.w = vidmode->width; monitorRect.w = vidmode->width;
monitorRect.h = vidmode->height; monitorRect.h = vidmode->height;
currentRect = _get_intersection(&windowRect, &monitorRect); scratchRect = _get_intersection(&windowRect, &monitorRect);
currentDim = currentRect.w * currentRect.h; currentDim = scratchRect.w * scratchRect.h;
overlapDim = overlapRect.w * overlapRect.h; overlapDim = overlapRect.w * overlapRect.h;
if (currentDim > 0 && currentDim > overlapDim) if (currentDim > 0 && currentDim > overlapDim)
{ {
overlapRect = currentRect; overlapRect = scratchRect;
overlapMonitor = i; overlapMonitor = i;
} }
} }