Bug 1876818 - ClientWebGLContext::Run serialization now coerces to HostWebGLContext arg types. r=gfx-reviewers,lsalzman
Differential Revision: https://phabricator.services.mozilla.com/D199768
This commit is contained in:
@@ -36,6 +36,9 @@ namespace mozilla {
|
||||
class ClientWebGLExtensionBase;
|
||||
class HostWebGLContext;
|
||||
|
||||
template <typename MethodT, MethodT Method>
|
||||
size_t IdByMethod();
|
||||
|
||||
namespace dom {
|
||||
class OwningHTMLCanvasElementOrOffscreenCanvas;
|
||||
class WebGLChild;
|
||||
@@ -2309,22 +2312,46 @@ class ClientWebGLContext final : public nsICanvasRenderingContextInternal,
|
||||
// The cross-process communication mechanism
|
||||
// -------------------------------------------------------------------------
|
||||
protected:
|
||||
template <typename ReturnType>
|
||||
friend struct WebGLClientDispatcher;
|
||||
|
||||
template <typename MethodType, MethodType method, typename ReturnType,
|
||||
typename... Args>
|
||||
friend ReturnType RunOn(const ClientWebGLContext& context, Args&&... aArgs);
|
||||
|
||||
// If we are running WebGL in this process then call the HostWebGLContext
|
||||
// method directly. Otherwise, dispatch over IPC.
|
||||
template <typename MethodType, MethodType method, typename... Args>
|
||||
void Run(Args&&... aArgs) const;
|
||||
template <typename MethodType, MethodType method, typename... CallerArgs>
|
||||
void Run(const CallerArgs&... args) const {
|
||||
const auto id = IdByMethod<MethodType, method>();
|
||||
Run_WithDestArgTypes_ConstnessHelper({}, method, id, args...);
|
||||
}
|
||||
|
||||
// Same as above for use when using potentially GC-controlled data. The scope
|
||||
// of `aNoGC` will be ended after the data is no longer needed.
|
||||
template <typename MethodType, MethodType method, typename... Args>
|
||||
void RunWithGCData(JS::AutoCheckCannotGC&& aNoGC, Args&&... aArgs) const;
|
||||
template <typename MethodType, MethodType method, typename... CallerArgs>
|
||||
void RunWithGCData(JS::AutoCheckCannotGC&& aNoGC,
|
||||
const CallerArgs&... aArgs) const {
|
||||
const auto id = IdByMethod<MethodType, method>();
|
||||
Run_WithDestArgTypes_ConstnessHelper(std::move(aNoGC), method, id,
|
||||
aArgs...);
|
||||
}
|
||||
|
||||
// Because we're trying to explicitly pull `DestArgs` via `method`, we have
|
||||
// one overload for mut-methods and one for const-methods.
|
||||
template <typename... DestArgs>
|
||||
void Run_WithDestArgTypes_ConstnessHelper(
|
||||
std::optional<JS::AutoCheckCannotGC> noGc,
|
||||
void (HostWebGLContext::*method)(DestArgs...), const size_t id,
|
||||
const std::remove_reference_t<std::remove_const_t<DestArgs>>&... args)
|
||||
const {
|
||||
Run_WithDestArgTypes(std::move(noGc), method, id, args...);
|
||||
}
|
||||
template <typename... DestArgs>
|
||||
void Run_WithDestArgTypes_ConstnessHelper(
|
||||
std::optional<JS::AutoCheckCannotGC> noGc,
|
||||
void (HostWebGLContext::*method)(DestArgs...) const, const size_t id,
|
||||
const std::remove_reference_t<std::remove_const_t<DestArgs>>&... args)
|
||||
const {
|
||||
Run_WithDestArgTypes(std::move(noGc), method, id, args...);
|
||||
}
|
||||
|
||||
template <typename MethodT, typename... DestArgs>
|
||||
void Run_WithDestArgTypes(std::optional<JS::AutoCheckCannotGC>, MethodT,
|
||||
const size_t id, const DestArgs&...) const;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Helpers for DOM operations, composition, actors, etc
|
||||
|
||||
Reference in New Issue
Block a user