Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / canvas / WebGLChild.h
blobf4229e1b9bb7ff7795bd86c4b73ae3e895381251
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/. */
6 #ifndef WEBGLCHILD_H_
7 #define WEBGLCHILD_H_
9 #include "mozilla/dom/PWebGLChild.h"
10 #include "mozilla/ipc/BigBuffer.h"
11 #include "mozilla/Maybe.h"
12 #include "mozilla/WeakPtr.h"
14 #include <string>
16 namespace mozilla {
18 class ClientWebGLContext;
20 namespace dom {
22 struct FlushedCmdInfo final {
23 size_t flushes = 0;
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;
30 size_t overhead = 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;
41 public:
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();
49 void Destroy();
50 void ActorDestroy(ActorDestroyReason why) override;
52 FlushedCmdInfo& GetFlushedCmdInfo() { return mFlushedCmdInfo; }
54 private:
55 friend PWebGLChild;
56 virtual ~WebGLChild();
58 public:
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;
64 } // namespace dom
65 } // namespace mozilla
67 #endif // WEBGLCHILD_H_