AcceleratedSurfaceWayland.cpp [plain text]
#include "config.h"
#include "AcceleratedSurfaceWayland.h"
#if PLATFORM(WAYLAND)
#include "WaylandCompositorDisplay.h"
#include "WebProcess.h"
#include <wayland-egl.h>
using namespace WebCore;
namespace WebKit {
std::unique_ptr<AcceleratedSurfaceWayland> AcceleratedSurfaceWayland::create(WebPage& webPage, Client& client)
{
return WebProcess::singleton().waylandCompositorDisplay() ? std::unique_ptr<AcceleratedSurfaceWayland>(new AcceleratedSurfaceWayland(webPage, client)) : nullptr;
}
AcceleratedSurfaceWayland::AcceleratedSurfaceWayland(WebPage& webPage, Client& client)
: AcceleratedSurface(webPage, client)
, m_surface(WebProcess::singleton().waylandCompositorDisplay()->createSurface())
, m_window(wl_egl_window_create(m_surface.get(), std::max(1, m_size.width()), std::max(1, m_size.height())))
{
WebProcess::singleton().waylandCompositorDisplay()->bindSurfaceToPage(m_surface.get(), m_webPage);
}
AcceleratedSurfaceWayland::~AcceleratedSurfaceWayland()
{
wl_egl_window_destroy(m_window);
}
bool AcceleratedSurfaceWayland::resize(const IntSize& size)
{
if (!AcceleratedSurface::resize(size))
return false;
wl_egl_window_resize(m_window, m_size.width(), m_size.height(), 0, 0);
return true;
}
void AcceleratedSurfaceWayland::didRenderFrame()
{
m_client.frameComplete();
}
}
#endif // PLATFORM(WAYLAND)