Commit e88da317 by Nicolas Capens

Fix retrieving the current Display.

eglGetCurrentDisplay() returned a pointer to the concrete egl::Display object, instead of the opaque identifier obtained from eglGetDisplay. This was a regression caused by https://swiftshader-review.googlesource.com/10188 Bug chromium:738298 Change-Id: Id3a87fc3978f8f4efdc77d6c5eaa85743fa3672c Reviewed-on: https://swiftshader-review.googlesource.com/10508Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 420b64d2
......@@ -46,7 +46,7 @@ namespace egl
class DisplayImplementation : public Display
{
public:
DisplayImplementation(void *nativeDisplay) : Display(nativeDisplay) {}
DisplayImplementation(EGLDisplay dpy, void *nativeDisplay) : Display(dpy, nativeDisplay) {}
~DisplayImplementation() override {}
Image *getSharedImage(EGLImageKHR name) override
......@@ -72,12 +72,12 @@ Display *Display::get(EGLDisplay dpy)
}
#endif
static DisplayImplementation display(nativeDisplay);
static DisplayImplementation display(dpy, nativeDisplay);
return &display;
}
Display::Display(void *nativeDisplay) : nativeDisplay(nativeDisplay)
Display::Display(EGLDisplay eglDisplay, void *nativeDisplay) : eglDisplay(eglDisplay), nativeDisplay(nativeDisplay)
{
mMinSwapInterval = 1;
mMaxSwapInterval = 1;
......@@ -610,6 +610,11 @@ EGLint Display::getMaxSwapInterval() const
return mMaxSwapInterval;
}
EGLDisplay Display::getEGLDisplay() const
{
return eglDisplay;
}
void *Display::getNativeDisplay() const
{
return nativeDisplay;
......
......@@ -38,7 +38,7 @@ namespace egl
class [[clang::lto_visibility_public]] Display
{
protected:
explicit Display(void *nativeDisplay);
explicit Display(EGLDisplay eglDisplay, void *nativeDisplay);
virtual ~Display() = 0;
public:
......@@ -70,6 +70,7 @@ namespace egl
EGLint getMinSwapInterval() const;
EGLint getMaxSwapInterval() const;
EGLDisplay getEGLDisplay() const;
void *getNativeDisplay() const;
EGLImageKHR createSharedImage(Image *image);
......@@ -79,6 +80,7 @@ namespace egl
private:
sw::Format getDisplayFormat() const;
const EGLDisplay eglDisplay;
void *const nativeDisplay;
EGLint mMaxSwapInterval;
......
......@@ -862,7 +862,14 @@ EGLDisplay GetCurrentDisplay(void)
return success(EGL_NO_DISPLAY);
}
return success(context->getDisplay());
egl::Display *display = context->getDisplay();
if(!display)
{
return error(EGL_BAD_ACCESS, EGL_NO_DISPLAY);
}
return success(display->getEGLDisplay());
}
EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
......
......@@ -117,7 +117,7 @@ TEST_F(SwiftShaderTest, Initalization)
EGLContext context = eglCreateContext(display, config, NULL, contextAttributes);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_SURFACE, surface);
EXPECT_NE(EGL_NO_CONTEXT, context);
success = eglMakeCurrent(display, surface, surface, context);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
......@@ -125,19 +125,19 @@ TEST_F(SwiftShaderTest, Initalization)
EGLDisplay currentDisplay = eglGetCurrentDisplay();
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_DISPLAY, currentDisplay);
EXPECT_EQ(display, currentDisplay);
EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_SURFACE, currentDrawSurface);
EXPECT_EQ(surface, currentDrawSurface);
EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_READ);
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_SURFACE, currentReadSurface);
EXPECT_EQ(surface, currentReadSurface);
EGLContext currentContext = eglGetCurrentContext();
EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_CONTEXT, currentContext);
EXPECT_EQ(context, currentContext);
EXPECT_EQ((GLenum)GL_NO_ERROR, glGetError());
......
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