mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
CHANGE: Elimated variable overhead in glfwGetMonitorFromWindow.
This commit is contained in:
parent
e01fb0f6de
commit
47d2e58e48
30
src/window.c
30
src/window.c
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user