Commit b7e6c326 by Nicolas Capens

Simplify Android window property queries.

Change-Id: Ic54eefe422f5d0478b7cdd8dfaa19ccb2e1a8a8e Reviewed-on: https://swiftshader-review.googlesource.com/4131Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent c8bae0b7
...@@ -230,22 +230,6 @@ WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWi ...@@ -230,22 +230,6 @@ WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWi
frameBuffer = nullptr; frameBuffer = nullptr;
} }
#ifdef __ANDROID__
static int32_t getWindowProp(ANativeWindow* window, int what) {
int value;
int res = window->query(window, what, &value);
return res < 0 ? res : value;
}
static int32_t ANativeWindow_getHeight(ANativeWindow* window) {
return getWindowProp(window, NATIVE_WINDOW_HEIGHT);
}
static int32_t ANativeWindow_getWidth(ANativeWindow* window) {
return getWindowProp(window, NATIVE_WINDOW_WIDTH);
}
#endif
bool WindowSurface::initialize() bool WindowSurface::initialize()
{ {
ASSERT(!frameBuffer && !backBuffer && !depthStencil); ASSERT(!frameBuffer && !backBuffer && !depthStencil);
...@@ -256,7 +240,10 @@ bool WindowSurface::initialize() ...@@ -256,7 +240,10 @@ bool WindowSurface::initialize()
return reset(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); return reset(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top);
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
return reset(ANativeWindow_getWidth(window), ANativeWindow_getHeight(window)); int width; window->query(window, NATIVE_WINDOW_WIDTH, &width);
int height; window->query(window, NATIVE_WINDOW_HEIGHT, &height);
return reset(width, height);
#else #else
XWindowAttributes windowAttributes; XWindowAttributes windowAttributes;
libX11->XGetWindowAttributes(display->getNativeDisplay(), window, &windowAttributes); libX11->XGetWindowAttributes(display->getNativeDisplay(), window, &windowAttributes);
...@@ -295,8 +282,8 @@ bool WindowSurface::checkForResize() ...@@ -295,8 +282,8 @@ bool WindowSurface::checkForResize()
int clientWidth = client.right - client.left; int clientWidth = client.right - client.left;
int clientHeight = client.bottom - client.top; int clientHeight = client.bottom - client.top;
#elif defined(__ANDROID__) #elif defined(__ANDROID__)
int clientWidth = ANativeWindow_getWidth(window); int clientWidth; window->query(window, NATIVE_WINDOW_WIDTH, &clientWidth);
int clientHeight = ANativeWindow_getHeight(window); int clientHeight; window->query(window, NATIVE_WINDOW_HEIGHT, &clientHeight);
#else #else
XWindowAttributes windowAttributes; XWindowAttributes windowAttributes;
libX11->XGetWindowAttributes(display->getNativeDisplay(), window, &windowAttributes); libX11->XGetWindowAttributes(display->getNativeDisplay(), window, &windowAttributes);
......
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