SharedTextureD3D11.h (1892B)
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #ifndef GPU_SharedTextureD3D11_H_ 7 #define GPU_SharedTextureD3D11_H_ 8 9 #include "mozilla/gfx/FileHandleWrapper.h" 10 #include "mozilla/webgpu/SharedTexture.h" 11 12 struct ID3D11Texture2D; 13 14 namespace mozilla { 15 16 namespace layers { 17 class FenceD3D11; 18 } // namespace layers 19 20 namespace webgpu { 21 22 class SharedTextureD3D11 final : public SharedTexture { 23 public: 24 static UniquePtr<SharedTextureD3D11> Create( 25 WebGPUParent* aParent, const ffi::WGPUDeviceId aDeviceId, 26 const uint32_t aWidth, const uint32_t aHeight, 27 const struct ffi::WGPUTextureFormat aFormat, 28 const ffi::WGPUTextureUsages aUsage); 29 30 SharedTextureD3D11( 31 const uint32_t aWidth, const uint32_t aHeight, 32 const struct ffi::WGPUTextureFormat aFormat, 33 const ffi::WGPUTextureUsages aUsage, 34 const RefPtr<ID3D11Texture2D> aTexture, 35 RefPtr<gfx::FileHandleWrapper>&& aSharedHandle, 36 const layers::CompositeProcessFencesHolderId aFencesHolderId, 37 RefPtr<layers::FenceD3D11>&& aWriteFence); 38 virtual ~SharedTextureD3D11(); 39 40 void* GetSharedTextureHandle(); 41 42 Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override; 43 44 void GetSnapshot(const ipc::Shmem& aDestShmem, 45 const gfx::IntSize& aSize) override; 46 47 SharedTextureD3D11* AsSharedTextureD3D11() override { return this; } 48 49 protected: 50 const RefPtr<ID3D11Texture2D> mTexture; 51 const RefPtr<gfx::FileHandleWrapper> mSharedHandle; 52 const layers::CompositeProcessFencesHolderId mFencesHolderId; 53 const RefPtr<layers::FenceD3D11> mWriteFence; 54 }; 55 56 } // namespace webgpu 57 } // namespace mozilla 58 59 #endif // GPU_Texture_H_