Bug 1798703 - Enforce alignment for UniformData via union rather than overalignment...
[gecko.git] / dom / canvas / WebGLChild.h
blobd5995045e3a510eb2dc9b80600c09138a5863679
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/WeakPtr.h"
12 #include <string>
14 namespace mozilla {
16 class ClientWebGLContext;
18 namespace dom {
20 struct FlushedCmdInfo final {
21 size_t flushes = 0;
22 size_t flushedCmdBytes = 0;
23 size_t overhead = 0;
26 class WebGLChild final : public PWebGLChild, public SupportsWeakPtr {
27 const WeakPtr<ClientWebGLContext> mContext;
28 const size_t mDefaultCmdsShmemSize;
29 webgl::RaiiShmem mPendingCmdsShmem;
30 size_t mPendingCmdsPos = 0;
31 size_t mPendingCmdsAlignmentOverhead = 0;
32 FlushedCmdInfo mFlushedCmdInfo;
34 public:
35 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(WebGLChild, override);
37 explicit WebGLChild(ClientWebGLContext&);
39 Maybe<Range<uint8_t>> AllocPendingCmdBytes(size_t,
40 size_t fyiAlignmentOverhead);
41 void FlushPendingCmds();
42 void ActorDestroy(ActorDestroyReason why) override;
44 private:
45 friend PWebGLChild;
46 virtual ~WebGLChild();
48 public:
49 mozilla::ipc::IPCResult RecvJsWarning(const std::string&) const;
50 mozilla::ipc::IPCResult RecvOnContextLoss(webgl::ContextLossReason) const;
53 } // namespace dom
54 } // namespace mozilla
56 #endif // WEBGLCHILD_H_