Commit 8add0eb7 by Jamie Madill

Use OSWindow with angle_tests for Window management.

BUG=angle:730 Change-Id: I409fd4f4e00eb0d8d964b0ac199fa6f675a36df8 Reviewed-on: https://chromium-review.googlesource.com/213295Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org>
parent b547ddf5
#include "ANGLETest.h" #include "ANGLETest.h"
#include "OSWindow.h"
OSWindow *ANGLETest::mOSWindow = NULL;
ANGLETest::ANGLETest() ANGLETest::ANGLETest()
: mTestPlatform(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE), : mTestPlatform(EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE),
...@@ -19,9 +22,6 @@ ANGLETest::ANGLETest() ...@@ -19,9 +22,6 @@ ANGLETest::ANGLETest()
{ {
} }
EGLNativeWindowType ANGLETest::mNativeWindow = 0;
EGLNativeDisplayType ANGLETest::mNativeDisplay = 0;
void ANGLETest::SetUp() void ANGLETest::SetUp()
{ {
ResizeWindow(mWidth, mHeight); ResizeWindow(mWidth, mHeight);
...@@ -38,6 +38,16 @@ void ANGLETest::TearDown() ...@@ -38,6 +38,16 @@ void ANGLETest::TearDown()
{ {
FAIL() << "egl context destruction failed."; FAIL() << "egl context destruction failed.";
} }
// Check for quit message
Event myEvent;
while (mOSWindow->popEvent(&myEvent))
{
if (myEvent.Type == Event::EVENT_CLOSED)
{
exit(0);
}
}
} }
void ANGLETest::swapBuffers() void ANGLETest::swapBuffers()
...@@ -264,7 +274,7 @@ bool ANGLETest::createEGLContext() ...@@ -264,7 +274,7 @@ bool ANGLETest::createEGLContext()
EGL_NONE, EGL_NONE,
}; };
mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, mNativeDisplay, displayAttributes); mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, mOSWindow->getNativeDisplay(), displayAttributes);
if (mDisplay == EGL_NO_DISPLAY) if (mDisplay == EGL_NO_DISPLAY)
{ {
destroyEGLContext(); destroyEGLContext();
...@@ -315,7 +325,7 @@ bool ANGLETest::createEGLContext() ...@@ -315,7 +325,7 @@ bool ANGLETest::createEGLContext()
eglGetConfigAttrib(mDisplay, mConfig, EGL_SAMPLE_BUFFERS, &samples); eglGetConfigAttrib(mDisplay, mConfig, EGL_SAMPLE_BUFFERS, &samples);
mMultisample = (samples != 0); mMultisample = (samples != 0);
mSurface = eglCreateWindowSurface(mDisplay, mConfig, mNativeWindow, NULL); mSurface = eglCreateWindowSurface(mDisplay, mConfig, mOSWindow->getNativeWindow(), NULL);
if(mSurface == EGL_NO_SURFACE) if(mSurface == EGL_NO_SURFACE)
{ {
eglGetError(); // Clear error eglGetError(); // Clear error
...@@ -375,6 +385,36 @@ bool ANGLETest::destroyEGLContext() ...@@ -375,6 +385,36 @@ bool ANGLETest::destroyEGLContext()
return true; return true;
} }
bool ANGLETest::InitTestWindow()
{
mOSWindow = CreateOSWindow();
if (!mOSWindow->initialize("ANGLE_TEST", 128, 128))
{
return false;
}
mOSWindow->setVisible(true);
return true;
}
bool ANGLETest::DestroyTestWindow()
{
if (mOSWindow)
{
mOSWindow->destroy();
delete mOSWindow;
mOSWindow = NULL;
}
return true;
}
bool ANGLETest::ResizeWindow(int width, int height)
{
return mOSWindow->resize(width, height);
}
void ANGLETestEnvironment::SetUp() void ANGLETestEnvironment::SetUp()
{ {
if (!ANGLETest::InitTestWindow()) if (!ANGLETest::InitTestWindow())
......
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
#define SHADER_SOURCE(...) #__VA_ARGS__ #define SHADER_SOURCE(...) #__VA_ARGS__
class OSWindow;
class ANGLETest : public testing::Test class ANGLETest : public testing::Test
{ {
protected: protected:
...@@ -100,8 +102,7 @@ class ANGLETest : public testing::Test ...@@ -100,8 +102,7 @@ class ANGLETest : public testing::Test
EGLContext mContext; EGLContext mContext;
EGLDisplay mDisplay; EGLDisplay mDisplay;
static EGLNativeWindowType mNativeWindow; static OSWindow *mOSWindow;
static EGLNativeDisplayType mNativeDisplay;
}; };
class ANGLETestEnvironment : public testing::Environment class ANGLETestEnvironment : public testing::Environment
......
#include "ANGLETest.h"
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_CLOSE:
PostQuitMessage(0);
return 1;
default:
break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
static const PTCHAR GetTestWindowName()
{
return TEXT("ANGLE_TEST");
}
bool ANGLETest::InitTestWindow()
{
WNDCLASS sWC;
sWC.style = CS_OWNDC;
sWC.lpfnWndProc = WndProc;
sWC.cbClsExtra = 0;
sWC.cbWndExtra = 0;
sWC.hInstance = NULL;
sWC.hIcon = NULL;
sWC.hCursor = LoadCursor(NULL, IDC_ARROW);
sWC.lpszMenuName = NULL;
sWC.hbrBackground = NULL;
sWC.lpszClassName = GetTestWindowName();
if (!RegisterClass(&sWC))
{
return false;
}
mNativeWindow = CreateWindow(GetTestWindowName(), NULL, WS_BORDER, 128, 128, 128, 128, NULL, NULL, NULL, NULL);
SetWindowLong(mNativeWindow, GWL_STYLE, 0);
ShowWindow(mNativeWindow, SW_SHOW);
mNativeDisplay = GetDC(mNativeWindow);
if (!mNativeDisplay)
{
DestroyTestWindow();
return false;
}
return true;
}
bool ANGLETest::DestroyTestWindow()
{
if (mNativeDisplay)
{
ReleaseDC(mNativeWindow, mNativeDisplay);
mNativeDisplay = 0;
}
if (mNativeWindow)
{
DestroyWindow(mNativeWindow);
mNativeWindow = 0;
}
UnregisterClass(GetTestWindowName(), NULL);
return true;
}
bool ANGLETest::ResizeWindow(int width, int height)
{
RECT windowRect;
if (!GetWindowRect(mNativeWindow, &windowRect))
{
return false;
}
if (!MoveWindow(mNativeWindow, windowRect.left, windowRect.top, width, height, FALSE))
{
return false;
}
return true;
}
...@@ -157,6 +157,7 @@ ...@@ -157,6 +157,7 @@
'../src/angle.gyp:libGLESv2', '../src/angle.gyp:libGLESv2',
'../src/angle.gyp:libEGL', '../src/angle.gyp:libEGL',
'gtest', 'gtest',
'../util/util.gyp:angle_util',
], ],
'include_dirs': 'include_dirs':
[ [
......
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