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/. */
6 #ifndef GPU_ExternalTextureDMABuf_H_
7 #define GPU_ExternalTextureDMABuf_H_
9 #include "mozilla/gfx/FileHandleWrapper.h"
10 #include "mozilla/webgpu/ExternalTexture.h"
18 class ExternalTextureDMABuf final
: public ExternalTexture
{
20 static UniquePtr
<ExternalTextureDMABuf
> Create(
21 const ffi::WGPUGlobal
* aContext
, const ffi::WGPUDeviceId aDeviceId
,
22 const uint32_t aWidth
, const uint32_t aHeight
,
23 const struct ffi::WGPUTextureFormat aFormat
,
24 const ffi::WGPUTextureUsages aUsage
);
26 ExternalTextureDMABuf(
27 UniquePtr
<ffi::WGPUVkImageHandle
>&& aVkImageHandle
, const uint32_t aWidth
,
28 const uint32_t aHeight
, const struct ffi::WGPUTextureFormat aFormat
,
29 const ffi::WGPUTextureUsages aUsage
, RefPtr
<DMABufSurface
>&& aSurface
,
30 const layers::SurfaceDescriptorDMABuf
& aSurfaceDescriptor
);
31 virtual ~ExternalTextureDMABuf();
33 void* GetExternalTextureHandle() override
;
35 Maybe
<layers::SurfaceDescriptor
> ToSurfaceDescriptor(
36 Maybe
<gfx::FenceInfo
>& aFenceInfo
) override
;
38 void GetSnapshot(const ipc::Shmem
& aDestShmem
,
39 const gfx::IntSize
& aSize
) override
;
41 ExternalTextureDMABuf
* AsExternalTextureDMABuf() override
{ return this; }
43 UniqueFileHandle
CloneDmaBufFd();
45 ffi::WGPUVkImageHandle
* GetHandle() { return mVkImageHandle
.get(); }
48 UniquePtr
<ffi::WGPUVkImageHandle
> mVkImageHandle
;
49 RefPtr
<DMABufSurface
> mSurface
;
50 const layers::SurfaceDescriptorDMABuf mSurfaceDescriptor
;
54 } // namespace mozilla
56 #endif // GPU_Texture_H_