Commit 7154c1ce by Nicolas Capens

Eliminate duplicate window size query code.

Change-Id: Ibe95427c6b626c308dff41996f636a7dc88f792c Reviewed-on: https://swiftshader-review.googlesource.com/4444Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent ad86752c
...@@ -21,18 +21,14 @@ ...@@ -21,18 +21,14 @@
#include "common/debug.h" #include "common/debug.h"
#include "Common/MutexLock.hpp" #include "Common/MutexLock.hpp"
#if defined(__unix__) && !defined(__ANDROID__)
#include "Main/libX11.hpp"
#endif
#ifdef __ANDROID__ #ifdef __ANDROID__
#include <system/window.h> #include <system/window.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <linux/fb.h> #include <linux/fb.h>
#include <fcntl.h> #include <fcntl.h>
#endif #elif defined(__unix__)
#include "Main/libX11.hpp"
#if defined(__APPLE__) #elif defined(__APPLE__)
#include "OSXUtils.hpp" #include "OSXUtils.hpp"
#endif #endif
......
...@@ -25,13 +25,9 @@ ...@@ -25,13 +25,9 @@
#if defined(__unix__) && !defined(__ANDROID__) #if defined(__unix__) && !defined(__ANDROID__)
#include "Main/libX11.hpp" #include "Main/libX11.hpp"
#endif #elif defined(_WIN32)
#if defined(_WIN32)
#include <tchar.h> #include <tchar.h>
#endif #elif defined(__APPLE__)
#if defined(__APPLE__)
#include "OSXUtils.hpp" #include "OSXUtils.hpp"
#endif #endif
...@@ -238,30 +234,7 @@ bool WindowSurface::initialize() ...@@ -238,30 +234,7 @@ bool WindowSurface::initialize()
{ {
ASSERT(!frameBuffer && !backBuffer && !depthStencil); ASSERT(!frameBuffer && !backBuffer && !depthStencil);
#if defined(_WIN32) return checkForResize();
RECT windowRect;
GetClientRect(window, &windowRect);
return reset(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top);
#elif defined(__ANDROID__)
int width; window->query(window, NATIVE_WINDOW_WIDTH, &width);
int height; window->query(window, NATIVE_WINDOW_HEIGHT, &height);
return reset(width, height);
#elif defined(__linux__)
XWindowAttributes windowAttributes;
libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
return reset(windowAttributes.width, windowAttributes.height);
#elif defined(__APPLE__)
int width;
int height;
sw::OSX::GetNativeWindowSize(window, width, height);
return reset(width, height);
#else
#error "WindowSurface::initialize unimplemented for this platform"
#endif
} }
void WindowSurface::swap() void WindowSurface::swap()
...@@ -291,41 +264,38 @@ bool WindowSurface::checkForResize() ...@@ -291,41 +264,38 @@ bool WindowSurface::checkForResize()
return false; return false;
} }
int clientWidth = client.right - client.left; int windowWidth = client.right - client.left;
int clientHeight = client.bottom - client.top; int windowHeight = client.bottom - client.top;
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
int clientWidth; window->query(window, NATIVE_WINDOW_WIDTH, &clientWidth); int windowWidth; window->query(window, NATIVE_WINDOW_WIDTH, &windowWidth);
int clientHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &clientHeight); int windowHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &windowHeight);
#elif defined(__linux__) #elif defined(__linux__)
XWindowAttributes windowAttributes; XWindowAttributes windowAttributes;
libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes); libX11->XGetWindowAttributes((::Display*)display->getNativeDisplay(), window, &windowAttributes);
int clientWidth = windowAttributes.width; int windowWidth = windowAttributes.width;
int clientHeight = windowAttributes.height; int windowHeight = windowAttributes.height;
#elif defined(__APPLE__) #elif defined(__APPLE__)
int clientWidth; int windowWidth;
int clientHeight; int windowHeight;
sw::OSX::GetNativeWindowSize(window, clientWidth, clientHeight); sw::OSX::GetNativeWindowSize(window, windowWidth, windowHeight);
return true;
#else #else
#error "WindowSurface::checkForResize unimplemented for this platform" #error "WindowSurface::checkForResize unimplemented for this platform"
#endif #endif
bool sizeDirty = (clientWidth != width) || (clientHeight != height); if((windowWidth != width) || (windowHeight != height))
if(sizeDirty)
{ {
reset(clientWidth, clientHeight); bool success = reset(windowWidth, windowHeight);
if(static_cast<egl::Surface*>(getCurrentDrawSurface()) == this) if(getCurrentDrawSurface() == this)
{ {
static_cast<egl::Context*>(getCurrentContext())->makeCurrent(this); getCurrentContext()->makeCurrent(this);
} }
return true; return success;
} }
return false; return true; // Success
} }
void WindowSurface::deleteResources() void WindowSurface::deleteResources()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment