no bug - Import translations from android-l10n r=release a=l10n CLOSED TREE
[gecko.git] / gfx / layers / ipc / TextureForwarder.h
blobaf843901430af429e198fc1d26cd88beb65cc5e8
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
11 #include "gfxTypes.h"
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"
20 namespace mozilla {
21 namespace layers {
22 class CanvasChild;
24 /**
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 {
29 public:
30 virtual bool IPCOpen() const { return true; }
33 /**
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
37 * shmem.
39 class LayersIPCChannel : public LayersIPCActor,
40 public mozilla::ipc::IShmemAllocator {
41 public:
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() {
53 return nullptr;
56 virtual void CancelWaitForNotifyNotUsed(uint64_t aTextureId) = 0;
58 virtual wr::MaybeExternalImageId GetNextExternalImageId() {
59 return Nothing();
62 protected:
63 virtual ~LayersIPCChannel() = default;
66 /**
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 {
72 public:
73 /**
74 * Create a TextureChild/Parent pair as as well as the TextureHost on the
75 * parent side.
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;
83 /**
84 * Returns the CanvasChild for this TextureForwarder.
86 virtual already_AddRefed<CanvasChild> GetCanvasChild() { return nullptr; };
89 } // namespace layers
90 } // namespace mozilla
92 #endif