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