Line data Source code
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/. */
6 :
7 : #ifndef MOZILLA_LAYERS_TEXTUREFORWARDER
8 : #define MOZILLA_LAYERS_TEXTUREFORWARDER
9 :
10 : #include <stdint.h> // for int32_t, uint64_t
11 : #include "gfxTypes.h"
12 : #include "mozilla/layers/LayersTypes.h" // for LayersBackend
13 : #include "mozilla/layers/TextureClient.h" // for TextureClient
14 : #include "mozilla/layers/KnowsCompositor.h"
15 :
16 : namespace mozilla {
17 : namespace ipc {
18 : class IShmemAllocator;
19 : }
20 : namespace layers {
21 :
22 : /**
23 : * An abstract interface for classes that implement the autogenerated
24 : * IPDL actor class. Lets us check if they are still valid for IPC.
25 : */
26 11 : class LayersIPCActor {
27 : public:
28 0 : virtual bool IPCOpen() const { return true; }
29 : };
30 :
31 : /**
32 : * An abstract interface for LayersIPCActors that implement a top-level
33 : * IPDL protocol so also have their own channel.
34 : * Has their own MessageLoop for message dispatch, and can allocate
35 : * shmem.
36 : */
37 9 : class LayersIPCChannel : public LayersIPCActor
38 : , public mozilla::ipc::IShmemAllocator {
39 : public:
40 : NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
41 :
42 : virtual bool IsSameProcess() const = 0;
43 :
44 106 : virtual bool UsesImageBridge() const { return false; }
45 :
46 : virtual base::ProcessId GetParentPid() const = 0;
47 :
48 : virtual MessageLoop* GetMessageLoop() const = 0;
49 :
50 0 : virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() { return nullptr; }
51 :
52 : virtual void CancelWaitForRecycle(uint64_t aTextureId) = 0;
53 :
54 0 : virtual wr::MaybeExternalImageId GetNextExternalImageId() { return Nothing(); }
55 :
56 : protected:
57 0 : virtual ~LayersIPCChannel() {}
58 : };
59 :
60 : /**
61 : * An abstract interface for classes that can allocate PTexture objects
62 : * across IPDL. Currently a sub-class of LayersIPCChannel for simplicity
63 : * since all our implementations use both, but could be independant if needed.
64 : */
65 9 : class TextureForwarder : public LayersIPCChannel {
66 : public:
67 : /**
68 : * Create a TextureChild/Parent pair as as well as the TextureHost on the parent side.
69 : */
70 : virtual PTextureChild* CreateTexture(
71 : const SurfaceDescriptor& aSharedData,
72 : LayersBackend aLayersBackend,
73 : TextureFlags aFlags,
74 : uint64_t aSerial,
75 : wr::MaybeExternalImageId& aExternalImageId,
76 : nsIEventTarget* aTarget = nullptr) = 0;
77 : };
78 :
79 : } // namespace layers
80 : } // namespace mozilla
81 :
82 : #endif
|