1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_LAYERS_TEXTUREFORWARDER
8 #define MOZILLA_LAYERS_TEXTUREFORWARDER
10 #include <stdint.h> // for int32_t, uint64_t
12 #include "mozilla/dom/ipc/IdType.h"
13 #include "mozilla/ipc/ProtocolUtils.h"
14 #include "mozilla/layers/LayersMessages.h" // for Edit, etc
15 #include "mozilla/layers/LayersTypes.h" // for LayersBackend
16 #include "mozilla/layers/TextureClient.h" // for TextureClient
17 #include "mozilla/layers/KnowsCompositor.h"
18 #include "nsISerialEventTarget.h"
25 * An abstract interface for classes that implement the autogenerated
26 * IPDL actor class. Lets us check if they are still valid for IPC.
28 class LayersIPCActor
{
30 virtual bool IPCOpen() const { return true; }
34 * An abstract interface for LayersIPCActors that implement a top-level
35 * IPDL protocol so also have their own channel.
36 * Has their own MessageLoop for message dispatch, and can allocate
39 class LayersIPCChannel
: public LayersIPCActor
,
40 public mozilla::ipc::IShmemAllocator
{
42 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
44 virtual bool IsSameProcess() const = 0;
46 virtual bool UsesImageBridge() const { return false; }
48 virtual base::ProcessId
GetParentPid() const = 0;
50 virtual nsISerialEventTarget
* GetThread() const = 0;
52 virtual FixedSizeSmallShmemSectionAllocator
* GetTileLockAllocator() {
56 virtual void CancelWaitForNotifyNotUsed(uint64_t aTextureId
) = 0;
58 virtual wr::MaybeExternalImageId
GetNextExternalImageId() {
63 virtual ~LayersIPCChannel() = default;
67 * An abstract interface for classes that can allocate PTexture objects
68 * across IPDL. Currently a sub-class of LayersIPCChannel for simplicity
69 * since all our implementations use both, but could be independant if needed.
71 class TextureForwarder
: public LayersIPCChannel
{
74 * Create a TextureChild/Parent pair as as well as the TextureHost on the
77 virtual PTextureChild
* CreateTexture(
78 const SurfaceDescriptor
& aSharedData
, ReadLockDescriptor
&& aReadLock
,
79 LayersBackend aLayersBackend
, TextureFlags aFlags
,
80 const dom::ContentParentId
& aContentId
, uint64_t aSerial
,
81 wr::MaybeExternalImageId
& aExternalImageId
) = 0;
84 * Returns the CanvasChild for this TextureForwarder.
86 virtual already_AddRefed
<CanvasChild
> GetCanvasChild() { return nullptr; };
90 } // namespace mozilla