2021-11-04 19:29:44 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* 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 _include_gfx_ipc_CanvasManagerChild_h__
|
|
|
|
#define _include_gfx_ipc_CanvasManagerChild_h__
|
|
|
|
|
Bug 1736177 - Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika
Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.
This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.
This will be used for Firefox screenshots, New Tab tiles, and printing.
Differential Revision: https://phabricator.services.mozilla.com/D130785
2021-12-10 05:57:55 +03:00
|
|
|
#include "mozilla/Atomics.h"
|
2021-11-04 19:29:44 +03:00
|
|
|
#include "mozilla/gfx/PCanvasManagerChild.h"
|
|
|
|
#include "mozilla/ThreadLocal.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class IPCWorkerRef;
|
|
|
|
class WorkerPrivate;
|
|
|
|
} // namespace dom
|
|
|
|
|
2022-02-02 23:49:23 +03:00
|
|
|
namespace webgpu {
|
|
|
|
class WebGPUChild;
|
|
|
|
} // namespace webgpu
|
|
|
|
|
2021-11-04 19:29:44 +03:00
|
|
|
namespace gfx {
|
Bug 1736177 - Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika
Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.
This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.
This will be used for Firefox screenshots, New Tab tiles, and printing.
Differential Revision: https://phabricator.services.mozilla.com/D130785
2021-12-10 05:57:55 +03:00
|
|
|
class DataSourceSurface;
|
2021-11-04 19:29:44 +03:00
|
|
|
|
|
|
|
class CanvasManagerChild final : public PCanvasManagerChild {
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CanvasManagerChild, override);
|
|
|
|
|
Bug 1736177 - Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika
Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.
This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.
This will be used for Firefox screenshots, New Tab tiles, and printing.
Differential Revision: https://phabricator.services.mozilla.com/D130785
2021-12-10 05:57:55 +03:00
|
|
|
explicit CanvasManagerChild(uint32_t aId);
|
|
|
|
uint32_t Id() const { return mId; }
|
|
|
|
already_AddRefed<DataSourceSurface> GetSnapshot(uint32_t aManagerId,
|
|
|
|
int32_t aProtocolId,
|
|
|
|
bool aHasAlpha);
|
2021-11-04 19:29:44 +03:00
|
|
|
void ActorDestroy(ActorDestroyReason aReason) override;
|
|
|
|
|
|
|
|
static CanvasManagerChild* Get();
|
|
|
|
static void Shutdown();
|
|
|
|
static bool CreateParent(
|
|
|
|
mozilla::ipc::Endpoint<PCanvasManagerParent>&& aEndpoint);
|
|
|
|
|
2022-02-02 23:49:23 +03:00
|
|
|
RefPtr<webgpu::WebGPUChild> GetWebGPUChild();
|
|
|
|
|
2021-11-04 19:29:44 +03:00
|
|
|
private:
|
|
|
|
~CanvasManagerChild();
|
|
|
|
void Destroy();
|
|
|
|
|
|
|
|
RefPtr<mozilla::dom::IPCWorkerRef> mWorkerRef;
|
2022-02-02 23:49:23 +03:00
|
|
|
RefPtr<webgpu::WebGPUChild> mWebGPUChild;
|
Bug 1736177 - Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika
Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.
This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.
This will be used for Firefox screenshots, New Tab tiles, and printing.
Differential Revision: https://phabricator.services.mozilla.com/D130785
2021-12-10 05:57:55 +03:00
|
|
|
const uint32_t mId;
|
2021-11-04 19:29:44 +03:00
|
|
|
|
|
|
|
static MOZ_THREAD_LOCAL(CanvasManagerChild*) sLocalManager;
|
Bug 1736177 - Part 9. Add plumbing to snapshot worker canvas contexts from the main thread. r=jgilbert,ipc-reviewers,nika
Right now, if we wanted to get a snapshot of an OffscreenCanvas context
on a worker thread from the main thread, we would need to block the main
thread on the worker thread, and from the worker thread, issue a sync
IPC call get the front buffer snapshot.
This patch adds an alternative which allows the main thread to go
directly to the canvas owning thread in the compositor process to get
the snapshot, thereby bypassing the worker thread in content process
entirely. All it needs as the unique ID of the CanvasManagerChild
instance, and the protocol ID of the WebGLChild instance.
This will be used for Firefox screenshots, New Tab tiles, and printing.
Differential Revision: https://phabricator.services.mozilla.com/D130785
2021-12-10 05:57:55 +03:00
|
|
|
static Atomic<uint32_t> sNextId;
|
2021-11-04 19:29:44 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gfx
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // _include_gfx_ipc_CanvasManagerChild_h__
|