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 ...@@ -46,7 +46,7 @@ namespace egl
class DisplayImplementation : public Display class DisplayImplementation : public Display
{ {
public: public:
DisplayImplementation(void *nativeDisplay) : Display(nativeDisplay) {} DisplayImplementation(EGLDisplay dpy, void *nativeDisplay) : Display(dpy, nativeDisplay) {}
~DisplayImplementation() override {} ~DisplayImplementation() override {}
Image *getSharedImage(EGLImageKHR name) override Image *getSharedImage(EGLImageKHR name) override
...@@ -72,12 +72,12 @@ Display *Display::get(EGLDisplay dpy) ...@@ -72,12 +72,12 @@ Display *Display::get(EGLDisplay dpy)
} }
#endif #endif
static DisplayImplementation display(nativeDisplay); static DisplayImplementation display(dpy, nativeDisplay);
return &display; return &display;
} }
Display::Display(void *nativeDisplay) : nativeDisplay(nativeDisplay) Display::Display(EGLDisplay eglDisplay, void *nativeDisplay) : eglDisplay(eglDisplay), nativeDisplay(nativeDisplay)
{ {
mMinSwapInterval = 1; mMinSwapInterval = 1;
mMaxSwapInterval = 1; mMaxSwapInterval = 1;
...@@ -610,6 +610,11 @@ EGLint Display::getMaxSwapInterval() const ...@@ -610,6 +610,11 @@ EGLint Display::getMaxSwapInterval() const
return mMaxSwapInterval; return mMaxSwapInterval;
} }
EGLDisplay Display::getEGLDisplay() const
{
return eglDisplay;
}
void *Display::getNativeDisplay() const void *Display::getNativeDisplay() const
{ {
return nativeDisplay; return nativeDisplay;
......
...@@ -38,7 +38,7 @@ namespace egl ...@@ -38,7 +38,7 @@ namespace egl
class [[clang::lto_visibility_public]] Display class [[clang::lto_visibility_public]] Display
{ {
protected: protected:
explicit Display(void *nativeDisplay); explicit Display(EGLDisplay eglDisplay, void *nativeDisplay);
virtual ~Display() = 0; virtual ~Display() = 0;
public: public:
...@@ -70,6 +70,7 @@ namespace egl ...@@ -70,6 +70,7 @@ namespace egl
EGLint getMinSwapInterval() const; EGLint getMinSwapInterval() const;
EGLint getMaxSwapInterval() const; EGLint getMaxSwapInterval() const;
EGLDisplay getEGLDisplay() const;
void *getNativeDisplay() const; void *getNativeDisplay() const;
EGLImageKHR createSharedImage(Image *image); EGLImageKHR createSharedImage(Image *image);
...@@ -79,6 +80,7 @@ namespace egl ...@@ -79,6 +80,7 @@ namespace egl
private: private:
sw::Format getDisplayFormat() const; sw::Format getDisplayFormat() const;
const EGLDisplay eglDisplay;
void *const nativeDisplay; void *const nativeDisplay;
EGLint mMaxSwapInterval; EGLint mMaxSwapInterval;
......
...@@ -862,7 +862,14 @@ EGLDisplay GetCurrentDisplay(void) ...@@ -862,7 +862,14 @@ EGLDisplay GetCurrentDisplay(void)
return success(EGL_NO_DISPLAY); 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) EGLBoolean QueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value)
......
...@@ -117,7 +117,7 @@ TEST_F(SwiftShaderTest, Initalization) ...@@ -117,7 +117,7 @@ TEST_F(SwiftShaderTest, Initalization)
EGLContext context = eglCreateContext(display, config, NULL, contextAttributes); EGLContext context = eglCreateContext(display, config, NULL, contextAttributes);
EXPECT_EQ(EGL_SUCCESS, eglGetError()); EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_SURFACE, surface); EXPECT_NE(EGL_NO_CONTEXT, context);
success = eglMakeCurrent(display, surface, surface, context); success = eglMakeCurrent(display, surface, surface, context);
EXPECT_EQ(EGL_SUCCESS, eglGetError()); EXPECT_EQ(EGL_SUCCESS, eglGetError());
...@@ -125,19 +125,19 @@ TEST_F(SwiftShaderTest, Initalization) ...@@ -125,19 +125,19 @@ TEST_F(SwiftShaderTest, Initalization)
EGLDisplay currentDisplay = eglGetCurrentDisplay(); EGLDisplay currentDisplay = eglGetCurrentDisplay();
EXPECT_EQ(EGL_SUCCESS, eglGetError()); EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_DISPLAY, currentDisplay); EXPECT_EQ(display, currentDisplay);
EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW); EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW);
EXPECT_EQ(EGL_SUCCESS, eglGetError()); EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_SURFACE, currentDrawSurface); EXPECT_EQ(surface, currentDrawSurface);
EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_READ); EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_READ);
EXPECT_EQ(EGL_SUCCESS, eglGetError()); EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_SURFACE, currentReadSurface); EXPECT_EQ(surface, currentReadSurface);
EGLContext currentContext = eglGetCurrentContext(); EGLContext currentContext = eglGetCurrentContext();
EXPECT_EQ(EGL_SUCCESS, eglGetError()); EXPECT_EQ(EGL_SUCCESS, eglGetError());
EXPECT_NE(EGL_NO_CONTEXT, currentContext); EXPECT_EQ(context, currentContext);
EXPECT_EQ((GLenum)GL_NO_ERROR, glGetError()); 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