1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
11 #include "mozilla/dom/PWebGLChild.h"
12 #include "mozilla/dom/IpdlQueue.h"
14 // This is a bit weird. Nothing directly in WebGLChild.h necessitates including
15 // WebGLParent.h, but if we don't do this, we get compiler errors in the
16 // generated code inside PWebGLChild.cpp. The error is due to a complex
17 // dependency chain involving IpdlQueue, which I won't go into here. Including
18 // WebGLParent.h inside WebGLChild.h is the simplest way we could think of to
19 // avoid this issue. Including it in any of the code more directly involved in
20 // the breaking dependency chain unfortunately introduces a cyclical dependency
21 // between WebGLParent.h and PWebGLParent.h.
22 #include "mozilla/dom/WebGLParent.h"
26 class ClientWebGLContext
;
30 struct FlushedCmdInfo final
{
32 size_t flushedCmdBytes
= 0;
35 class WebGLChild final
: public PWebGLChild
, public SupportsWeakPtr
{
36 const WeakPtr
<ClientWebGLContext
> mContext
;
37 const size_t mDefaultCmdsShmemSize
;
38 webgl::RaiiShmem mPendingCmdsShmem
;
39 size_t mPendingCmdsPos
= 0;
40 FlushedCmdInfo mFlushedCmdInfo
;
43 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLChild
, override
);
44 using OtherSideActor
= WebGLParent
;
46 explicit WebGLChild(ClientWebGLContext
&);
48 Maybe
<Range
<uint8_t>> AllocPendingCmdBytes(size_t);
49 void FlushPendingCmds();
50 void ActorDestroy(ActorDestroyReason why
) override
;
54 virtual ~WebGLChild();
57 mozilla::ipc::IPCResult
RecvJsWarning(const std::string
&) const;
58 mozilla::ipc::IPCResult
RecvOnContextLoss(webgl::ContextLossReason
) const;
62 } // namespace mozilla
64 #endif // WEBGLCHILD_H_