RemoteGraphicsContextGL.cpp [plain text]
#include "config.h"
#include "RemoteGraphicsContextGL.h"
#if ENABLE(GPU_PROCESS) && ENABLE(WEBGL)
#include "GPUConnectionToWebProcess.h"
#include "RemoteGraphicsContextGLMessages.h"
#include "RemoteGraphicsContextGLProxyMessages.h"
#include <WebCore/GraphicsContextGLOpenGL.h>
#include <WebCore/NotImplemented.h>
namespace WebKit {
using namespace WebCore;
#if !PLATFORM(COCOA)
std::unique_ptr<RemoteGraphicsContextGL> RemoteGraphicsContextGL::create(const WebCore::GraphicsContextGLAttributes& attributes, GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLIdentifier graphicsContextGLIdentifier)
{
ASSERT_NOT_REACHED();
return nullptr;
}
#endif
RemoteGraphicsContextGL::RemoteGraphicsContextGL(const WebCore::GraphicsContextGLAttributes& attributes, GPUConnectionToWebProcess& gpuConnectionToWebProcess, GraphicsContextGLIdentifier graphicsContextGLIdentifier, Ref<GraphicsContextGLOpenGL> context)
: m_context(WTFMove(context))
, m_gpuConnectionToWebProcess(makeWeakPtr(gpuConnectionToWebProcess))
, m_graphicsContextGLIdentifier(graphicsContextGLIdentifier)
{
if (auto* gpuConnectionToWebProcess = m_gpuConnectionToWebProcess.get())
gpuConnectionToWebProcess->messageReceiverMap().addMessageReceiver(Messages::RemoteGraphicsContextGL::messageReceiverName(), graphicsContextGLIdentifier.toUInt64(), *this);
m_context->addClient(*this);
String extensions = m_context->getString(GraphicsContextGL::EXTENSIONS);
String requestableExtensions = m_context->getString(ExtensionsGL::REQUESTABLE_EXTENSIONS_ANGLE);
send(Messages::RemoteGraphicsContextGLProxy::WasCreated(extensions, requestableExtensions), m_graphicsContextGLIdentifier);
}
RemoteGraphicsContextGL::~RemoteGraphicsContextGL()
{
if (auto* gpuConnectionToWebProcess = m_gpuConnectionToWebProcess.get())
gpuConnectionToWebProcess->messageReceiverMap().removeMessageReceiver(Messages::RemoteGraphicsContextGL::messageReceiverName(), m_graphicsContextGLIdentifier.toUInt64());
}
GPUConnectionToWebProcess* RemoteGraphicsContextGL::gpuConnectionToWebProcess() const
{
return m_gpuConnectionToWebProcess.get();
}
IPC::Connection* RemoteGraphicsContextGL::messageSenderConnection() const
{
if (auto* gpuConnectionToWebProcess = m_gpuConnectionToWebProcess.get())
return &gpuConnectionToWebProcess->connection();
return nullptr;
}
uint64_t RemoteGraphicsContextGL::messageSenderDestinationID() const
{
return m_graphicsContextGLIdentifier.toUInt64();
}
void RemoteGraphicsContextGL::didComposite()
{
}
void RemoteGraphicsContextGL::forceContextLost()
{
send(Messages::RemoteGraphicsContextGLProxy::WasLost(), m_graphicsContextGLIdentifier);
}
void RemoteGraphicsContextGL::recycleContext()
{
ASSERT_NOT_REACHED();
}
void RemoteGraphicsContextGL::dispatchContextChangedNotification()
{
send(Messages::RemoteGraphicsContextGLProxy::WasChanged(), m_graphicsContextGLIdentifier);
}
void RemoteGraphicsContextGL::reshape(int32_t width, int32_t height)
{
if (width && height)
m_context->reshape(width, height);
else
forceContextLost();
}
#if !PLATFORM(COCOA)
void RemoteGraphicsContextGL::prepareForDisplay(CompletionHandler<void()>&& completionHandler)
{
notImplemented();
completionHandler();
}
#endif
void RemoteGraphicsContextGL::ensureExtensionEnabled(String&& extension)
{
m_context->getExtensions().ensureEnabled(extension);
}
void RemoteGraphicsContextGL::notifyMarkContextChanged()
{
m_context->markContextChanged();
}
}
#endif