/* -*- 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/. */
#include"mozilla/gfx/Point.h"// for IntSize #include"mozilla/gfx/Types.h"// for SurfaceFormat #include"mozilla/ipc/Shmem.h" #include"mozilla/layers/CompositorTypes.h"// for TextureFlags, etc #include"mozilla/layers/LayersSurfaces.h"// for SurfaceDescriptor #include"mozilla/layers/TextureHost.h" #include"mozilla/Monitor.h" #include"mozilla/StaticPtr.h" #include"mozilla/ThreadSafeWeakPtr.h" #include"mozilla/UniquePtr.h" #include"mozilla/webrender/WebRenderTypes.h"
class nsISerialEventTarget;
namespace mozilla {
namespace ipc { class IProtocol;
}
namespace gl { class SharedSurface;
}
namespace webgpu { class ExternalTexture;
}
namespace layers {
class CompositableHost; class RemoteTextureHostWrapper; class TextureData; class TextureHost;
/** * RemoteTextureTxnScheduler manages dependencies on transaction numbers for a * given top-level protocol ("type"). It expects that transaction numbers are * all sequenced and comparable for this top-level protocol. Dependencies may * then be issued on a given future transaction number. Clients must notify the * scheduler when transactions are completed, so that any dependencies can be * cleared as the transaction number advances. Generally, transaction numbers * will be generated by a FwdTransactionCounter on a top-level protocol child, * and there should be a RemoteTextureTxnScheduler instantiated on the top-level * protocol parent that corresponds to the same protocol lifetime as the child. * To ease sharing in sub-protocols, RemoteTextureTxnScheduler is ref-counted * and may be multiply-registered by the various sub-protocols that derive from * a given top-level protocol, without having to directly refer to the original * top-level protocol.
*/ class RemoteTextureTxnScheduler final { public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteTextureTxnScheduler)
/** * A class provides API for remote texture owners.
*/ class RemoteTextureOwnerClient final { public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RemoteTextureOwnerClient)
/** * A class to map RemoteTextureId to remote texture(TextureHost). * Remote textures are provided by texture owner.
*/ class RemoteTextureMap { public: staticvoid Init(); staticvoid Shutdown(); static RemoteTextureMap* Get() { return sInstance; }
RemoteTextureMap();
~RemoteTextureMap();
// Push remote texture data and gl::SharedSurface from texture owner. // The texture data is used for creating TextureHost. // gl::SharedSurface is pushed only when the surface needs to be kept alive // during TextureHost usage. The texture data and the surface might be // recycled when TextureHost is destroyed. void PushTexture(const RemoteTextureId aTextureId, const RemoteTextureOwnerId aOwnerId, const base::ProcessId aForPid,
UniquePtr<TextureData>&& aTextureData,
RefPtr<TextureHost>& aTextureHost,
UniquePtr<SharedResourceWrapper>&& aResourceWrapper);
// Remove waiting texture that will not be used. bool RemoveTexture(const RemoteTextureId aTextureId, const RemoteTextureOwnerId aOwnerId, const base::ProcessId aForPid);
// Holds data related to remote texture struct TextureDataHolder {
TextureDataHolder(const RemoteTextureId aTextureId,
RefPtr<TextureHost> aTextureHost,
UniquePtr<TextureData>&& aTextureData,
UniquePtr<SharedResourceWrapper>&& aResourceWrapper);
const RemoteTextureId mTextureId; // TextureHost of remote texture // Compositable ref of the mTextureHost should be updated within mMonitor. // The compositable ref is used to check if TextureHost(remote texture) is // still in use by WebRender.
RefPtr<TextureHost> mTextureHost; // Holds BufferTextureData of TextureHost
UniquePtr<TextureData> mTextureData; // Holds gl::SharedSurface of TextureHost
UniquePtr<SharedResourceWrapper> mResourceWrapper;
};
struct TextureOwner { bool mIsContextLost = false; // Whether to wait for a transaction to complete before unregistering. bool mWaitForTxn = false; // The thread on which to finally unregister when ready.
RefPtr<nsISerialEventTarget> mDeferUnregister;
// Holds TextureDataHolders that wait to be used for building wr display // list.
std::deque<UniquePtr<TextureDataHolder>> mWaitingTextureDataHolders; // Holds TextureDataHolders that are used for building wr display list.
std::deque<UniquePtr<TextureDataHolder>> mUsingTextureDataHolders;
std::deque<UniquePtr<TextureDataHolder>> mReleasingTextureDataHolders; // Holds RemoteTexture ready callbacks.
std::deque<UniquePtr<RenderingReadyCallbackHolder>>
mRenderingReadyCallbackHolders;
RemoteTextureId mLatestPushedTextureId = {0};
RemoteTextureId mLatestUsingTextureId = {0};
CompositableTextureHostRef mLatestTextureHost;
CompositableTextureHostRef mLatestRenderedTextureHost; // Holds compositable refs to TextureHosts of RenderTextureHosts that are // waiting to be released in non-RenderThread.
std::deque<CompositableTextureHostRef> mReleasingRenderedTextureHosts;
RefPtr<RemoteTextureRecycleBin> mRecycleBin;
};
// Holds data related to remote texture wrapper struct RemoteTextureHostWrapperHolder { explicit RemoteTextureHostWrapperHolder(
RefPtr<TextureHost> aRemoteTextureHostWrapper);
const RefPtr<TextureHost> mRemoteTextureHostWrapper; // Hold compositable ref of remote texture of the RemoteTextureId.
CompositableTextureHostRef mRemoteTextureHost; bool mReadyCheckSuppressed = false;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.