gecko-dev/widget/android/CompositorWidgetChild.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 строки
1.4 KiB
C
Исходник Обычный вид История

Bug 1741156 - Initial GPU process implementation on Android. r=aosmond,agi Declare a GPU process and corresponding Service in the AndroidManifest. This is of a new class GeckoServiceGpuProcess which inherits from GeckoServiceChildProcess, and provides a binder interface ICompositorSurfaceManager which allows the parent process to set the compositor Surface for a given widget ID, and the compositor in the GPU process to look up the Surface for a widget ID. The ICompositorSurfaceManager interface is exposed to the parent process through a new method getCompositorSurfaceManager() in the IChildProcess interface. Add a new connection type for GPU processes to GeckoProcessManager, along with a function to look up the GPU process connection and fetch the ICompositorSurfaceManager binder. When the GPU process is launched we store the returned binder in the GPUProcessHost, and when each widget's compositor is created we store a reference to the binder in the UiCompositorControllerChild. Each nsWindow is given a unique ID, and whenever the Surface changes due to an Android resume event, it sends the new surface for that ID to the GPU process (if enabled) by calling ICompositorSurfaceManager.onSurfaceChanged(). Stop inheriting AndroidCompositorWidget from InProcessCompositorWidget and instead inherit from CompositorWidget directly. This class holds a reference to the Surface that will be rendered in to. The CompositorBridgeParent notifies the CompositorWidget whenever it has been resumed, allowing it to fetch the new Surface. For the cross-process CompositorWidgetParent implementation it fetches that Surface from the CompositorSurfaceManagerService, whereas the InProcessAndroidCompositorWidget can read it directly from the real widget. AndroidCompositorWidget::GetClientSize() can now calculate its size from the Surface, rather than racily reading the value from the nsWindow. This means RenderCompositorEGL and RenderCompositorOGLSWGL can now use GetClientSize() again rather than querying their own size from the Surface. With this patch, setting layers.gpu-process.enabled to true will cause us to launch a GPU process and render from it. We do not yet gracefully recover from a GPU process crash, nor can we render anything using SurfaceTextures (eg video or webgl). Those will come in future patches. Differential Revision: https://phabricator.services.mozilla.com/D131231
2021-11-29 23:52:31 +03:00
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef widget_android_CompositorWidgetChild_h
#define widget_android_CompositorWidgetChild_h
#include "AndroidCompositorWidget.h"
#include "mozilla/widget/PCompositorWidgetChild.h"
#include "mozilla/widget/CompositorWidgetVsyncObserver.h"
namespace mozilla {
namespace widget {
class CompositorWidgetChild final : public PCompositorWidgetChild,
public PlatformCompositorWidgetDelegate {
public:
CompositorWidgetChild(RefPtr<CompositorVsyncDispatcher> aVsyncDispatcher,
RefPtr<CompositorWidgetVsyncObserver> aVsyncObserver,
const CompositorWidgetInitData&);
~CompositorWidgetChild() override;
bool Initialize();
mozilla::ipc::IPCResult RecvObserveVsync() override;
mozilla::ipc::IPCResult RecvUnobserveVsync() override;
Bug 1766127 - Allow AndroidCompositorWidget::mClientSize to be updated from main thread. r=agi,gfx-reviewers,lsalzman On Android we have long since calculated the compositor widget size from the Surface rather than using the main thread widget size. This is to avoid a trip via the main thread in response to a ResumeAndResize event on the UI thread. AndroidCompositorWidget::mClientSize therefore gets calculated when the compositor is resumed. However, it is possible in some circumstances for the compositor to receive a display list prior to it being resumed. In this bug's case, SyncResumeAndResize is getting called before the UI thread has been notified that the compositor has been initialized. It therefore cannot resume the compositor, and we instead resume the compositor on the subsequent NotifyCompositorCreated call. This starts a race between the main thread paint and NotifyCompositorCreated being scheduled on the UI thread then resuming the compositor via PUiCompositorController. If we receive WebRenderBridgeParent::RecvSetDisplayList prior to UiCompositorControllerParent::RecvResumeAndResize, then AndroidCompositorWidget::mClientSize will be zero. This results in us setting zero-sized webrender scene rect, leading to webrender exiting early during rendering, resulting in a black screen. To fix this, allow the main thread to set the AndroidCompositorWidget size, in addition to the UI thread being able to set it. We do so by adding a NotifyClientSizeChanged method to PlatformCompositorWidgetDelegate, called from nsWindow::OnSizeChanged. The cross-process implementation of this uses an IPDL call on PCompositorWidget, which shares a top-level protocol with PWebRenderBridge, meaning calls are guaranteed to occur in order. This means a resize event on the main thread is guaranteed to set the CompositorWidget size before the display list from the subsequent paint is received. Differential Revision: https://phabricator.services.mozilla.com/D144594
2022-04-25 21:20:55 +03:00
// PlatformCompositorWidgetDelegate overrides
void NotifyClientSizeChanged(const LayoutDeviceIntSize& aClientSize) override;
Bug 1741156 - Initial GPU process implementation on Android. r=aosmond,agi Declare a GPU process and corresponding Service in the AndroidManifest. This is of a new class GeckoServiceGpuProcess which inherits from GeckoServiceChildProcess, and provides a binder interface ICompositorSurfaceManager which allows the parent process to set the compositor Surface for a given widget ID, and the compositor in the GPU process to look up the Surface for a widget ID. The ICompositorSurfaceManager interface is exposed to the parent process through a new method getCompositorSurfaceManager() in the IChildProcess interface. Add a new connection type for GPU processes to GeckoProcessManager, along with a function to look up the GPU process connection and fetch the ICompositorSurfaceManager binder. When the GPU process is launched we store the returned binder in the GPUProcessHost, and when each widget's compositor is created we store a reference to the binder in the UiCompositorControllerChild. Each nsWindow is given a unique ID, and whenever the Surface changes due to an Android resume event, it sends the new surface for that ID to the GPU process (if enabled) by calling ICompositorSurfaceManager.onSurfaceChanged(). Stop inheriting AndroidCompositorWidget from InProcessCompositorWidget and instead inherit from CompositorWidget directly. This class holds a reference to the Surface that will be rendered in to. The CompositorBridgeParent notifies the CompositorWidget whenever it has been resumed, allowing it to fetch the new Surface. For the cross-process CompositorWidgetParent implementation it fetches that Surface from the CompositorSurfaceManagerService, whereas the InProcessAndroidCompositorWidget can read it directly from the real widget. AndroidCompositorWidget::GetClientSize() can now calculate its size from the Surface, rather than racily reading the value from the nsWindow. This means RenderCompositorEGL and RenderCompositorOGLSWGL can now use GetClientSize() again rather than querying their own size from the Surface. With this patch, setting layers.gpu-process.enabled to true will cause us to launch a GPU process and render from it. We do not yet gracefully recover from a GPU process crash, nor can we render anything using SurfaceTextures (eg video or webgl). Those will come in future patches. Differential Revision: https://phabricator.services.mozilla.com/D131231
2021-11-29 23:52:31 +03:00
private:
RefPtr<CompositorVsyncDispatcher> mVsyncDispatcher;
RefPtr<CompositorWidgetVsyncObserver> mVsyncObserver;
};
} // namespace widget
} // namespace mozilla
#endif // widget_android_CompositorWidgetChild_h