2020-01-09 01:19:14 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef WEBGLCROSSPROCESSCOMMANDQUEUE_H_
|
|
|
|
#define WEBGLCROSSPROCESSCOMMANDQUEUE_H_
|
|
|
|
|
|
|
|
#include "mozilla/dom/WebGLCommandQueue.h"
|
2020-05-01 01:24:44 +03:00
|
|
|
#include "ProducerConsumerQueue.h"
|
|
|
|
#include "IpdlQueue.h"
|
2020-01-09 01:19:14 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2020-05-01 01:24:44 +03:00
|
|
|
namespace dom {
|
|
|
|
class WebGLParent;
|
|
|
|
class WebGLChild;
|
|
|
|
} // namespace dom
|
|
|
|
|
2020-01-09 01:19:14 +03:00
|
|
|
namespace layers {
|
|
|
|
class PCompositorBridgeParent;
|
|
|
|
}
|
|
|
|
|
|
|
|
class HostWebGLContext;
|
|
|
|
|
|
|
|
using mozilla::webgl::ProducerConsumerQueue;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The source for the WebGL Command Queue.
|
|
|
|
*/
|
2020-05-01 01:23:02 +03:00
|
|
|
using ClientWebGLCommandSourceP =
|
|
|
|
SyncCommandSource<size_t, mozilla::webgl::PcqProducer,
|
|
|
|
mozilla::webgl::ProducerConsumerQueue>;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The sink for the WebGL Command Queue. This object is created in the client
|
|
|
|
* and sent to the host, where it needs to be given a HostWebGLContext that it
|
|
|
|
* then uses for executing methods. Add new commands to DispatchCommand using
|
|
|
|
* the WEBGL_SYNC_COMMAND and WEBGL_ASYNC_COMMAND macros.
|
|
|
|
*/
|
2020-05-01 01:23:02 +03:00
|
|
|
template <typename Consumer, typename Queue>
|
|
|
|
class HostWebGLCommandSink final
|
|
|
|
: public SyncCommandSink<size_t, Consumer, Queue> {
|
2020-01-09 01:19:14 +03:00
|
|
|
public:
|
|
|
|
HostWebGLCommandSink(UniquePtr<Consumer>&& aConsumer,
|
2020-05-01 01:23:02 +03:00
|
|
|
UniquePtr<typename Queue::Producer>&& aResponseProducer)
|
|
|
|
: SyncCommandSink<size_t, Consumer, Queue>(
|
|
|
|
std::move(aConsumer), std::move(aResponseProducer)) {}
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-01-09 01:19:16 +03:00
|
|
|
HostWebGLContext* mHostContext = nullptr;
|
2020-01-09 01:19:14 +03:00
|
|
|
|
2020-04-30 06:06:33 +03:00
|
|
|
// For IPDL:
|
2020-05-01 01:24:44 +03:00
|
|
|
HostWebGLCommandSink() = default;
|
|
|
|
|
|
|
|
protected:
|
2020-01-09 01:19:14 +03:00
|
|
|
friend struct mozilla::ipc::IPDLParamTraits<HostWebGLCommandSink>;
|
|
|
|
friend class mozilla::layers::PCompositorBridgeParent;
|
|
|
|
|
2020-05-01 01:24:44 +03:00
|
|
|
bool DispatchCommand(size_t command) override {
|
|
|
|
MOZ_CRASH("TODO:");
|
|
|
|
return false;
|
|
|
|
}
|
2020-01-09 01:19:14 +03:00
|
|
|
};
|
|
|
|
|
2020-05-01 01:23:02 +03:00
|
|
|
using HostWebGLCommandSinkP =
|
|
|
|
HostWebGLCommandSink<mozilla::webgl::PcqConsumer,
|
|
|
|
mozilla::webgl::ProducerConsumerQueue>;
|
|
|
|
|
2020-05-01 01:24:44 +03:00
|
|
|
using IpdlWebGLCommandQueue =
|
|
|
|
mozilla::dom::IpdlQueue<mozilla::dom::WebGLChild,
|
|
|
|
mozilla::dom::WebGLParent>;
|
|
|
|
using IpdlWebGLResponseQueue =
|
|
|
|
mozilla::dom::IpdlQueue<mozilla::dom::WebGLParent,
|
|
|
|
mozilla::dom::WebGLChild>;
|
|
|
|
|
|
|
|
using ClientWebGLCommandSourceI =
|
|
|
|
SyncCommandSource<size_t, typename IpdlWebGLCommandQueue::Producer,
|
|
|
|
IpdlWebGLResponseQueue>;
|
|
|
|
using HostWebGLCommandSinkI =
|
|
|
|
HostWebGLCommandSink<typename IpdlWebGLCommandQueue::Consumer,
|
|
|
|
IpdlWebGLResponseQueue>;
|
|
|
|
|
2020-01-09 01:19:14 +03:00
|
|
|
namespace ipc {
|
|
|
|
|
2020-05-01 01:23:02 +03:00
|
|
|
template <typename Consumer, typename Queue>
|
|
|
|
struct IPDLParamTraits<mozilla::HostWebGLCommandSink<Consumer, Queue>>
|
|
|
|
: public IPDLParamTraits<
|
|
|
|
mozilla::SyncCommandSink<size_t, Consumer, Queue>> {
|
2020-01-09 01:19:14 +03:00
|
|
|
public:
|
2020-05-01 01:23:02 +03:00
|
|
|
typedef mozilla::HostWebGLCommandSink<Consumer, Queue> paramType;
|
2020-01-09 01:19:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ipc
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // WEBGLCROSSPROCESSCOMMANDQUEUE_H_
|