Make OSWindow a non-static member of ANGLETest.

BUG=angle:611

Change-Id: I455e1dd0ad5582191621e316c4808a2d753e9aaa
Reviewed-on: https://chromium-review.googlesource.com/219867
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Jamie Madill 2014-10-01 10:41:40 -04:00
Родитель 91f2911f70
Коммит 4119ed3da1
10 изменённых файлов: 38 добавлений и 77 удалений

Просмотреть файл

@ -85,6 +85,8 @@ int SampleApplication::run()
return -1;
}
mOSWindow->setVisible(true);
if (!mEGLWindow->initializeGL(mOSWindow.get()))
{
return -1;

Просмотреть файл

@ -2,31 +2,25 @@
#include "EGLWindow.h"
#include "OSWindow.h"
OSWindow *ANGLETest::mOSWindow = NULL;
ANGLETest::ANGLETest(EGLint glesMajorVersion, EGLint requestedRenderer)
: mEGLWindow(NULL),
mRequestedRenderer(requestedRenderer)
mOSWindow(NULL)
{
mEGLWindow = new EGLWindow(1280, 720, glesMajorVersion, requestedRenderer);
}
void ANGLETest::SetUp()
{
// As per the spec for ANGLE_platform_angle, the value of EGL_PLATFORM_ANGLE_TYPE_ANGLE is ignored if an EGLDisplay
// was previously created for any value of EGLNativeDisplayType.
// As a result, if we wish to request a different display type then we need to recreate the OS Window.
if (mOSWindow->getRequestedRenderer() != EGL_NONE && mOSWindow->getRequestedRenderer() != mRequestedRenderer)
if (!initTestWindow())
{
ANGLETest::DestroyTestWindow();
if (!ANGLETest::InitTestWindow())
{
FAIL() << "Failed to create ANGLE test window.";
}
FAIL() << "Failed to create ANGLE test window.";
}
if (!resizeWindow(mEGLWindow->getWidth(), mEGLWindow->getHeight()))
{
FAIL() << "Failed to resize ANGLE test window.";
}
ResizeWindow(mEGLWindow->getWidth(), mEGLWindow->getHeight());
if (!createEGLContext())
{
FAIL() << "egl context creation failed.";
@ -52,6 +46,11 @@ void ANGLETest::TearDown()
exit(0);
}
}
if (!destroyTestWindow())
{
FAIL() << "ANGLE test window destruction failed.";
}
}
void ANGLETest::swapBuffers()
@ -197,7 +196,7 @@ bool ANGLETest::destroyEGLContext()
return true;
}
bool ANGLETest::InitTestWindow()
bool ANGLETest::initTestWindow()
{
mOSWindow = CreateOSWindow();
if (!mOSWindow->initialize("ANGLE_TEST", 128, 128))
@ -205,12 +204,12 @@ bool ANGLETest::InitTestWindow()
return false;
}
mOSWindow->setVisible(true);
mOSWindow->setVisible(false);
return true;
}
bool ANGLETest::DestroyTestWindow()
bool ANGLETest::destroyTestWindow()
{
if (mOSWindow)
{
@ -222,20 +221,12 @@ bool ANGLETest::DestroyTestWindow()
return true;
}
bool ANGLETest::ResizeWindow(int width, int height)
bool ANGLETest::resizeWindow(int width, int height)
{
return mOSWindow->resize(width, height);
}
void ANGLETestEnvironment::SetUp()
void ANGLETest::setWindowVisible(bool isVisible)
{
if (!ANGLETest::InitTestWindow())
{
FAIL() << "Failed to create ANGLE test window.";
}
}
void ANGLETestEnvironment::TearDown()
{
ANGLETest::DestroyTestWindow();
mOSWindow->setVisible(isVisible);
}

Просмотреть файл

@ -45,9 +45,8 @@ class ANGLETest : public testing::Test
ANGLETest(EGLint requestedRenderer, EGLint glesMajorVersion);
public:
static bool InitTestWindow();
static bool DestroyTestWindow();
static bool ResizeWindow(int width, int height);
bool resizeWindow(int width, int height);
void setWindowVisible(bool isVisible);
protected:
virtual void SetUp();
@ -75,21 +74,13 @@ class ANGLETest : public testing::Test
bool isMultisampleEnabled() const;
private:
bool initTestWindow();
bool destroyTestWindow();
bool createEGLContext();
bool destroyEGLContext();
EGLWindow *mEGLWindow;
EGLint mRequestedRenderer;
static OSWindow *mOSWindow;
};
class ANGLETestEnvironment : public testing::Environment
{
public:
virtual void SetUp();
virtual void TearDown();
OSWindow *mOSWindow;
};
#endif // ANGLE_TESTS_ANGLE_TEST_H_

Просмотреть файл

@ -23,6 +23,9 @@ class DrawBuffersTest : public ANGLETest
{
ANGLETest::SetUp();
// This test seems to fail on an nVidia machine when the window is hidden
setWindowVisible(true);
glGenFramebuffers(1, &mFBO);
glBindFramebuffer(GL_FRAMEBUFFER, mFBO);
@ -284,4 +287,4 @@ TYPED_TEST(DrawBuffersTest, FirstHalfNULL)
EXPECT_GL_NO_ERROR();
glDeleteProgram(program);
}
}

Просмотреть файл

@ -10,7 +10,6 @@
int main(int argc, char** argv)
{
testing::InitGoogleTest(&argc, argv);
testing::AddGlobalTestEnvironment(new ANGLETestEnvironment());
int rt = RUN_ALL_TESTS();
return rt;
}

Просмотреть файл

@ -87,15 +87,6 @@ bool EGLWindow::initializeGL(OSWindow *osWindow)
return false;
}
if (osWindow->getRequestedRenderer() != EGL_NONE && osWindow->getRequestedRenderer() != mRequestedRenderer)
{
// The OS window should be recreated in this case, to ensure the requested renderer is created.
destroyGL();
return false;
}
osWindow->setRequestedRenderer(mRequestedRenderer);
EGLint majorVersion, minorVersion;
if (!eglInitialize(mDisplay, &majorVersion, &minorVersion))
{

Просмотреть файл

@ -8,8 +8,7 @@
OSWindow::OSWindow()
: mWidth(0),
mHeight(0),
mRequestedRenderer(EGL_NONE)
mHeight(0)
{
}
@ -52,13 +51,3 @@ void OSWindow::pushEvent(Event event)
mEvents.push_back(event);
}
void OSWindow::setRequestedRenderer(EGLint requestedDisplayType)
{
mRequestedRenderer = requestedDisplayType;
}
EGLint OSWindow::getRequestedRenderer() const
{
return mRequestedRenderer;
}

Просмотреть файл

@ -28,9 +28,6 @@ class OSWindow
virtual EGLNativeWindowType getNativeWindow() const = 0;
virtual EGLNativeDisplayType getNativeDisplay() const = 0;
void setRequestedRenderer(EGLint requestedDisplayType);
EGLint getRequestedRenderer() const ;
virtual void messageLoop() = 0;
bool popEvent(Event *event);
@ -38,14 +35,12 @@ class OSWindow
virtual void setMousePosition(int x, int y) = 0;
virtual bool resize(int width, int height) = 0;
virtual bool setVisible(bool isVisible) = 0;
virtual void setVisible(bool isVisible) = 0;
protected:
int mWidth;
int mHeight;
EGLint mRequestedRenderer;
std::list<Event> mEvents;
};

Просмотреть файл

@ -417,7 +417,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
return false;
}
DWORD parentStyle = WS_VISIBLE | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
DWORD parentStyle = WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU;
DWORD parentExtendedStyle = WS_EX_APPWINDOW;
RECT sizeRect = { 0, 0, width, height };
@ -427,7 +427,7 @@ bool Win32Window::initialize(const std::string &name, size_t width, size_t heigh
sizeRect.right - sizeRect.left, sizeRect.bottom - sizeRect.top, NULL, NULL,
GetModuleHandle(NULL), this);
mNativeWindow = CreateWindowExA(0, mChildClassName.c_str(), name.c_str(), WS_VISIBLE | WS_CHILD, 0, 0, width, height,
mNativeWindow = CreateWindowExA(0, mChildClassName.c_str(), name.c_str(), WS_CHILD, 0, 0, width, height,
mParentWindow, NULL, GetModuleHandle(NULL), this);
mNativeDisplay = GetDC(mNativeWindow);
@ -536,12 +536,12 @@ bool Win32Window::resize(int width, int height)
return true;
}
bool Win32Window::setVisible(bool isVisible)
void Win32Window::setVisible(bool isVisible)
{
int flag = (isVisible ? SW_SHOW : SW_HIDE);
return (ShowWindow(mNativeWindow, flag) == TRUE) &&
(ShowWindow(mParentWindow, flag) == TRUE);
ShowWindow(mParentWindow, flag);
ShowWindow(mNativeWindow, flag);
}
void Win32Window::pushEvent(Event event)

Просмотреть файл

@ -29,7 +29,7 @@ class Win32Window : public OSWindow
void setMousePosition(int x, int y);
bool resize(int width, int height);
bool setVisible(bool isVisible);
void setVisible(bool isVisible);
private:
std::string mParentClassName;