Commit ad398ee8 by Jamie Madill Committed by Commit Bot

Free OSWindow and EGLWindow through helpers.

This cleans up any potential problems with allocating and freeing resources in different shared objects or DLLs. Previously we were using a dynamically linked allocation function and then calling the standard delete function. Also adds a base class helper for EGLWindow. Will base the WGL Window class on this. Needed for running ANGLE tests against native drivers. Bug: angleproject:2995 Change-Id: Ic92b447649ebb32c547605c20086c07a601842f0 Reviewed-on: https://chromium-review.googlesource.com/c/1393443 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 9fa54eab
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
OSWindow *window = CreateOSWindow(); OSWindow *window = OSWindow::New();
int width = 400; int width = 400;
int height = 400; int height = 400;
int x = 0; int x = 0;
......
...@@ -58,7 +58,7 @@ void main() ...@@ -58,7 +58,7 @@ void main()
{ {
window window; window window;
window.osWindow = CreateOSWindow(); window.osWindow = OSWindow::New();
if (!window.osWindow->initialize("MultiWindow", 256, 256)) if (!window.osWindow->initialize("MultiWindow", 256, 256))
{ {
return false; return false;
......
...@@ -49,7 +49,12 @@ SampleApplication::SampleApplication(std::string name, ...@@ -49,7 +49,12 @@ SampleApplication::SampleApplication(std::string name,
EGLint glesMinorVersion, EGLint glesMinorVersion,
size_t width, size_t width,
size_t height) size_t height)
: mName(std::move(name)), mWidth(width), mHeight(height), mRunning(false) : mName(std::move(name)),
mWidth(width),
mHeight(height),
mRunning(false),
mEGLWindow(nullptr),
mOSWindow(nullptr)
{ {
EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE; EGLint requestedRenderer = EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
...@@ -61,10 +66,10 @@ SampleApplication::SampleApplication(std::string name, ...@@ -61,10 +66,10 @@ SampleApplication::SampleApplication(std::string name,
// Load EGL library so we can initialize the display. // Load EGL library so we can initialize the display.
mEntryPointsLib.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME)); mEntryPointsLib.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME));
mEGLWindow.reset(new EGLWindow(glesMajorVersion, glesMinorVersion, mEGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion,
EGLPlatformParameters(requestedRenderer))); EGLPlatformParameters(requestedRenderer));
mTimer.reset(CreateTimer()); mTimer.reset(CreateTimer());
mOSWindow.reset(CreateOSWindow()); mOSWindow = OSWindow::New();
mEGLWindow->setConfigRedBits(8); mEGLWindow->setConfigRedBits(8);
mEGLWindow->setConfigGreenBits(8); mEGLWindow->setConfigGreenBits(8);
...@@ -77,7 +82,11 @@ SampleApplication::SampleApplication(std::string name, ...@@ -77,7 +82,11 @@ SampleApplication::SampleApplication(std::string name,
mEGLWindow->setSwapInterval(0); mEGLWindow->setSwapInterval(0);
} }
SampleApplication::~SampleApplication() {} SampleApplication::~SampleApplication()
{
EGLWindow::Delete(&mEGLWindow);
OSWindow::Delete(&mOSWindow);
}
bool SampleApplication::initialize() bool SampleApplication::initialize()
{ {
...@@ -97,7 +106,7 @@ void SampleApplication::swap() ...@@ -97,7 +106,7 @@ void SampleApplication::swap()
OSWindow *SampleApplication::getWindow() const OSWindow *SampleApplication::getWindow() const
{ {
return mOSWindow.get(); return mOSWindow;
} }
EGLConfig SampleApplication::getConfig() const EGLConfig SampleApplication::getConfig() const
...@@ -129,7 +138,7 @@ int SampleApplication::run() ...@@ -129,7 +138,7 @@ int SampleApplication::run()
mOSWindow->setVisible(true); mOSWindow->setVisible(true);
if (!mEGLWindow->initializeGL(mOSWindow.get(), mEntryPointsLib.get())) if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get()))
{ {
return -1; return -1;
} }
......
...@@ -61,8 +61,8 @@ class SampleApplication ...@@ -61,8 +61,8 @@ class SampleApplication
bool mRunning; bool mRunning;
std::unique_ptr<Timer> mTimer; std::unique_ptr<Timer> mTimer;
std::unique_ptr<EGLWindow> mEGLWindow; EGLWindow *mEGLWindow;
std::unique_ptr<OSWindow> mOSWindow; OSWindow *mOSWindow;
// Handle to the entry point binding library. // Handle to the entry point binding library.
std::unique_ptr<angle::Library> mEntryPointsLib; std::unique_ptr<angle::Library> mEntryPointsLib;
......
...@@ -272,7 +272,7 @@ eglu::NativeWindow *NativeWindowFactory::createWindow(eglu::NativeDisplay *nativ ...@@ -272,7 +272,7 @@ eglu::NativeWindow *NativeWindowFactory::createWindow(eglu::NativeDisplay *nativ
NativeWindow::NativeWindow(ANGLENativeDisplay *nativeDisplay, NativeWindow::NativeWindow(ANGLENativeDisplay *nativeDisplay,
const eglu::WindowParams &params, const eglu::WindowParams &params,
EventState *eventState) EventState *eventState)
: eglu::NativeWindow(kWindowCapabilities), mWindow(CreateOSWindow()), mEvents(eventState) : eglu::NativeWindow(kWindowCapabilities), mWindow(OSWindow::New()), mEvents(eventState)
{ {
bool initialized = mWindow->initialize( bool initialized = mWindow->initialize(
"dEQP ANGLE Tests", "dEQP ANGLE Tests",
...@@ -305,7 +305,7 @@ void NativeWindow::setVisibility(eglu::WindowParams::Visibility visibility) ...@@ -305,7 +305,7 @@ void NativeWindow::setVisibility(eglu::WindowParams::Visibility visibility)
NativeWindow::~NativeWindow() NativeWindow::~NativeWindow()
{ {
delete mWindow; OSWindow::Delete(&mWindow);
} }
eglw::EGLNativeWindowType NativeWindow::getLegacyNative() eglw::EGLNativeWindowType NativeWindow::getLegacyNative()
......
...@@ -116,7 +116,7 @@ class EGLContextCompatibilityTest : public EGLTest, ...@@ -116,7 +116,7 @@ class EGLContextCompatibilityTest : public EGLTest,
EGLConfig contextConfig, EGLConfig contextConfig,
bool compatible) const bool compatible) const
{ {
OSWindow *osWindow = CreateOSWindow(); OSWindow *osWindow = OSWindow::New();
ASSERT_TRUE(osWindow != nullptr); ASSERT_TRUE(osWindow != nullptr);
osWindow->initialize("EGLContextCompatibilityTest", 500, 500); osWindow->initialize("EGLContextCompatibilityTest", 500, 500);
osWindow->setVisible(true); osWindow->setVisible(true);
...@@ -144,7 +144,7 @@ class EGLContextCompatibilityTest : public EGLTest, ...@@ -144,7 +144,7 @@ class EGLContextCompatibilityTest : public EGLTest,
eglDestroyContext(mDisplay, context); eglDestroyContext(mDisplay, context);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
SafeDelete(osWindow); OSWindow::Delete(&osWindow);
} }
void testPbufferCompatibility(EGLConfig pbufferConfig, void testPbufferCompatibility(EGLConfig pbufferConfig,
......
...@@ -76,7 +76,7 @@ class EGLDeviceCreationTest : public EGLTest ...@@ -76,7 +76,7 @@ class EGLDeviceCreationTest : public EGLTest
SafeRelease(mDevice); SafeRelease(mDevice);
SafeRelease(mDeviceContext); SafeRelease(mDeviceContext);
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
if (mSurface != EGL_NO_SURFACE) if (mSurface != EGL_NO_SURFACE)
{ {
...@@ -138,7 +138,7 @@ class EGLDeviceCreationTest : public EGLTest ...@@ -138,7 +138,7 @@ class EGLDeviceCreationTest : public EGLTest
ASSERT_EGL_TRUE(eglChooseConfig(mDisplay, configAttributes, &mConfig, 1, &configCount)); ASSERT_EGL_TRUE(eglChooseConfig(mDisplay, configAttributes, &mConfig, 1, &configCount));
// Create an OS Window // Create an OS Window
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
mOSWindow->initialize("EGLSurfaceTest", 64, 64); mOSWindow->initialize("EGLSurfaceTest", 64, 64);
// Create window surface // Create window surface
......
...@@ -47,7 +47,7 @@ class EGLDirectCompositionTest : public ANGLETest ...@@ -47,7 +47,7 @@ class EGLDirectCompositionTest : public ANGLETest
} }
// Create an OS Window // Create an OS Window
mOSWindow = std::unique_ptr<OSWindow>(CreateOSWindow()); mOSWindow = OSWindow::New();
mOSWindow->initialize("EGLDirectCompositionTest", WINDOWWIDTH, WINDOWHEIGHT); mOSWindow->initialize("EGLDirectCompositionTest", WINDOWWIDTH, WINDOWHEIGHT);
auto nativeWindow = mOSWindow->getNativeWindow(); auto nativeWindow = mOSWindow->getNativeWindow();
...@@ -198,9 +198,11 @@ class EGLDirectCompositionTest : public ANGLETest ...@@ -198,9 +198,11 @@ class EGLDirectCompositionTest : public ANGLETest
return; return;
} }
ASSERT_EGL_TRUE(eglTerminate(mEglDisplay)); ASSERT_EGL_TRUE(eglTerminate(mEglDisplay));
OSWindow::Delete(&mOSWindow);
} }
std::unique_ptr<OSWindow> mOSWindow; OSWindow *mOSWindow;
ComPtr<ICompositor> mCompositor; ComPtr<ICompositor> mCompositor;
ComPtr<IDispatcherQueueController> mDispatcherController; ComPtr<IDispatcherQueueController> mDispatcherController;
ComPtr<ICompositionColorBrush> mColorBrush; ComPtr<ICompositionColorBrush> mColorBrush;
......
...@@ -31,7 +31,7 @@ class EGLPresentPathD3D11 : public EGLTest, public testing::WithParamInterface<P ...@@ -31,7 +31,7 @@ class EGLPresentPathD3D11 : public EGLTest, public testing::WithParamInterface<P
{ {
EGLTest::SetUp(); EGLTest::SetUp();
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
mWindowWidth = 64; mWindowWidth = 64;
mOSWindow->initialize("EGLPresentPathD3D11", mWindowWidth, mWindowWidth); mOSWindow->initialize("EGLPresentPathD3D11", mWindowWidth, mWindowWidth);
} }
...@@ -169,7 +169,7 @@ class EGLPresentPathD3D11 : public EGLTest, public testing::WithParamInterface<P ...@@ -169,7 +169,7 @@ class EGLPresentPathD3D11 : public EGLTest, public testing::WithParamInterface<P
} }
mOSWindow->destroy(); mOSWindow->destroy();
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
} }
void drawQuadUsingGL() void drawQuadUsingGL()
......
...@@ -21,7 +21,7 @@ class EGLRobustnessTest : public EGLTest, ...@@ -21,7 +21,7 @@ class EGLRobustnessTest : public EGLTest,
{ {
EGLTest::SetUp(); EGLTest::SetUp();
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
mOSWindow->initialize("EGLRobustnessTest", 500, 500); mOSWindow->initialize("EGLRobustnessTest", 500, 500);
mOSWindow->setVisible(true); mOSWindow->setVisible(true);
...@@ -80,7 +80,7 @@ class EGLRobustnessTest : public EGLTest, ...@@ -80,7 +80,7 @@ class EGLRobustnessTest : public EGLTest,
eglTerminate(mDisplay); eglTerminate(mDisplay);
EXPECT_EGL_SUCCESS(); EXPECT_EGL_SUCCESS();
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
} }
void createContext(EGLint resetStrategy) void createContext(EGLint resetStrategy)
......
...@@ -42,7 +42,7 @@ class EGLSurfaceTest : public EGLTest ...@@ -42,7 +42,7 @@ class EGLSurfaceTest : public EGLTest
{ {
EGLTest::SetUp(); EGLTest::SetUp();
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
mOSWindow->initialize("EGLSurfaceTest", 64, 64); mOSWindow->initialize("EGLSurfaceTest", 64, 64);
} }
...@@ -82,7 +82,7 @@ class EGLSurfaceTest : public EGLTest ...@@ -82,7 +82,7 @@ class EGLSurfaceTest : public EGLTest
} }
mOSWindow->destroy(); mOSWindow->destroy();
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
ASSERT_TRUE(mWindowSurface == EGL_NO_SURFACE && mContext == EGL_NO_CONTEXT); ASSERT_TRUE(mWindowSurface == EGL_NO_SURFACE && mContext == EGL_NO_CONTEXT);
} }
......
...@@ -64,7 +64,7 @@ class EGLSyncControlTest : public testing::Test ...@@ -64,7 +64,7 @@ class EGLSyncControlTest : public testing::Test
SafeRelease(mDevice); SafeRelease(mDevice);
SafeRelease(mDeviceContext); SafeRelease(mDeviceContext);
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
if (mSurface != EGL_NO_SURFACE) if (mSurface != EGL_NO_SURFACE)
{ {
...@@ -110,7 +110,7 @@ class EGLSyncControlTest : public testing::Test ...@@ -110,7 +110,7 @@ class EGLSyncControlTest : public testing::Test
EGL_NONE}; EGL_NONE};
// Create an OS Window // Create an OS Window
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
mOSWindow->initialize("EGLSyncControlTest", 64, 64); mOSWindow->initialize("EGLSyncControlTest", 64, 64);
mOSWindow->setVisible(true); mOSWindow->setVisible(true);
......
...@@ -95,7 +95,7 @@ TEST_P(EGLX11VisualHintTest, ValidVisualIDAndClear) ...@@ -95,7 +95,7 @@ TEST_P(EGLX11VisualHintTest, ValidVisualIDAndClear)
{ {
// We'll test the extension with one visual ID but we don't care which one. This means we // We'll test the extension with one visual ID but we don't care which one. This means we
// can use OSWindow to create a window and just grab its visual. // can use OSWindow to create a window and just grab its visual.
OSWindow *osWindow = CreateOSWindow(); OSWindow *osWindow = OSWindow::New();
osWindow->initialize("EGLX11VisualHintTest", 500, 500); osWindow->initialize("EGLX11VisualHintTest", 500, 500);
osWindow->setVisible(true); osWindow->setVisible(true);
...@@ -151,7 +151,7 @@ TEST_P(EGLX11VisualHintTest, ValidVisualIDAndClear) ...@@ -151,7 +151,7 @@ TEST_P(EGLX11VisualHintTest, ValidVisualIDAndClear)
eglDestroyContext(display, context); eglDestroyContext(display, context);
ASSERT_EGL_SUCCESS(); ASSERT_EGL_SUCCESS();
SafeDelete(osWindow); OSWindow::Delete(&osWindow);
eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(display); eglTerminate(display);
...@@ -165,7 +165,7 @@ TEST_P(EGLX11VisualHintTest, InvalidWindowVisualID) ...@@ -165,7 +165,7 @@ TEST_P(EGLX11VisualHintTest, InvalidWindowVisualID)
// creation will succeed. // creation will succeed.
int visualId; int visualId;
{ {
OSWindow *osWindow = CreateOSWindow(); OSWindow *osWindow = OSWindow::New();
osWindow->initialize("EGLX11VisualHintTest", 500, 500); osWindow->initialize("EGLX11VisualHintTest", 500, 500);
osWindow->setVisible(true); osWindow->setVisible(true);
...@@ -175,7 +175,7 @@ TEST_P(EGLX11VisualHintTest, InvalidWindowVisualID) ...@@ -175,7 +175,7 @@ TEST_P(EGLX11VisualHintTest, InvalidWindowVisualID)
ASSERT_NE(0, XGetWindowAttributes(mDisplay, xWindow, &windowAttributes)); ASSERT_NE(0, XGetWindowAttributes(mDisplay, xWindow, &windowAttributes));
visualId = windowAttributes.visual->visualid; visualId = windowAttributes.visual->visualid;
SafeDelete(osWindow); OSWindow::Delete(&osWindow);
} }
auto attributes = getDisplayAttributes(visualId); auto attributes = getDisplayAttributes(visualId);
...@@ -205,7 +205,7 @@ TEST_P(EGLX11VisualHintTest, InvalidWindowVisualID) ...@@ -205,7 +205,7 @@ TEST_P(EGLX11VisualHintTest, InvalidWindowVisualID)
ASSERT_EQ(EGL_NO_SURFACE, window); ASSERT_EQ(EGL_NO_SURFACE, window);
ASSERT_EGL_ERROR(EGL_BAD_MATCH); ASSERT_EGL_ERROR(EGL_BAD_MATCH);
SafeDelete(osWindow); OSWindow::Delete(&osWindow);
} }
ANGLE_INSTANTIATE_TEST(EGLX11VisualHintTest, ES2_OPENGL()); ANGLE_INSTANTIATE_TEST(EGLX11VisualHintTest, ES2_OPENGL());
...@@ -632,7 +632,7 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi ...@@ -632,7 +632,7 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi
public: public:
void SetUp() override void SetUp() override
{ {
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
bool result = mOSWindow->initialize("ProgramBinariesAcrossRenderersTests", 100, 100); bool result = mOSWindow->initialize("ProgramBinariesAcrossRenderersTests", 100, 100);
if (result == false) if (result == false)
...@@ -646,12 +646,11 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi ...@@ -646,12 +646,11 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi
EGLWindow *createAndInitEGLWindow(angle::PlatformParameters &param) EGLWindow *createAndInitEGLWindow(angle::PlatformParameters &param)
{ {
EGLWindow *eglWindow = EGLWindow *eglWindow =
new EGLWindow(param.majorVersion, param.minorVersion, param.eglParameters); EGLWindow::New(param.majorVersion, param.minorVersion, param.eglParameters);
bool result = eglWindow->initializeGL(mOSWindow, mEntryPointsLib.get()); bool result = eglWindow->initializeGL(mOSWindow, mEntryPointsLib.get());
if (result == false) if (result == false)
{ {
SafeDelete(eglWindow); EGLWindow::Delete(&eglWindow);
eglWindow = nullptr;
} }
angle::LoadGLES(eglGetProcAddress); angle::LoadGLES(eglGetProcAddress);
...@@ -663,8 +662,7 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi ...@@ -663,8 +662,7 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi
{ {
ASSERT_NE(nullptr, *eglWindow); ASSERT_NE(nullptr, *eglWindow);
(*eglWindow)->destroyGL(); (*eglWindow)->destroyGL();
SafeDelete(*eglWindow); EGLWindow::Delete(eglWindow);
*eglWindow = nullptr;
} }
GLuint createES2ProgramFromSource() GLuint createES2ProgramFromSource()
...@@ -706,7 +704,7 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi ...@@ -706,7 +704,7 @@ class ProgramBinariesAcrossPlatforms : public testing::TestWithParam<PlatformsWi
void TearDown() override void TearDown() override
{ {
mOSWindow->destroy(); mOSWindow->destroy();
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
} }
OSWindow *mOSWindow = nullptr; OSWindow *mOSWindow = nullptr;
......
...@@ -311,7 +311,7 @@ std::string RenderTestParams::suffix() const ...@@ -311,7 +311,7 @@ std::string RenderTestParams::suffix() const
ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams) ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams &testParams)
: ANGLEPerfTest(name, testParams.suffix(), OneFrame() ? 1 : testParams.iterationsPerStep), : ANGLEPerfTest(name, testParams.suffix(), OneFrame() ? 1 : testParams.iterationsPerStep),
mTestParams(testParams), mTestParams(testParams),
mEGLWindow(createEGLWindow(testParams)), mGLWindow(nullptr),
mOSWindow(nullptr) mOSWindow(nullptr)
{ {
// Force fast tests to make sure our slowest bots don't time out. // Force fast tests to make sure our slowest bots don't time out.
...@@ -322,12 +322,14 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams ...@@ -322,12 +322,14 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name, const RenderTestParams
// Try to ensure we don't trigger allocation during execution. // Try to ensure we don't trigger allocation during execution.
mTraceEventBuffer.reserve(kInitialTraceEventBufferSize); mTraceEventBuffer.reserve(kInitialTraceEventBufferSize);
mGLWindow = createEGLWindow(testParams);
} }
ANGLERenderTest::~ANGLERenderTest() ANGLERenderTest::~ANGLERenderTest()
{ {
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
SafeDelete(mEGLWindow); GLWindowBase::Delete(&mGLWindow);
} }
void ANGLERenderTest::addExtensionPrerequisite(const char *extensionName) void ANGLERenderTest::addExtensionPrerequisite(const char *extensionName)
...@@ -342,15 +344,15 @@ void ANGLERenderTest::SetUp() ...@@ -342,15 +344,15 @@ void ANGLERenderTest::SetUp()
// Set a consistent CPU core affinity and high priority. // Set a consistent CPU core affinity and high priority.
angle::StabilizeCPUForBenchmarking(); angle::StabilizeCPUForBenchmarking();
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
if (!mEGLWindow) if (!mGLWindow)
{ {
abortTest(); mSkipTest = true;
return; return;
} }
mEGLWindow->setSwapInterval(0); mGLWindow->setSwapInterval(0);
mPlatformMethods.overrideWorkaroundsD3D = OverrideWorkaroundsD3D; mPlatformMethods.overrideWorkaroundsD3D = OverrideWorkaroundsD3D;
mPlatformMethods.logError = EmptyPlatformMethod; mPlatformMethods.logError = EmptyPlatformMethod;
...@@ -361,7 +363,7 @@ void ANGLERenderTest::SetUp() ...@@ -361,7 +363,7 @@ void ANGLERenderTest::SetUp()
mPlatformMethods.updateTraceEventDuration = UpdateTraceEventDuration; mPlatformMethods.updateTraceEventDuration = UpdateTraceEventDuration;
mPlatformMethods.monotonicallyIncreasingTime = MonotonicallyIncreasingTime; mPlatformMethods.monotonicallyIncreasingTime = MonotonicallyIncreasingTime;
mPlatformMethods.context = this; mPlatformMethods.context = this;
mEGLWindow->setPlatformMethods(&mPlatformMethods); mGLWindow->setPlatformMethods(&mPlatformMethods);
if (!mOSWindow->initialize(mName, mTestParams.windowWidth, mTestParams.windowHeight)) if (!mOSWindow->initialize(mName, mTestParams.windowWidth, mTestParams.windowHeight))
{ {
...@@ -374,9 +376,9 @@ void ANGLERenderTest::SetUp() ...@@ -374,9 +376,9 @@ void ANGLERenderTest::SetUp()
mEntryPointsLib.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME)); mEntryPointsLib.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME));
#endif // defined(ANGLE_USE_UTIL_LOADER) #endif // defined(ANGLE_USE_UTIL_LOADER)
if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get())) if (!mGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get()))
{ {
FAIL() << "Failed initializing EGLWindow"; FAIL() << "Failed initializing GL Window";
return; return;
} }
...@@ -406,10 +408,22 @@ void ANGLERenderTest::SetUp() ...@@ -406,10 +408,22 @@ void ANGLERenderTest::SetUp()
void ANGLERenderTest::TearDown() void ANGLERenderTest::TearDown()
{ {
destroyBenchmark(); if (!mSkipTest)
{
destroyBenchmark();
}
mEGLWindow->destroyGL(); if (mGLWindow)
mOSWindow->destroy(); {
mGLWindow->destroyGL();
mGLWindow = nullptr;
}
if (mOSWindow)
{
mOSWindow->destroy();
mOSWindow = nullptr;
}
// Dump trace events to json file. // Dump trace events to json file.
if (gEnableTrace) if (gEnableTrace)
...@@ -446,7 +460,7 @@ void ANGLERenderTest::step() ...@@ -446,7 +460,7 @@ void ANGLERenderTest::step()
// to swap. // to swap.
if (mTestParams.eglParameters.deviceType != EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE) if (mTestParams.eglParameters.deviceType != EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE)
{ {
mEGLWindow->swap(); mGLWindow->swap();
} }
mOSWindow->messageLoop(); mOSWindow->messageLoop();
} }
...@@ -486,12 +500,12 @@ bool ANGLERenderTest::areExtensionPrerequisitesFulfilled() const ...@@ -486,12 +500,12 @@ bool ANGLERenderTest::areExtensionPrerequisitesFulfilled() const
void ANGLERenderTest::setWebGLCompatibilityEnabled(bool webglCompatibility) void ANGLERenderTest::setWebGLCompatibilityEnabled(bool webglCompatibility)
{ {
mEGLWindow->setWebGLCompatibilityEnabled(webglCompatibility); mGLWindow->setWebGLCompatibilityEnabled(webglCompatibility);
} }
void ANGLERenderTest::setRobustResourceInit(bool enabled) void ANGLERenderTest::setRobustResourceInit(bool enabled)
{ {
mEGLWindow->setRobustResourceInit(enabled); mGLWindow->setRobustResourceInit(enabled);
} }
std::vector<TraceEvent> &ANGLERenderTest::getTraceEventBuffer() std::vector<TraceEvent> &ANGLERenderTest::getTraceEventBuffer()
...@@ -502,8 +516,8 @@ std::vector<TraceEvent> &ANGLERenderTest::getTraceEventBuffer() ...@@ -502,8 +516,8 @@ std::vector<TraceEvent> &ANGLERenderTest::getTraceEventBuffer()
// static // static
EGLWindow *ANGLERenderTest::createEGLWindow(const RenderTestParams &testParams) EGLWindow *ANGLERenderTest::createEGLWindow(const RenderTestParams &testParams)
{ {
return new EGLWindow(testParams.majorVersion, testParams.minorVersion, return EGLWindow::New(testParams.majorVersion, testParams.minorVersion,
testParams.eglParameters); testParams.eglParameters);
} }
void ANGLEProcessPerfTestArgs(int *argc, char **argv) void ANGLEProcessPerfTestArgs(int *argc, char **argv)
......
...@@ -151,7 +151,7 @@ class ANGLERenderTest : public ANGLEPerfTest ...@@ -151,7 +151,7 @@ class ANGLERenderTest : public ANGLEPerfTest
static EGLWindow *createEGLWindow(const RenderTestParams &testParams); static EGLWindow *createEGLWindow(const RenderTestParams &testParams);
EGLWindow *mEGLWindow; GLWindowBase *mGLWindow;
OSWindow *mOSWindow; OSWindow *mOSWindow;
std::vector<const char *> mExtensionPrerequisites; std::vector<const char *> mExtensionPrerequisites;
angle::PlatformMethods mPlatformMethods; angle::PlatformMethods mPlatformMethods;
......
...@@ -95,7 +95,7 @@ EGLInitializePerfTest::EGLInitializePerfTest() ...@@ -95,7 +95,7 @@ EGLInitializePerfTest::EGLInitializePerfTest()
} }
displayAttributes.push_back(EGL_NONE); displayAttributes.push_back(EGL_NONE);
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
mOSWindow->initialize("EGLInitialize Test", 64, 64); mOSWindow->initialize("EGLInitialize Test", 64, 64);
auto eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>( auto eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(
...@@ -125,7 +125,7 @@ void EGLInitializePerfTest::SetUp() ...@@ -125,7 +125,7 @@ void EGLInitializePerfTest::SetUp()
EGLInitializePerfTest::~EGLInitializePerfTest() EGLInitializePerfTest::~EGLInitializePerfTest()
{ {
SafeDelete(mOSWindow); OSWindow::Delete(&mOSWindow);
} }
void EGLInitializePerfTest::step() void EGLInitializePerfTest::step()
......
...@@ -59,7 +59,7 @@ EGLMakeCurrentPerfTest::EGLMakeCurrentPerfTest() ...@@ -59,7 +59,7 @@ EGLMakeCurrentPerfTest::EGLMakeCurrentPerfTest()
displayAttributes.push_back(platform.deviceType); displayAttributes.push_back(platform.deviceType);
displayAttributes.push_back(EGL_NONE); displayAttributes.push_back(EGL_NONE);
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
mOSWindow->initialize("EGLMakeCurrent Test", 64, 64); mOSWindow->initialize("EGLMakeCurrent Test", 64, 64);
mEGLLibrary.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME)); mEGLLibrary.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME));
......
...@@ -293,7 +293,7 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params) ...@@ -293,7 +293,7 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params)
m3DTexturedQuadProgram(0), m3DTexturedQuadProgram(0),
mDeferContextInit(false) mDeferContextInit(false)
{ {
mEGLWindow = new EGLWindow(params.majorVersion, params.minorVersion, params.eglParameters); mEGLWindow = EGLWindow::New(params.majorVersion, params.minorVersion, params.eglParameters);
// Default debug layers to enabled in tests. // Default debug layers to enabled in tests.
mEGLWindow->setDebugLayersEnabled(true); mEGLWindow->setDebugLayersEnabled(true);
...@@ -333,7 +333,7 @@ ANGLETestBase::~ANGLETestBase() ...@@ -333,7 +333,7 @@ ANGLETestBase::~ANGLETestBase()
{ {
glDeleteProgram(m3DTexturedQuadProgram); glDeleteProgram(m3DTexturedQuadProgram);
} }
SafeDelete(mEGLWindow); EGLWindow::Delete(&mEGLWindow);
} }
void ANGLETestBase::ANGLETestSetUp() void ANGLETestBase::ANGLETestSetUp()
...@@ -372,10 +372,6 @@ void ANGLETestBase::ANGLETestSetUp() ...@@ -372,10 +372,6 @@ void ANGLETestBase::ANGLETestSetUp()
FAIL() << "GL Context init failed."; FAIL() << "GL Context init failed.";
} }
#if defined(ANGLE_USE_UTIL_LOADER)
angle::LoadGLES(eglGetProcAddress);
#endif // defined(ANGLE_USE_UTIL_LOADER)
if (needSwap) if (needSwap)
{ {
// Swap the buffers so that the default framebuffer picks up the resize // Swap the buffers so that the default framebuffer picks up the resize
...@@ -395,27 +391,22 @@ void ANGLETestBase::ANGLETestSetUp() ...@@ -395,27 +391,22 @@ void ANGLETestBase::ANGLETestSetUp()
void ANGLETestBase::ANGLETestTearDown() void ANGLETestBase::ANGLETestTearDown()
{ {
mEGLWindow->setPlatformMethods(nullptr); if (mEGLWindow)
{
mEGLWindow->setPlatformMethods(nullptr);
checkD3D11SDKLayersMessages();
}
mPlatformContext.currentTest = nullptr; mPlatformContext.currentTest = nullptr;
checkD3D11SDKLayersMessages();
const auto &info = testing::UnitTest::GetInstance()->current_test_info(); const auto &info = testing::UnitTest::GetInstance()->current_test_info();
angle::WriteDebugMessage("Exiting %s.%s\n", info->test_case_name(), info->name()); angle::WriteDebugMessage("Exiting %s.%s\n", info->test_case_name(), info->name());
swapBuffers(); swapBuffers();
if (eglGetError() != EGL_SUCCESS)
{
FAIL() << "egl error during swap.";
}
mOSWindow->messageLoop(); mOSWindow->messageLoop();
if (!destroyEGLContext()) getGLWindow()->destroyGL();
{
FAIL() << "egl context destruction failed.";
}
// Check for quit message // Check for quit message
Event myEvent; Event myEvent;
...@@ -430,9 +421,14 @@ void ANGLETestBase::ANGLETestTearDown() ...@@ -430,9 +421,14 @@ void ANGLETestBase::ANGLETestTearDown()
void ANGLETestBase::swapBuffers() void ANGLETestBase::swapBuffers()
{ {
if (mEGLWindow->isGLInitialized()) if (getGLWindow()->isGLInitialized())
{ {
mEGLWindow->swap(); getGLWindow()->swap();
if (mEGLWindow)
{
EXPECT_EGL_SUCCESS();
}
} }
} }
...@@ -904,34 +900,39 @@ void ANGLETestBase::setWindowHeight(int height) ...@@ -904,34 +900,39 @@ void ANGLETestBase::setWindowHeight(int height)
mHeight = height; mHeight = height;
} }
GLWindowBase *ANGLETestBase::getGLWindow() const
{
return mEGLWindow;
}
void ANGLETestBase::setConfigRedBits(int bits) void ANGLETestBase::setConfigRedBits(int bits)
{ {
mEGLWindow->setConfigRedBits(bits); getGLWindow()->setConfigRedBits(bits);
} }
void ANGLETestBase::setConfigGreenBits(int bits) void ANGLETestBase::setConfigGreenBits(int bits)
{ {
mEGLWindow->setConfigGreenBits(bits); getGLWindow()->setConfigGreenBits(bits);
} }
void ANGLETestBase::setConfigBlueBits(int bits) void ANGLETestBase::setConfigBlueBits(int bits)
{ {
mEGLWindow->setConfigBlueBits(bits); getGLWindow()->setConfigBlueBits(bits);
} }
void ANGLETestBase::setConfigAlphaBits(int bits) void ANGLETestBase::setConfigAlphaBits(int bits)
{ {
mEGLWindow->setConfigAlphaBits(bits); getGLWindow()->setConfigAlphaBits(bits);
} }
void ANGLETestBase::setConfigDepthBits(int bits) void ANGLETestBase::setConfigDepthBits(int bits)
{ {
mEGLWindow->setConfigDepthBits(bits); getGLWindow()->setConfigDepthBits(bits);
} }
void ANGLETestBase::setConfigStencilBits(int bits) void ANGLETestBase::setConfigStencilBits(int bits)
{ {
mEGLWindow->setConfigStencilBits(bits); getGLWindow()->setConfigStencilBits(bits);
} }
void ANGLETestBase::setConfigComponentType(EGLenum componentType) void ANGLETestBase::setConfigComponentType(EGLenum componentType)
...@@ -1039,16 +1040,10 @@ bool ANGLETestBase::isMultisampleEnabled() const ...@@ -1039,16 +1040,10 @@ bool ANGLETestBase::isMultisampleEnabled() const
return mEGLWindow->isMultisample(); return mEGLWindow->isMultisample();
} }
bool ANGLETestBase::destroyEGLContext()
{
mEGLWindow->destroyGL();
return true;
}
// static // static
bool ANGLETestBase::InitTestWindow() bool ANGLETestBase::InitTestWindow()
{ {
mOSWindow = CreateOSWindow(); mOSWindow = OSWindow::New();
if (!mOSWindow->initialize("ANGLE_TEST", 128, 128)) if (!mOSWindow->initialize("ANGLE_TEST", 128, 128))
{ {
return false; return false;
...@@ -1065,8 +1060,7 @@ bool ANGLETestBase::DestroyTestWindow() ...@@ -1065,8 +1060,7 @@ bool ANGLETestBase::DestroyTestWindow()
if (mOSWindow) if (mOSWindow)
{ {
mOSWindow->destroy(); mOSWindow->destroy();
delete mOSWindow; OSWindow::Delete(&mOSWindow);
mOSWindow = nullptr;
} }
return true; return true;
......
...@@ -235,9 +235,10 @@ GLColor32F ReadColor32F(GLint x, GLint y); ...@@ -235,9 +235,10 @@ GLColor32F ReadColor32F(GLint x, GLint y);
#define EXPECT_PIXEL_COLOR32F_NEAR(x, y, angleColor, abs_error) \ #define EXPECT_PIXEL_COLOR32F_NEAR(x, y, angleColor, abs_error) \
EXPECT_PIXEL32F_NEAR(x, y, angleColor.R, angleColor.G, angleColor.B, angleColor.A, abs_error) EXPECT_PIXEL32F_NEAR(x, y, angleColor.R, angleColor.G, angleColor.B, angleColor.A, abs_error)
class ANGLETestBase;
class EGLWindow; class EGLWindow;
class GLWindowBase;
class OSWindow; class OSWindow;
class ANGLETestBase;
struct TestPlatformContext final : private angle::NonCopyable struct TestPlatformContext final : private angle::NonCopyable
{ {
...@@ -385,8 +386,6 @@ class ANGLETestBase ...@@ -385,8 +386,6 @@ class ANGLETestBase
}; };
private: private:
bool destroyEGLContext();
void checkD3D11SDKLayersMessages(); void checkD3D11SDKLayersMessages();
void drawQuad(GLuint program, void drawQuad(GLuint program,
...@@ -397,6 +396,8 @@ class ANGLETestBase ...@@ -397,6 +396,8 @@ class ANGLETestBase
bool useInstancedDrawCalls, bool useInstancedDrawCalls,
GLuint numInstances); GLuint numInstances);
GLWindowBase *getGLWindow() const;
EGLWindow *mEGLWindow; EGLWindow *mEGLWindow;
int mWidth; int mWidth;
int mHeight; int mHeight;
......
...@@ -20,6 +20,25 @@ ...@@ -20,6 +20,25 @@
namespace angle namespace angle
{ {
namespace
{
bool IsANGLEConfigSupported(const PlatformParameters &param, OSWindow *osWindow)
{
std::unique_ptr<angle::Library> eglLibrary;
#if defined(ANGLE_USE_UTIL_LOADER)
eglLibrary.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME));
#endif
EGLWindow *eglWindow =
EGLWindow::New(param.majorVersion, param.minorVersion, param.eglParameters);
bool result = eglWindow->initializeGL(osWindow, eglLibrary.get());
eglWindow->destroyGL();
EGLWindow::Delete(&eglWindow);
return result;
}
} // namespace
bool IsPlatformAvailable(const PlatformParameters &param) bool IsPlatformAvailable(const PlatformParameters &param)
{ {
switch (param.getRenderer()) switch (param.getRenderer())
...@@ -75,27 +94,16 @@ bool IsPlatformAvailable(const PlatformParameters &param) ...@@ -75,27 +94,16 @@ bool IsPlatformAvailable(const PlatformParameters &param)
} }
else else
{ {
OSWindow *osWindow = CreateOSWindow(); OSWindow *osWindow = OSWindow::New();
bool result = osWindow->initialize("CONFIG_TESTER", 1, 1); bool result = osWindow->initialize("CONFIG_TESTER", 1, 1);
if (result) if (result)
{ {
std::unique_ptr<angle::Library> eglLibrary; result = IsANGLEConfigSupported(param, osWindow);
#if defined(ANGLE_USE_UTIL_LOADER)
eglLibrary.reset(angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME));
#endif // defined(ANGLE_USE_UTIL_LOADER)
EGLWindow *eglWindow =
new EGLWindow(param.majorVersion, param.minorVersion, param.eglParameters);
result = eglWindow->initializeGL(osWindow, eglLibrary.get());
eglWindow->destroyGL();
SafeDelete(eglWindow);
} }
osWindow->destroy(); osWindow->destroy();
SafeDelete(osWindow); OSWindow::Delete(&osWindow);
paramAvailabilityCache[param] = result; paramAvailabilityCache[param] = result;
......
...@@ -557,7 +557,7 @@ void destroy_window(struct sample_info &info) ...@@ -557,7 +557,7 @@ void destroy_window(struct sample_info &info)
void init_window_size(struct sample_info &info, int32_t default_width, int32_t default_height) void init_window_size(struct sample_info &info, int32_t default_width, int32_t default_height)
{ {
#ifdef __ANDROID__ #ifdef __ANDROID__
info.mOSWindow = CreateOSWindow(); info.mOSWindow = OSWindow::New();
assert(info.mOSWindow != nullptr); assert(info.mOSWindow != nullptr);
info.mOSWindow->initialize("VulkanTest", default_width, default_height); info.mOSWindow->initialize("VulkanTest", default_width, default_height);
#endif #endif
......
...@@ -87,39 +87,45 @@ bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b) ...@@ -87,39 +87,45 @@ bool operator==(const EGLPlatformParameters &a, const EGLPlatformParameters &b)
(a.presentPath == b.presentPath); (a.presentPath == b.presentPath);
} }
// GLWindowBase implementation.
GLWindowBase::GLWindowBase(EGLint glesMajorVersion, EGLint glesMinorVersion)
: mClientMajorVersion(glesMajorVersion),
mClientMinorVersion(glesMinorVersion),
mRedBits(-1),
mGreenBits(-1),
mBlueBits(-1),
mAlphaBits(-1),
mDepthBits(-1),
mStencilBits(-1),
mSwapInterval(-1),
mPlatformMethods(nullptr)
{}
GLWindowBase::~GLWindowBase() = default;
// EGLWindow implementation.
EGLWindow::EGLWindow(EGLint glesMajorVersion, EGLWindow::EGLWindow(EGLint glesMajorVersion,
EGLint glesMinorVersion, EGLint glesMinorVersion,
const EGLPlatformParameters &platform) const EGLPlatformParameters &platform)
: mDisplay(EGL_NO_DISPLAY), : GLWindowBase(glesMajorVersion, glesMinorVersion),
mDisplay(EGL_NO_DISPLAY),
mSurface(EGL_NO_SURFACE), mSurface(EGL_NO_SURFACE),
mContext(EGL_NO_CONTEXT), mContext(EGL_NO_CONTEXT),
mClientMajorVersion(glesMajorVersion),
mClientMinorVersion(glesMinorVersion),
mEGLMajorVersion(0), mEGLMajorVersion(0),
mEGLMinorVersion(0), mEGLMinorVersion(0),
mPlatform(platform), mPlatform(platform),
mRedBits(-1),
mGreenBits(-1),
mBlueBits(-1),
mAlphaBits(-1),
mDepthBits(-1),
mStencilBits(-1),
mComponentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT), mComponentType(EGL_COLOR_COMPONENT_TYPE_FIXED_EXT),
mMultisample(false), mMultisample(false),
mDebug(false), mDebug(false),
mNoError(false), mNoError(false),
mWebGLCompatibility(false),
mExtensionsEnabled(), mExtensionsEnabled(),
mBindGeneratesResource(true), mBindGeneratesResource(true),
mClientArraysEnabled(true), mClientArraysEnabled(true),
mRobustAccess(false), mRobustAccess(false),
mRobustResourceInit(),
mSwapInterval(-1),
mSamples(-1), mSamples(-1),
mDebugLayersEnabled(), mDebugLayersEnabled(),
mContextProgramCacheEnabled(), mContextProgramCacheEnabled(),
mContextVirtualization(), mContextVirtualization()
mPlatformMethods(nullptr)
{} {}
EGLWindow::~EGLWindow() EGLWindow::~EGLWindow()
...@@ -152,18 +158,18 @@ EGLContext EGLWindow::getContext() const ...@@ -152,18 +158,18 @@ EGLContext EGLWindow::getContext() const
return mContext; return mContext;
} }
bool EGLWindow::initializeGL(OSWindow *osWindow, angle::Library *eglLibrary) bool EGLWindow::initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibrary)
{ {
if (!initializeDisplayAndSurface(osWindow, eglLibrary)) if (!initializeDisplayAndSurface(osWindow, glWindowingLibrary))
return false; return false;
return initializeContext(); return initializeContext();
} }
bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow, angle::Library *eglLibrary) bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow, angle::Library *glWindowingLibrary)
{ {
#if defined(ANGLE_USE_UTIL_LOADER) #if defined(ANGLE_USE_UTIL_LOADER)
PFNEGLGETPROCADDRESSPROC getProcAddress; PFNEGLGETPROCADDRESSPROC getProcAddress;
eglLibrary->getAs("eglGetProcAddress", &getProcAddress); glWindowingLibrary->getAs("eglGetProcAddress", &getProcAddress);
if (!getProcAddress) if (!getProcAddress)
{ {
return false; return false;
...@@ -307,6 +313,10 @@ bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow, angle::Library * ...@@ -307,6 +313,10 @@ bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow, angle::Library *
return false; return false;
} }
#if defined(ANGLE_USE_UTIL_LOADER)
angle::LoadGLES(eglGetProcAddress);
#endif // defined(ANGLE_USE_UTIL_LOADER)
return true; return true;
} }
...@@ -324,7 +334,7 @@ EGLContext EGLWindow::createContext(EGLContext share) const ...@@ -324,7 +334,7 @@ EGLContext EGLWindow::createContext(EGLContext share) const
bool hasWebGLCompatibility = bool hasWebGLCompatibility =
strstr(displayExtensions, "EGL_ANGLE_create_context_webgl_compatibility") != nullptr; strstr(displayExtensions, "EGL_ANGLE_create_context_webgl_compatibility") != nullptr;
if (mWebGLCompatibility && !hasWebGLCompatibility) if (mWebGLCompatibility.valid() && !hasWebGLCompatibility)
{ {
return EGL_NO_CONTEXT; return EGL_NO_CONTEXT;
} }
...@@ -389,10 +399,10 @@ EGLContext EGLWindow::createContext(EGLContext share) const ...@@ -389,10 +399,10 @@ EGLContext EGLWindow::createContext(EGLContext share) const
contextAttributes.push_back(EGL_CONTEXT_OPENGL_NO_ERROR_KHR); contextAttributes.push_back(EGL_CONTEXT_OPENGL_NO_ERROR_KHR);
contextAttributes.push_back(mNoError ? EGL_TRUE : EGL_FALSE); contextAttributes.push_back(mNoError ? EGL_TRUE : EGL_FALSE);
if (hasWebGLCompatibility) if (mWebGLCompatibility.valid())
{ {
contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE); contextAttributes.push_back(EGL_CONTEXT_WEBGL_COMPATIBILITY_ANGLE);
contextAttributes.push_back(mWebGLCompatibility ? EGL_TRUE : EGL_FALSE); contextAttributes.push_back(mWebGLCompatibility.value() ? EGL_TRUE : EGL_FALSE);
} }
if (mExtensionsEnabled.valid()) if (mExtensionsEnabled.valid())
...@@ -552,3 +562,25 @@ bool CheckExtensionExists(const char *allExtensions, const std::string &extName) ...@@ -552,3 +562,25 @@ bool CheckExtensionExists(const char *allExtensions, const std::string &extName)
return paddedExtensions.find(std::string(" ") + extName + std::string(" ")) != return paddedExtensions.find(std::string(" ") + extName + std::string(" ")) !=
std::string::npos; std::string::npos;
} }
// static
void GLWindowBase::Delete(GLWindowBase **window)
{
delete *window;
*window = nullptr;
}
// static
EGLWindow *EGLWindow::New(EGLint glesMajorVersion,
EGLint glesMinorVersion,
const EGLPlatformParameters &platform)
{
return new EGLWindow(glesMajorVersion, glesMinorVersion, platform);
}
// static
void EGLWindow::Delete(EGLWindow **window)
{
delete *window;
*window = nullptr;
}
...@@ -26,30 +26,78 @@ class Library; ...@@ -26,30 +26,78 @@ class Library;
struct PlatformMethods; struct PlatformMethods;
} // namespace angle } // namespace angle
class ANGLE_UTIL_EXPORT EGLWindow : angle::NonCopyable class ANGLE_UTIL_EXPORT GLWindowBase : angle::NonCopyable
{ {
public: public:
EGLWindow(EGLint glesMajorVersion, static void Delete(GLWindowBase **window);
EGLint glesMinorVersion,
const EGLPlatformParameters &platform);
~EGLWindow();
// It should also be possible to set multisample and floating point framebuffers.
void setConfigRedBits(int bits) { mRedBits = bits; } void setConfigRedBits(int bits) { mRedBits = bits; }
void setConfigGreenBits(int bits) { mGreenBits = bits; } void setConfigGreenBits(int bits) { mGreenBits = bits; }
void setConfigBlueBits(int bits) { mBlueBits = bits; } void setConfigBlueBits(int bits) { mBlueBits = bits; }
void setConfigAlphaBits(int bits) { mAlphaBits = bits; } void setConfigAlphaBits(int bits) { mAlphaBits = bits; }
void setConfigDepthBits(int bits) { mDepthBits = bits; } void setConfigDepthBits(int bits) { mDepthBits = bits; }
void setConfigStencilBits(int bits) { mStencilBits = bits; } void setConfigStencilBits(int bits) { mStencilBits = bits; }
void setSwapInterval(int swapInterval) { mSwapInterval = swapInterval; }
int getConfigRedBits() const { return mRedBits; }
int getConfigGreenBits() const { return mGreenBits; }
int getConfigBlueBits() const { return mBlueBits; }
int getConfigAlphaBits() const { return mAlphaBits; }
int getConfigDepthBits() const { return mDepthBits; }
int getConfigStencilBits() const { return mStencilBits; }
int getSwapInterval() const { return mSwapInterval; }
void setPlatformMethods(angle::PlatformMethods *platformMethods)
{
mPlatformMethods = platformMethods;
}
void setWebGLCompatibilityEnabled(bool webglCompatibility)
{
mWebGLCompatibility = webglCompatibility;
}
void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; }
EGLint getClientMajorVersion() const { return mClientMajorVersion; }
EGLint getClientMinorVersion() const { return mClientMinorVersion; }
virtual bool initializeGL(OSWindow *osWindow, angle::Library *glLibrary) = 0;
virtual bool isGLInitialized() const = 0;
virtual void swap() = 0;
virtual void destroyGL() = 0;
virtual void makeCurrent() = 0;
protected:
GLWindowBase(EGLint glesMajorVersion, EGLint glesMinorVersion);
virtual ~GLWindowBase();
EGLint mClientMajorVersion;
EGLint mClientMinorVersion;
int mRedBits;
int mGreenBits;
int mBlueBits;
int mAlphaBits;
int mDepthBits;
int mStencilBits;
int mSwapInterval;
angle::PlatformMethods *mPlatformMethods;
Optional<bool> mWebGLCompatibility;
Optional<bool> mRobustResourceInit;
};
class ANGLE_UTIL_EXPORT EGLWindow : public GLWindowBase
{
public:
static EGLWindow *New(EGLint glesMajorVersion,
EGLint glesMinorVersion,
const EGLPlatformParameters &platform);
static void Delete(EGLWindow **window);
void setConfigComponentType(EGLenum componentType) { mComponentType = componentType; } void setConfigComponentType(EGLenum componentType) { mComponentType = componentType; }
void setMultisample(bool multisample) { mMultisample = multisample; } void setMultisample(bool multisample) { mMultisample = multisample; }
void setSamples(EGLint samples) { mSamples = samples; } void setSamples(EGLint samples) { mSamples = samples; }
void setDebugEnabled(bool debug) { mDebug = debug; } void setDebugEnabled(bool debug) { mDebug = debug; }
void setNoErrorEnabled(bool noError) { mNoError = noError; } void setNoErrorEnabled(bool noError) { mNoError = noError; }
void setWebGLCompatibilityEnabled(bool webglCompatibility)
{
mWebGLCompatibility = webglCompatibility;
}
void setExtensionsEnabled(bool extensionsEnabled) { mExtensionsEnabled = extensionsEnabled; } void setExtensionsEnabled(bool extensionsEnabled) { mExtensionsEnabled = extensionsEnabled; }
void setBindGeneratesResource(bool bindGeneratesResource) void setBindGeneratesResource(bool bindGeneratesResource)
{ {
...@@ -58,42 +106,27 @@ class ANGLE_UTIL_EXPORT EGLWindow : angle::NonCopyable ...@@ -58,42 +106,27 @@ class ANGLE_UTIL_EXPORT EGLWindow : angle::NonCopyable
void setDebugLayersEnabled(bool enabled) { mDebugLayersEnabled = enabled; } void setDebugLayersEnabled(bool enabled) { mDebugLayersEnabled = enabled; }
void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; } void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; }
void setRobustAccess(bool enabled) { mRobustAccess = enabled; } void setRobustAccess(bool enabled) { mRobustAccess = enabled; }
void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; }
void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
void setPlatformMethods(angle::PlatformMethods *platformMethods)
{
mPlatformMethods = platformMethods;
}
void setContextProgramCacheEnabled(bool enabled) { mContextProgramCacheEnabled = enabled; } void setContextProgramCacheEnabled(bool enabled) { mContextProgramCacheEnabled = enabled; }
void setContextVirtualization(bool enabled) { mContextVirtualization = enabled; } void setContextVirtualization(bool enabled) { mContextVirtualization = enabled; }
static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config); static EGLBoolean FindEGLConfig(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *config);
void swap(); void swap() override;
EGLint getClientMajorVersion() const { return mClientMajorVersion; }
EGLint getClientMinorVersion() const { return mClientMinorVersion; }
const EGLPlatformParameters &getPlatform() const { return mPlatform; } const EGLPlatformParameters &getPlatform() const { return mPlatform; }
EGLConfig getConfig() const; EGLConfig getConfig() const;
EGLDisplay getDisplay() const; EGLDisplay getDisplay() const;
EGLSurface getSurface() const; EGLSurface getSurface() const;
EGLContext getContext() const; EGLContext getContext() const;
int getConfigRedBits() const { return mRedBits; }
int getConfigGreenBits() const { return mGreenBits; }
int getConfigBlueBits() const { return mBlueBits; }
int getConfigAlphaBits() const { return mAlphaBits; }
int getConfigDepthBits() const { return mDepthBits; }
int getConfigStencilBits() const { return mStencilBits; }
bool isMultisample() const { return mMultisample; } bool isMultisample() const { return mMultisample; }
bool isDebugEnabled() const { return mDebug; } bool isDebugEnabled() const { return mDebug; }
EGLint getSwapInterval() const { return mSwapInterval; }
const angle::PlatformMethods *getPlatformMethods() const { return mPlatformMethods; } const angle::PlatformMethods *getPlatformMethods() const { return mPlatformMethods; }
// Internally initializes the Display, Surface and Context. // Internally initializes the Display, Surface and Context.
bool initializeGL(OSWindow *osWindow, angle::Library *eglLibrary); bool initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibrary) override;
// Only initializes the Display and Surface. // Only initializes the Display and Surface.
bool initializeDisplayAndSurface(OSWindow *osWindow, angle::Library *eglLibrary); bool initializeDisplayAndSurface(OSWindow *osWindow, angle::Library *glWindowingLibrary);
// Create an EGL context with this window's configuration // Create an EGL context with this window's configuration
EGLContext createContext(EGLContext share) const; EGLContext createContext(EGLContext share) const;
...@@ -101,46 +134,39 @@ class ANGLE_UTIL_EXPORT EGLWindow : angle::NonCopyable ...@@ -101,46 +134,39 @@ class ANGLE_UTIL_EXPORT EGLWindow : angle::NonCopyable
// Only initializes the Context. // Only initializes the Context.
bool initializeContext(); bool initializeContext();
void destroyGL(); void destroyGL() override;
bool isGLInitialized() const; bool isGLInitialized() const override;
void makeCurrent() override;
void makeCurrent();
static bool ClientExtensionEnabled(const std::string &extName); static bool ClientExtensionEnabled(const std::string &extName);
private: private:
EGLWindow(EGLint glesMajorVersion,
EGLint glesMinorVersion,
const EGLPlatformParameters &platform);
~EGLWindow() override;
EGLConfig mConfig; EGLConfig mConfig;
EGLDisplay mDisplay; EGLDisplay mDisplay;
EGLSurface mSurface; EGLSurface mSurface;
EGLContext mContext; EGLContext mContext;
EGLint mClientMajorVersion;
EGLint mClientMinorVersion;
EGLint mEGLMajorVersion; EGLint mEGLMajorVersion;
EGLint mEGLMinorVersion; EGLint mEGLMinorVersion;
EGLPlatformParameters mPlatform; EGLPlatformParameters mPlatform;
int mRedBits;
int mGreenBits;
int mBlueBits;
int mAlphaBits;
int mDepthBits;
int mStencilBits;
EGLenum mComponentType; EGLenum mComponentType;
bool mMultisample; bool mMultisample;
bool mDebug; bool mDebug;
bool mNoError; bool mNoError;
bool mWebGLCompatibility;
Optional<bool> mExtensionsEnabled; Optional<bool> mExtensionsEnabled;
bool mBindGeneratesResource; bool mBindGeneratesResource;
bool mClientArraysEnabled; bool mClientArraysEnabled;
bool mRobustAccess; bool mRobustAccess;
Optional<bool> mRobustResourceInit;
EGLint mSwapInterval;
EGLint mSamples; EGLint mSamples;
Optional<bool> mDebugLayersEnabled; Optional<bool> mDebugLayersEnabled;
Optional<bool> mContextProgramCacheEnabled; Optional<bool> mContextProgramCacheEnabled;
Optional<bool> mContextVirtualization; Optional<bool> mContextVirtualization;
angle::PlatformMethods *mPlatformMethods;
}; };
ANGLE_UTIL_EXPORT bool CheckExtensionExists(const char *allExtensions, const std::string &extName); ANGLE_UTIL_EXPORT bool CheckExtensionExists(const char *allExtensions, const std::string &extName);
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// OSWindow:
// Operating system window integration base class.
#ifndef SAMPLE_UTIL_WINDOW_H #ifndef UTIL_OSWINDOW_H_
#define SAMPLE_UTIL_WINDOW_H #define UTIL_OSWINDOW_H_
#include <stdint.h> #include <stdint.h>
#include <list> #include <list>
...@@ -20,8 +22,8 @@ ...@@ -20,8 +22,8 @@
class ANGLE_UTIL_EXPORT OSWindow class ANGLE_UTIL_EXPORT OSWindow
{ {
public: public:
OSWindow(); static OSWindow *New();
virtual ~OSWindow(); static void Delete(OSWindow **osWindow);
virtual bool initialize(const std::string &name, size_t width, size_t height) = 0; virtual bool initialize(const std::string &name, size_t width, size_t height) = 0;
virtual void destroy() = 0; virtual void destroy() = 0;
...@@ -56,6 +58,10 @@ class ANGLE_UTIL_EXPORT OSWindow ...@@ -56,6 +58,10 @@ class ANGLE_UTIL_EXPORT OSWindow
bool didTestEventFire(); bool didTestEventFire();
protected: protected:
OSWindow();
virtual ~OSWindow();
friend ANGLE_UTIL_EXPORT void FreeOSWindow(OSWindow *window);
int mX; int mX;
int mY; int mY;
int mWidth; int mWidth;
...@@ -64,6 +70,4 @@ class ANGLE_UTIL_EXPORT OSWindow ...@@ -64,6 +70,4 @@ class ANGLE_UTIL_EXPORT OSWindow
std::list<Event> mEvents; std::list<Event> mEvents;
}; };
ANGLE_UTIL_EXPORT OSWindow *CreateOSWindow(); #endif // UTIL_OSWINDOW_H_
#endif // SAMPLE_UTIL_WINDOW_H
...@@ -86,16 +86,6 @@ void AndroidWindow::signalTestEvent() ...@@ -86,16 +86,6 @@ void AndroidWindow::signalTestEvent()
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
OSWindow *CreateOSWindow()
{
// There should be only one live instance of AndroidWindow at a time,
// as there is only one Activity Surface behind it.
// Creating a new AndroidWindow each time works for ANGLETest,
// as it destroys an old window before creating a new one.
// TODO: use GLSurfaceView to support multiple windows
return new AndroidWindow();
}
static void onAppCmd(struct android_app *app, int32_t cmd) static void onAppCmd(struct android_app *app, int32_t cmd)
{ {
switch (cmd) switch (cmd)
...@@ -144,3 +134,14 @@ void android_main(struct android_app *app) ...@@ -144,3 +134,14 @@ void android_main(struct android_app *app)
} }
} }
} }
// static
OSWindow *OSWindow::New()
{
// There should be only one live instance of AndroidWindow at a time,
// as there is only one Activity Surface behind it.
// Creating a new AndroidWindow each time works for ANGLETest,
// as it destroys an old window before creating a new one.
// TODO: use GLSurfaceView to support multiple windows
return new AndroidWindow();
}
...@@ -777,7 +777,8 @@ NSWindow *OSXWindow::getNSWindow() const ...@@ -777,7 +777,8 @@ NSWindow *OSXWindow::getNSWindow() const
return mWindow; return mWindow;
} }
OSWindow *CreateOSWindow() // static
OSWindow *OSWindow::New()
{ {
return new OSXWindow; return new OSXWindow;
} }
...@@ -64,7 +64,8 @@ void OzoneWindow::setVisible(bool isVisible) ...@@ -64,7 +64,8 @@ void OzoneWindow::setVisible(bool isVisible)
void OzoneWindow::signalTestEvent() {} void OzoneWindow::signalTestEvent() {}
OSWindow *CreateOSWindow() // static
OSWindow *OSWindow::New()
{ {
return new OzoneWindow(); return new OzoneWindow();
} }
...@@ -736,11 +736,6 @@ void Win32Window::setMousePosition(int x, int y) ...@@ -736,11 +736,6 @@ void Win32Window::setMousePosition(int x, int y)
SetCursorPos(topLeft.x + x, topLeft.y + y); SetCursorPos(topLeft.x + x, topLeft.y + y);
} }
OSWindow *CreateOSWindow()
{
return new Win32Window();
}
bool Win32Window::setPosition(int x, int y) bool Win32Window::setPosition(int x, int y)
{ {
if (mX == x && mY == y) if (mX == x && mY == y)
...@@ -830,3 +825,9 @@ void Win32Window::signalTestEvent() ...@@ -830,3 +825,9 @@ void Win32Window::signalTestEvent()
{ {
PostMessage(mNativeWindow, WM_USER, 0, 0); PostMessage(mNativeWindow, WM_USER, 0, 0);
} }
// static
OSWindow *OSWindow::New()
{
return new Win32Window();
}
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#include "windows/winrt/WinRTWindow.h" #include "windows/winrt/WinRTWindow.h"
#include <wrl.h>
#include <windows.applicationmodel.core.h> #include <windows.applicationmodel.core.h>
#include <windows.ui.xaml.h> #include <windows.ui.xaml.h>
#include <wrl.h>
#include "angle_windowsstore.h" #include "angle_windowsstore.h"
#include "common/debug.h" #include "common/debug.h"
...@@ -22,9 +22,7 @@ using namespace ABI::Windows::UI::Core; ...@@ -22,9 +22,7 @@ using namespace ABI::Windows::UI::Core;
using namespace Microsoft::WRL; using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers; using namespace Microsoft::WRL::Wrappers;
WinRTWindow::WinRTWindow() : mNativeWindow(nullptr) WinRTWindow::WinRTWindow() : mNativeWindow(nullptr) {}
{
}
WinRTWindow::~WinRTWindow() WinRTWindow::~WinRTWindow()
{ {
...@@ -50,8 +48,8 @@ bool WinRTWindow::initialize(const std::string &name, size_t width, size_t heigh ...@@ -50,8 +48,8 @@ bool WinRTWindow::initialize(const std::string &name, size_t width, size_t heigh
destroy(); destroy();
// Get all the relevant activation factories // Get all the relevant activation factories
result = GetActivationFactory( result = GetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(),
HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(), &coreWindowStatic); &coreWindowStatic);
if (FAILED(result)) if (FAILED(result))
{ {
return false; return false;
...@@ -90,7 +88,7 @@ bool WinRTWindow::initialize(const std::string &name, size_t width, size_t heigh ...@@ -90,7 +88,7 @@ bool WinRTWindow::initialize(const std::string &name, size_t width, size_t heigh
// Get the PropertySet as a map, so we can Insert things into it later // Get the PropertySet as a map, so we can Insert things into it later
ComPtr<IInspectable> tempNativeWindow = mNativeWindow; ComPtr<IInspectable> tempNativeWindow = mNativeWindow;
result = tempNativeWindow.As(&nativeWindowAsMap); result = tempNativeWindow.As(&nativeWindowAsMap);
if (FAILED(result)) if (FAILED(result))
{ {
return false; return false;
...@@ -195,7 +193,7 @@ bool WinRTWindow::initialize(const std::string &name, size_t width, size_t heigh ...@@ -195,7 +193,7 @@ bool WinRTWindow::initialize(const std::string &name, size_t width, size_t heigh
Size renderSize; Size renderSize;
renderSize.Width = static_cast<float>(width); renderSize.Width = static_cast<float>(width);
renderSize.Height = static_cast<float>(height); renderSize.Height = static_cast<float>(height);
result = propertyValueStatics->CreateSize(renderSize, sizeValue.GetAddressOf()); result = propertyValueStatics->CreateSize(renderSize, sizeValue.GetAddressOf());
if (FAILED(result)) if (FAILED(result))
{ {
return false; return false;
...@@ -278,7 +276,7 @@ void WinRTWindow::signalTestEvent() ...@@ -278,7 +276,7 @@ void WinRTWindow::signalTestEvent()
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
OSWindow *CreateOSWindow() OSWindow *OSWindow::New()
{ {
return new WinRTWindow(); return new WinRTWindow();
} }
\ No newline at end of file
...@@ -413,11 +413,6 @@ void X11Window::setMousePosition(int x, int y) ...@@ -413,11 +413,6 @@ void X11Window::setMousePosition(int x, int y)
XWarpPointer(mDisplay, None, mWindow, 0, 0, 0, 0, x, y); XWarpPointer(mDisplay, None, mWindow, 0, 0, 0, 0, x, y);
} }
OSWindow *CreateOSWindow()
{
return new X11Window();
}
bool X11Window::setPosition(int x, int y) bool X11Window::setPosition(int x, int y)
{ {
XMoveWindow(mDisplay, mWindow, x, y); XMoveWindow(mDisplay, mWindow, x, y);
...@@ -706,3 +701,9 @@ void X11Window::processEvent(const XEvent &xEvent) ...@@ -706,3 +701,9 @@ void X11Window::processEvent(const XEvent &xEvent)
break; break;
} }
} }
// static
OSWindow *OSWindow::New()
{
return new X11Window();
}
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