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/. */
9 #include "mozilla/dom/PWebGLChild.h"
10 #include "mozilla/ipc/BigBuffer.h"
11 #include "mozilla/Maybe.h"
12 #include "mozilla/WeakPtr.h"
18 class ClientWebGLContext
;
22 struct FlushedCmdInfo final
{
24 // Store a number of flushes since last IPC congestion check.
25 // It is reset to 0, when current IPC congestion check is done.
26 size_t flushesSinceLastCongestionCheck
= 0;
27 // Incremented for each IPC congestion check.
28 size_t congestionCheckGeneration
= 0;
29 size_t flushedCmdBytes
= 0;
33 class WebGLChild final
: public PWebGLChild
, public SupportsWeakPtr
{
34 const WeakPtr
<ClientWebGLContext
> mContext
;
35 const size_t mDefaultCmdsShmemSize
;
36 mozilla::ipc::BigBuffer mPendingCmdsShmem
;
37 size_t mPendingCmdsPos
= 0;
38 size_t mPendingCmdsAlignmentOverhead
= 0;
39 FlushedCmdInfo mFlushedCmdInfo
;
42 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLChild
, override
);
44 explicit WebGLChild(ClientWebGLContext
&);
46 Maybe
<Range
<uint8_t>> AllocPendingCmdBytes(size_t,
47 size_t fyiAlignmentOverhead
);
48 void FlushPendingCmds();
50 void ActorDestroy(ActorDestroyReason why
) override
;
52 FlushedCmdInfo
& GetFlushedCmdInfo() { return mFlushedCmdInfo
; }
56 virtual ~WebGLChild();
59 mozilla::ipc::IPCResult
RecvJsWarning(const std::string
&) const;
60 mozilla::ipc::IPCResult
RecvOnContextLoss(webgl::ContextLossReason
) const;
61 mozilla::ipc::IPCResult
RecvOnSyncComplete(webgl::ObjectId
) const;
65 } // namespace mozilla
67 #endif // WEBGLCHILD_H_