Skip to content

Commit

Permalink
[sailfishos][embedlite] Fix mesa egl display initialisation
Browse files Browse the repository at this point in the history
Part 1/2 On mesa based systems, the egl display does not like being initialised
twice.

Extend the embedlite api to allow the EGLDisplay to be returned with the
context.
  • Loading branch information
piggz committed Apr 21, 2021
1 parent 70c0d79 commit 3871208
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion embedding/embedlite/EmbedLiteWindow.h
Expand Up @@ -64,7 +64,7 @@ class EmbedLiteWindowListener
//
// This funtion will be called directly from gecko Compositor thread. The embedder
// must ensure this function will be thread safe.
virtual bool RequestGLContext(void*& surface, void*& context) { return false; }
virtual bool RequestGLContext(void*& surface, void*& context, void*& display) { return false; }
};

class EmbedLiteWindow {
Expand Down
8 changes: 5 additions & 3 deletions embedding/embedlite/embedshared/nsWindow.cpp
Expand Up @@ -376,9 +376,10 @@ nsWindow::GetGLContext() const
EmbedLiteWindow* window = EmbedLiteApp::GetInstance()->GetWindowByID(mWindow->GetUniqueID());
void* context = nullptr;
void* surface = nullptr;
if (window && window->GetListener()->RequestGLContext(context, surface)) {
void* display = nullptr;
if (window && window->GetListener()->RequestGLContext(context, surface, display)) {
MOZ_ASSERT(context && surface);
RefPtr<GLContext> mozContext = GLContextProvider::CreateWrappingExisting(context, surface);
RefPtr<GLContext> mozContext = GLContextProvider::CreateWrappingExisting(context, surface, display);
if (!mozContext || !mozContext->Init()) {
NS_ERROR("Failed to initialize external GL context!");
return nullptr;
Expand Down Expand Up @@ -410,7 +411,8 @@ nsWindow::CreateGLContextEarly(uint32_t aWindowId)
if (window) {
void* context = nullptr;
void* surface = nullptr;
window->GetListener()->RequestGLContext(context, surface);
void* display = nullptr;
window->GetListener()->RequestGLContext(context, surface, display);
MOZ_ASSERT(context && surface);
} else {
NS_WARNING("Trying to early create GL context for non existing window!");
Expand Down

0 comments on commit 3871208

Please sign in to comment.