PlatformDisplayLibWPE.cpp [plain text]
#include "config.h"
#include "PlatformDisplayLibWPE.h"
#if USE(WPE_RENDERER)
#include "GLContextEGL.h"
#if USE(LIBEPOXY)
#define __GBM__ 1
#include "EpoxyEGL.h"
#else
#if PLATFORM(WAYLAND)
#include <wayland-egl.h>
#endif
#include <EGL/egl.h>
#endif
#include <wpe/wpe-egl.h>
#ifndef EGL_EXT_platform_base
#define EGL_EXT_platform_base 1
typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list);
#endif
namespace WebCore {
std::unique_ptr<PlatformDisplayLibWPE> PlatformDisplayLibWPE::create()
{
return std::unique_ptr<PlatformDisplayLibWPE>(new PlatformDisplayLibWPE());
}
PlatformDisplayLibWPE::PlatformDisplayLibWPE()
: PlatformDisplay(NativeDisplayOwned::No)
{
#if PLATFORM(GTK)
PlatformDisplay::setSharedDisplayForCompositing(*this);
#endif
}
PlatformDisplayLibWPE::~PlatformDisplayLibWPE()
{
wpe_renderer_backend_egl_destroy(m_backend);
}
bool PlatformDisplayLibWPE::initialize(int hostFd)
{
m_backend = wpe_renderer_backend_egl_create(hostFd);
EGLNativeDisplayType eglNativeDisplay = wpe_renderer_backend_egl_get_native_display(m_backend);
#if WPE_CHECK_VERSION(1, 1, 0)
uint32_t eglPlatform = wpe_renderer_backend_egl_get_platform(m_backend);
if (eglPlatform) {
using GetPlatformDisplayType = PFNEGLGETPLATFORMDISPLAYEXTPROC;
GetPlatformDisplayType getPlatformDisplay =
[] {
const char* extensions = eglQueryString(nullptr, EGL_EXTENSIONS);
if (GLContext::isExtensionSupported(extensions, "EGL_EXT_platform_base")
|| GLContext::isExtensionSupported(extensions, "EGL_KHR_platform_base"))
return reinterpret_cast<GetPlatformDisplayType>(eglGetProcAddress("eglGetPlatformDisplay"));
return GetPlatformDisplayType(nullptr);
}();
if (getPlatformDisplay)
m_eglDisplay = getPlatformDisplay(eglPlatform, eglNativeDisplay, nullptr);
}
#endif
if (m_eglDisplay == EGL_NO_DISPLAY)
m_eglDisplay = eglGetDisplay(eglNativeDisplay);
if (m_eglDisplay == EGL_NO_DISPLAY) {
WTFLogAlways("PlatformDisplayLibWPE: could not create the EGL display: %s.", GLContextEGL::lastErrorString());
return false;
}
PlatformDisplay::initializeEGLDisplay();
return m_eglDisplay != EGL_NO_DISPLAY;
}
}
#endif // USE(WPE_RENDERER)