Line data Source code
1 : /* -*- Mode: C++; tab-width: 20; 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/. */
5 :
6 : #ifndef MOZILLA_GFX_COMPOSITORMANAGERCHILD_H
7 : #define MOZILLA_GFX_COMPOSITORMANAGERCHILD_H
8 :
9 : #include <stddef.h> // for size_t
10 : #include <stdint.h> // for uint32_t, uint64_t
11 : #include "mozilla/Attributes.h" // for override
12 : #include "mozilla/RefPtr.h" // for already_AddRefed
13 : #include "mozilla/StaticPtr.h" // for StaticRefPtr
14 : #include "mozilla/layers/PCompositorManagerChild.h"
15 :
16 : namespace mozilla {
17 : namespace layers {
18 :
19 : class CompositorManagerParent;
20 : class LayerManager;
21 :
22 : class CompositorManagerChild : public PCompositorManagerChild
23 : {
24 9 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositorManagerChild)
25 :
26 : public:
27 : static bool IsInitialized(base::ProcessId aPid);
28 : static bool InitSameProcess(uint32_t aNamespace);
29 : static bool Init(Endpoint<PCompositorManagerChild>&& aEndpoint,
30 : uint32_t aNamespace);
31 : static void Shutdown();
32 :
33 : static bool
34 : CreateContentCompositorBridge(uint32_t aNamespace);
35 :
36 : static already_AddRefed<CompositorBridgeChild>
37 : CreateWidgetCompositorBridge(uint64_t aProcessToken,
38 : LayerManager* aLayerManager,
39 : uint32_t aNamespace,
40 : CSSToLayoutDeviceScale aScale,
41 : const CompositorOptions& aOptions,
42 : bool aUseExternalSurfaceSize,
43 : const gfx::IntSize& aSurfaceSize);
44 :
45 : static already_AddRefed<CompositorBridgeChild>
46 : CreateSameProcessWidgetCompositorBridge(LayerManager* aLayerManager,
47 : uint32_t aNamespace);
48 :
49 : uint32_t GetNextResourceId()
50 : {
51 : return ++mResourceId;
52 : }
53 :
54 : uint32_t GetNamespace() const
55 : {
56 : return mNamespace;
57 : }
58 :
59 : void ActorDestroy(ActorDestroyReason aReason) override;
60 :
61 : void HandleFatalError(const char* aName, const char* aMsg) const override;
62 :
63 : void ProcessingError(Result aCode, const char* aReason) override;
64 :
65 : PCompositorBridgeChild* AllocPCompositorBridgeChild(const CompositorBridgeOptions& aOptions) override;
66 :
67 : bool DeallocPCompositorBridgeChild(PCompositorBridgeChild* aActor) override;
68 :
69 : bool ShouldContinueFromReplyTimeout() override;
70 :
71 : private:
72 : static StaticRefPtr<CompositorManagerChild> sInstance;
73 :
74 : CompositorManagerChild(CompositorManagerParent* aParent,
75 : uint32_t aNamespace);
76 :
77 : CompositorManagerChild(Endpoint<PCompositorManagerChild>&& aEndpoint,
78 : uint32_t aNamespace);
79 :
80 0 : ~CompositorManagerChild() override
81 0 : {
82 0 : }
83 :
84 2 : bool CanSend() const
85 : {
86 2 : MOZ_ASSERT(NS_IsMainThread());
87 2 : return mCanSend;
88 : }
89 :
90 : void DeallocPCompositorManagerChild() override;
91 :
92 : already_AddRefed<nsIEventTarget>
93 : GetSpecificMessageEventTarget(const Message& aMsg) override;
94 :
95 : void SetReplyTimeout();
96 :
97 : bool mCanSend;
98 : uint32_t mNamespace;
99 : uint32_t mResourceId;
100 : };
101 :
102 : } // namespace layers
103 : } // namespace mozilla
104 :
105 : #endif
|