Bug 1754130 - Support presenting a WebGLFramebuffer to its own swap chain without opaque FB. r=aosmond,jgilbert

Most of the support for presenting a WebGLFramebuffer to a swap chain existed as part of the
mechanism for opaque WebXR framebuffer support. However, such "opaque" framebuffer are meant
to be opaque in the sense that their attachments can't be inspected or changed, which does
not provide the requisite level of control for efficiently implementing Canvas2D snapshots.

To this end, the existing Present mechanism is slightly extended to allow presenting to the
swap chain already present in WebGLFramebuffer without the existence of a corresponding
MozFramebuffer.

This also fixes a bug in that AsWebgl() was no longer being utilized in CanvasRenderer, such
that a new mechanism that routed GetFrontBuffer() was needed to fix the code rot.

There are also some efforts to remove a couple redundant copies I noticed in profiles along
the way.

Differential Revision: https://phabricator.services.mozilla.com/D138119
This commit is contained in:
Lee Salzman
2022-02-11 19:49:56 +00:00
parent a84816527a
commit da1e98bca3
15 changed files with 212 additions and 54 deletions

View File

@@ -368,13 +368,7 @@ void ClientWebGLContext::Run(Args&&... args) const {
// ------------------------- Composition, etc -------------------------
void ClientWebGLContext::OnBeforePaintTransaction() {
const RefPtr<layers::ImageBridgeChild> imageBridge =
layers::ImageBridgeChild::GetSingleton();
const auto texType = layers::TexTypeForWebgl(imageBridge);
Present(nullptr, texType);
}
void ClientWebGLContext::OnBeforePaintTransaction() { Present(nullptr); }
void ClientWebGLContext::EndComposition() {
// Mark ourselves as no longer invalidated.
@@ -383,6 +377,15 @@ void ClientWebGLContext::EndComposition() {
// -
void ClientWebGLContext::Present(WebGLFramebufferJS* const xrFb,
const bool webvr) {
const RefPtr<layers::ImageBridgeChild> imageBridge =
layers::ImageBridgeChild::GetSingleton();
const auto texType = layers::TexTypeForWebgl(imageBridge);
Present(xrFb, texType, webvr);
}
void ClientWebGLContext::Present(WebGLFramebufferJS* const xrFb,
const layers::TextureType type,
const bool webvr) {