Commit 4b91262a by Geoff Lang

Pass the Surface type, config and attributes to the constructor.

BUG=angleproject:795 Change-Id: I15e7f2f51ecc243edf83d9a9544eba137d8bb599 Reviewed-on: https://chromium-review.googlesource.com/260941Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarBrandon Jones <bajones@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 3cd438d1
...@@ -327,7 +327,7 @@ Error Display::createWindowSurface(const Config *configuration, EGLNativeWindowT ...@@ -327,7 +327,7 @@ Error Display::createWindowSurface(const Config *configuration, EGLNativeWindowT
} }
ASSERT(surfaceImpl != nullptr); ASSERT(surfaceImpl != nullptr);
Surface *surface = new Surface(surfaceImpl); Surface *surface = new Surface(surfaceImpl, EGL_WINDOW_BIT, configuration, attribs);
mImplementation->getSurfaceSet().insert(surface); mImplementation->getSurfaceSet().insert(surface);
ASSERT(outSurface != nullptr); ASSERT(outSurface != nullptr);
...@@ -356,7 +356,7 @@ Error Display::createPbufferSurface(const Config *configuration, const Attribute ...@@ -356,7 +356,7 @@ Error Display::createPbufferSurface(const Config *configuration, const Attribute
} }
ASSERT(surfaceImpl != nullptr); ASSERT(surfaceImpl != nullptr);
Surface *surface = new Surface(surfaceImpl); Surface *surface = new Surface(surfaceImpl, EGL_PBUFFER_BIT, configuration, attribs);
mImplementation->getSurfaceSet().insert(surface); mImplementation->getSurfaceSet().insert(surface);
ASSERT(outSurface != nullptr); ASSERT(outSurface != nullptr);
...@@ -386,7 +386,7 @@ Error Display::createPbufferFromClientBuffer(const Config *configuration, EGLCli ...@@ -386,7 +386,7 @@ Error Display::createPbufferFromClientBuffer(const Config *configuration, EGLCli
} }
ASSERT(surfaceImpl != nullptr); ASSERT(surfaceImpl != nullptr);
Surface *surface = new Surface(surfaceImpl); Surface *surface = new Surface(surfaceImpl, EGL_PBUFFER_BIT, configuration, attribs);
mImplementation->getSurfaceSet().insert(surface); mImplementation->getSurfaceSet().insert(surface);
ASSERT(outSurface != nullptr); ASSERT(outSurface != nullptr);
......
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
namespace egl namespace egl
{ {
Surface::Surface(rx::SurfaceImpl *impl) Surface::Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *config, const AttributeMap &attributes)
: mImplementation(impl), : mImplementation(impl),
mType(surfaceType),
mConfig(config),
// FIXME: Determine actual pixel aspect ratio // FIXME: Determine actual pixel aspect ratio
mPixelAspectRatio(static_cast<EGLint>(1.0 * EGL_DISPLAY_SCALING)), mPixelAspectRatio(static_cast<EGLint>(1.0 * EGL_DISPLAY_SCALING)),
mRenderBuffer(EGL_BACK_BUFFER), mRenderBuffer(EGL_BACK_BUFFER),
...@@ -42,6 +44,11 @@ Surface::~Surface() ...@@ -42,6 +44,11 @@ Surface::~Surface()
SafeDelete(mImplementation); SafeDelete(mImplementation);
} }
EGLint Surface::getType() const
{
return mType;
}
EGLNativeWindowType Surface::getWindowHandle() const EGLNativeWindowType Surface::getWindowHandle() const
{ {
return mImplementation->getWindowHandle(); return mImplementation->getWindowHandle();
...@@ -72,14 +79,9 @@ void Surface::setSwapInterval(EGLint interval) ...@@ -72,14 +79,9 @@ void Surface::setSwapInterval(EGLint interval)
mImplementation->setSwapInterval(interval); mImplementation->setSwapInterval(interval);
} }
EGLint Surface::getConfigID() const
{
return mImplementation->getConfig()->configID;
}
const Config *Surface::getConfig() const const Config *Surface::getConfig() const
{ {
return mImplementation->getConfig(); return mConfig;
} }
EGLint Surface::getPixelAspectRatio() const EGLint Surface::getPixelAspectRatio() const
......
...@@ -28,16 +28,20 @@ class SurfaceImpl; ...@@ -28,16 +28,20 @@ class SurfaceImpl;
namespace egl namespace egl
{ {
class AttributeMap;
class Display; class Display;
struct Config; struct Config;
class Surface final class Surface final
{ {
public: public:
Surface(rx::SurfaceImpl *impl); Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *config, const AttributeMap &attributes);
~Surface(); ~Surface();
rx::SurfaceImpl *getImplementation() const { return mImplementation; } rx::SurfaceImpl *getImplementation() { return mImplementation; }
const rx::SurfaceImpl *getImplementation() const { return mImplementation; }
EGLint getType() const;
Error swap(); Error swap();
Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height); Error postSubBuffer(EGLint x, EGLint y, EGLint width, EGLint height);
...@@ -51,7 +55,6 @@ class Surface final ...@@ -51,7 +55,6 @@ class Surface final
void setSwapInterval(EGLint interval); void setSwapInterval(EGLint interval);
EGLint getConfigID() const;
const Config *getConfig() const; const Config *getConfig() const;
// width and height can change with client window resizing // width and height can change with client window resizing
...@@ -73,6 +76,10 @@ class Surface final ...@@ -73,6 +76,10 @@ class Surface final
rx::SurfaceImpl *mImplementation; rx::SurfaceImpl *mImplementation;
EGLint mType;
const egl::Config *mConfig;
EGLint mPixelAspectRatio; // Display aspect ratio EGLint mPixelAspectRatio; // Display aspect ratio
EGLenum mRenderBuffer; // Render buffer EGLenum mRenderBuffer; // Render buffer
EGLenum mSwapBehavior; // Buffer swap behavior EGLenum mSwapBehavior; // Buffer swap behavior
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "libANGLE/AttributeMap.h"
#include "libANGLE/Config.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/renderer/SurfaceImpl.h" #include "libANGLE/renderer/SurfaceImpl.h"
...@@ -38,7 +40,7 @@ class SurfaceTest : public testing::Test ...@@ -38,7 +40,7 @@ class SurfaceTest : public testing::Test
{ {
mImpl = new MockSurfaceImpl; mImpl = new MockSurfaceImpl;
EXPECT_CALL(*mImpl, destroy()); EXPECT_CALL(*mImpl, destroy());
mSurface = new egl::Surface(mImpl); mSurface = new egl::Surface(mImpl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
} }
virtual void TearDown() virtual void TearDown()
...@@ -48,6 +50,7 @@ class SurfaceTest : public testing::Test ...@@ -48,6 +50,7 @@ class SurfaceTest : public testing::Test
MockSurfaceImpl *mImpl; MockSurfaceImpl *mImpl;
egl::Surface *mSurface; egl::Surface *mSurface;
egl::Config mConfig;
}; };
TEST_F(SurfaceTest, DestructionDeletesImpl) TEST_F(SurfaceTest, DestructionDeletesImpl)
...@@ -55,7 +58,7 @@ TEST_F(SurfaceTest, DestructionDeletesImpl) ...@@ -55,7 +58,7 @@ TEST_F(SurfaceTest, DestructionDeletesImpl)
MockSurfaceImpl *impl = new MockSurfaceImpl; MockSurfaceImpl *impl = new MockSurfaceImpl;
EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation(); EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation();
egl::Surface *surface = new egl::Surface(impl); egl::Surface *surface = new egl::Surface(impl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
delete surface; delete surface;
// Only needed because the mock is leaked if bugs are present, // Only needed because the mock is leaked if bugs are present,
......
...@@ -369,7 +369,7 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a ...@@ -369,7 +369,7 @@ EGLBoolean EGLAPIENTRY QuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint a
UNIMPLEMENTED(); // FIXME UNIMPLEMENTED(); // FIXME
break; break;
case EGL_CONFIG_ID: case EGL_CONFIG_ID:
*value = eglSurface->getConfigID(); *value = eglSurface->getConfig()->configID;
break; break;
case EGL_HEIGHT: case EGL_HEIGHT:
*value = eglSurface->getHeight(); *value = eglSurface->getHeight();
......
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