AcceleratedSurface.cpp [plain text]
#include "config.h"
#include "AcceleratedSurface.h"
#include "WebPage.h"
#include <WebCore/PlatformDisplay.h>
#if PLATFORM(WAYLAND)
#include "AcceleratedSurfaceWayland.h"
#endif
#if PLATFORM(X11)
#include "AcceleratedSurfaceX11.h"
#endif
#if USE(WPE_RENDERER)
#include "AcceleratedSurfaceLibWPE.h"
#endif
namespace WebKit {
using namespace WebCore;
std::unique_ptr<AcceleratedSurface> AcceleratedSurface::create(WebPage& webPage, Client& client)
{
#if PLATFORM(WAYLAND)
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::Wayland)
#if USE(WPE_RENDERER)
return AcceleratedSurfaceLibWPE::create(webPage, client);
#else
return AcceleratedSurfaceWayland::create(webPage, client);
#endif
#endif
#if PLATFORM(X11)
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::X11)
return AcceleratedSurfaceX11::create(webPage, client);
#endif
#if USE(WPE_RENDERER)
if (PlatformDisplay::sharedDisplay().type() == PlatformDisplay::Type::WPE)
return AcceleratedSurfaceLibWPE::create(webPage, client);
#endif
RELEASE_ASSERT_NOT_REACHED();
return nullptr;
}
AcceleratedSurface::AcceleratedSurface(WebPage& webPage, Client& client)
: m_webPage(webPage)
, m_client(client)
, m_size(webPage.size())
{
m_size.scale(m_webPage.deviceScaleFactor());
}
bool AcceleratedSurface::hostResize(const IntSize& size)
{
IntSize scaledSize(size);
scaledSize.scale(m_webPage.deviceScaleFactor());
if (scaledSize == m_size)
return false;
m_size = scaledSize;
return true;
}
}