TextureForwarder.h (2899B)
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/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" 19 20 namespace mozilla { 21 namespace layers { 22 class CanvasChild; 23 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. 27 */ 28 class LayersIPCActor { 29 public: 30 virtual bool IPCOpen() const { return true; } 31 }; 32 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. 38 */ 39 class LayersIPCChannel : public LayersIPCActor, 40 public mozilla::ipc::IShmemAllocator { 41 public: 42 NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING 43 44 virtual bool IsSameProcess() const = 0; 45 46 virtual bool UsesImageBridge() const { return false; } 47 48 virtual base::ProcessId GetParentPid() const = 0; 49 50 virtual nsISerialEventTarget* GetThread() const = 0; 51 52 virtual FixedSizeSmallShmemSectionAllocator* GetTileLockAllocator() { 53 return nullptr; 54 } 55 56 virtual void CancelWaitForNotifyNotUsed(uint64_t aTextureId) = 0; 57 58 virtual wr::MaybeExternalImageId GetNextExternalImageId() { 59 return Nothing(); 60 } 61 62 protected: 63 virtual ~LayersIPCChannel() = default; 64 }; 65 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. 70 */ 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. 76 */ 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; 82 83 /** 84 * Returns the CanvasChild for this TextureForwarder. 85 */ 86 virtual already_AddRefed<CanvasChild> GetCanvasChild() { return nullptr; }; 87 }; 88 89 } // namespace layers 90 } // namespace mozilla 91 92 #endif