Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=99: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 : #ifndef include_gfx_ipc_UiCompositorControllerChild_h
7 : #define include_gfx_ipc_UiCompositorControllerChild_h
8 :
9 : #include "mozilla/layers/PUiCompositorControllerChild.h"
10 :
11 : #include "mozilla/gfx/2D.h"
12 : #include "mozilla/Maybe.h"
13 : #include "mozilla/ipc/Shmem.h"
14 : #include "mozilla/layers/UiCompositorControllerParent.h"
15 : #include "mozilla/RefPtr.h"
16 : #include "nsThread.h"
17 :
18 : class nsBaseWidget;
19 :
20 : namespace mozilla {
21 : namespace layers {
22 :
23 : class UiCompositorControllerChild final : protected PUiCompositorControllerChild
24 : {
25 : public:
26 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(UiCompositorControllerChild)
27 :
28 : static RefPtr<UiCompositorControllerChild> CreateForSameProcess(const int64_t& aRootLayerTreeId);
29 : static RefPtr<UiCompositorControllerChild> CreateForGPUProcess(const uint64_t& aProcessToken,
30 : Endpoint<PUiCompositorControllerChild>&& aEndpoint);
31 :
32 : bool Pause();
33 : bool Resume();
34 : bool ResumeAndResize(const int32_t& aHeight, const int32_t& aWidth);
35 : bool InvalidateAndRender();
36 : bool SetMaxToolbarHeight(const int32_t& aHeight);
37 : bool SetPinned(const bool& aPinned, const int32_t& aReason);
38 : bool ToolbarAnimatorMessageFromUI(const int32_t& aMessage);
39 : bool SetDefaultClearColor(const uint32_t& aColor);
40 : bool RequestScreenPixels();
41 : bool EnableLayerUpdateNotifications(const bool& aEnable);
42 : bool ToolbarPixelsToCompositor(Shmem& aMem, const ScreenIntSize& aSize);
43 :
44 : void Destroy();
45 :
46 : void SetBaseWidget(nsBaseWidget* aWidget);
47 : bool AllocPixelBuffer(const int32_t aSize, Shmem* aMem);
48 : bool DeallocPixelBuffer(Shmem& aMem);
49 :
50 : protected:
51 : void ActorDestroy(ActorDestroyReason aWhy) override;
52 : void DeallocPUiCompositorControllerChild() override;
53 : void ProcessingError(Result aCode, const char* aReason) override;
54 : virtual void HandleFatalError(const char* aName, const char* aMsg) const override;
55 : mozilla::ipc::IPCResult RecvToolbarAnimatorMessageFromCompositor(const int32_t& aMessage) override;
56 : mozilla::ipc::IPCResult RecvRootFrameMetrics(const ScreenPoint& aScrollOffset, const CSSToScreenScale& aZoom) override;
57 : mozilla::ipc::IPCResult RecvScreenPixels(ipc::Shmem&& aMem, const ScreenIntSize& aSize) override;
58 : private:
59 : explicit UiCompositorControllerChild(const uint64_t& aProcessToken);
60 : ~UiCompositorControllerChild();
61 : void OpenForSameProcess();
62 : void OpenForGPUProcess(Endpoint<PUiCompositorControllerChild>&& aEndpoint);
63 : void SendCachedValues();
64 :
65 : bool mIsOpen;
66 : uint64_t mProcessToken;
67 : Maybe<gfx::IntSize> mResize;
68 : Maybe<int32_t> mMaxToolbarHeight;
69 : Maybe<uint32_t> mDefaultClearColor;
70 : Maybe<bool> mLayerUpdateEnabled;
71 : nsBaseWidget* mWidget;
72 : // Should only be set when compositor is in process.
73 : RefPtr<UiCompositorControllerParent> mParent;
74 : };
75 :
76 : } // namespace layers
77 : } // namespace mozilla
78 :
79 : #endif // include_gfx_ipc_UiCompositorControllerChild_h
|