Commit 586666ce by Jamie Madill

Make the sample app own the OS Window object.

This allows us to use OS Windows and EGL contexts differently for different implementations - eg, tests and samples. BUG=angle:730 Change-Id: I65e69fd829c3dbf2f1b406d90045bc296798ebb6 Reviewed-on: https://chromium-review.googlesource.com/213290Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 1cfaaf8a
......@@ -10,10 +10,11 @@
SampleApplication::SampleApplication(const std::string& name, size_t width, size_t height,
EGLint glesMajorVersion, EGLint requestedRenderer)
: mName(name),
mRunning(false),
mTimer(CreateTimer())
mRunning(false)
{
mEGLWindow.reset(new EGLWindow(width, height, glesMajorVersion, requestedRenderer));
mTimer.reset(CreateTimer());
mOSWindow.reset(CreateOSWindow());
}
SampleApplication::~SampleApplication()
......@@ -44,7 +45,7 @@ void SampleApplication::swap()
OSWindow *SampleApplication::getWindow() const
{
return mEGLWindow->getWindow();
return mOSWindow.get();
}
EGLConfig SampleApplication::getConfig() const
......@@ -69,12 +70,12 @@ EGLContext SampleApplication::getContext() const
int SampleApplication::run()
{
if (!getWindow()->initialize(mName, mEGLWindow->getWidth(), mEGLWindow->getHeight()))
if (!mOSWindow->initialize(mName, mEGLWindow->getWidth(), mEGLWindow->getHeight()))
{
return -1;
}
if (!mEGLWindow->initializeGL())
if (!mEGLWindow->initializeGL(mOSWindow.get()))
{
return -1;
}
......@@ -117,14 +118,14 @@ int SampleApplication::run()
draw();
swap();
getWindow()->messageLoop();
mOSWindow->messageLoop();
prevTime = elapsedTime;
}
destroy();
mEGLWindow->destroyGL();
getWindow()->destroy();
mOSWindow->destroy();
return result;
}
......@@ -136,5 +137,5 @@ void SampleApplication::exit()
bool SampleApplication::popEvent(Event *event)
{
return getWindow()->popEvent(event);
return mOSWindow->popEvent(event);
}
......@@ -52,6 +52,7 @@ class SampleApplication
std::unique_ptr<Timer> mTimer;
std::unique_ptr<EGLWindow> mEGLWindow;
std::unique_ptr<OSWindow> mOSWindow;
};
#endif // SAMPLE_UTIL_SAMPLE_APPLICATION_H
......@@ -24,8 +24,7 @@ EGLWindow::EGLWindow(size_t width, size_t height,
mClientVersion(glesMajorVersion),
mRequestedRenderer(requestedRenderer),
mWidth(width),
mHeight(height),
mOSWindow(CreateOSWindow())
mHeight(height)
{
}
......@@ -39,11 +38,6 @@ void EGLWindow::swap()
eglSwapBuffers(mDisplay, mSurface);
}
OSWindow *EGLWindow::getWindow() const
{
return mOSWindow.get();
}
EGLConfig EGLWindow::getConfig() const
{
return mConfig;
......@@ -64,7 +58,7 @@ EGLContext EGLWindow::getContext() const
return mContext;
}
bool EGLWindow::initializeGL()
bool EGLWindow::initializeGL(const OSWindow *osWindow)
{
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT"));
if (!eglGetPlatformDisplayEXT)
......@@ -78,7 +72,7 @@ bool EGLWindow::initializeGL()
EGL_NONE,
};
mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, mOSWindow->getNativeDisplay(), displayAttributes);
mDisplay = eglGetPlatformDisplayEXT(EGL_PLATFORM_ANGLE_ANGLE, osWindow->getNativeDisplay(), displayAttributes);
if (mDisplay == EGL_NO_DISPLAY)
{
destroyGL();
......@@ -124,7 +118,7 @@ bool EGLWindow::initializeGL()
EGL_NONE, EGL_NONE,
};
mSurface = eglCreateWindowSurface(mDisplay, mConfig, mOSWindow->getNativeWindow(), surfaceAttributes);
mSurface = eglCreateWindowSurface(mDisplay, mConfig, osWindow->getNativeWindow(), surfaceAttributes);
if (mSurface == EGL_NO_SURFACE)
{
eglGetError(); // Clear error and try again
......
......@@ -40,7 +40,6 @@ class EGLWindow
void swap();
OSWindow *getWindow() const;
EGLConfig getConfig() const;
EGLDisplay getDisplay() const;
EGLSurface getSurface() const;
......@@ -48,7 +47,7 @@ class EGLWindow
size_t getWidth() const { return mWidth; }
size_t getHeight() const { return mHeight; }
bool initializeGL();
bool initializeGL(const OSWindow *osWindow);
void destroyGL();
private:
......@@ -63,8 +62,6 @@ class EGLWindow
EGLint mRequestedRenderer;
size_t mWidth;
size_t mHeight;
std::unique_ptr<OSWindow> mOSWindow;
};
#endif // UTIL_EGLWINDOW_H_
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