gecko-dev/gfx/layers/ShareableCanvasRenderer.h
sotaro 02d18ed8c1 Bug 1776885 - Add capability of async remote texture on WebGL if CanvasRenderThread is used r=gfx-reviewers,lsalzman
The remote texture is processed asynchronously, but the WebGL rendering results are rendered synchronously with WebRender transaction by WebRender.

Async remote texture support is enabled only when CanvasRenderThread is used. This is to simplify implementation.

In async mode, remote texture of current RemoteTextureId might not be created yet when WebRenderImageHost::UseRemoteTexture() is called. In this case, RemoteTextureHostWrapper uses its own external image ID, otherwise the RemoteTextureHostWrapper uses compatible old remote texture for creating wr display list. RenderTextureHostWrapper calls RemoteTextureMap::GetExternalImageIdOfRemoteTextureSync() before is ussage. The GetExternalImageIdOfRemoteTextureSync() synchronously waits until remote texture becomes ready. The wait works since WebGL IPC handling is always done in CanvasRenderThread in async mode.

PWebGLChild::SendGetFrontBuffer() triggers sync IPC. It is called to ensure the compatible remote texture in RemoteTextureMap during RemoteTextureMap::GetRemoteTextureForDisplayList() call.

Differential Revision: https://phabricator.services.mozilla.com/D162971
2022-12-07 02:24:57 +00:00

64 lines
1.6 KiB
C++

/* -*- 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 GFX_SHAREABLECANVASRENDERER_H
#define GFX_SHAREABLECANVASRENDERER_H
#include "CompositorTypes.h"
#include "CanvasRenderer.h"
#include "mozilla/layers/CanvasClient.h"
namespace mozilla {
namespace gl {
class SurfaceFactory;
} // namespace gl
namespace gfx {
class DrawTarget;
} // namespace gfx
namespace layers {
class ShareableCanvasRenderer : public CanvasRenderer {
friend class CanvasClient2D;
friend class CanvasClientSharedSurface;
protected:
RefPtr<CanvasClient> mCanvasClient;
private:
layers::SurfaceDescriptor mFrontBufferDesc;
RefPtr<TextureClient> mFrontBufferFromDesc;
public:
ShareableCanvasRenderer();
virtual ~ShareableCanvasRenderer();
public:
void Initialize(const CanvasRendererData&) override;
virtual CompositableForwarder* GetForwarder() = 0;
virtual bool CreateCompositable() = 0;
virtual void EnsurePipeline() = 0;
void ClearCachedResources() override;
void DisconnectClient() override;
void UpdateCompositableClient();
CanvasClient* GetCanvasClient() { return mCanvasClient; }
private:
RefPtr<TextureClient> GetFrontBufferFromDesc(const layers::SurfaceDescriptor&,
TextureFlags);
};
} // namespace layers
} // namespace mozilla
#endif