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 ExternalTexture_H_
7 #define ExternalTexture_H_
9 #include "mozilla/gfx/Point.h"
10 #include "mozilla/layers/LayersSurfaces.h"
11 #include "mozilla/webgpu/ffi/wgpu.h"
21 // A texture that can be used by the WebGPU implementation but is created and
23 class ExternalTexture
{
25 static UniquePtr
<ExternalTexture
> Create(
26 const uint32_t aWidth
, const uint32_t aHeight
,
27 const struct ffi::WGPUTextureFormat aFormat
,
28 const ffi::WGPUTextureUsages aUsage
);
30 ExternalTexture(const uint32_t aWidth
, const uint32_t aHeight
,
31 const struct ffi::WGPUTextureFormat aFormat
,
32 const ffi::WGPUTextureUsages aUsage
);
33 virtual ~ExternalTexture();
35 virtual void* GetExternalTextureHandle() { return nullptr; }
37 virtual Maybe
<layers::SurfaceDescriptor
> ToSurfaceDescriptor(
38 Maybe
<gfx::FenceInfo
>& aFenceInfo
) = 0;
40 virtual void GetSnapshot(const ipc::Shmem
& aDestShmem
,
41 const gfx::IntSize
& aSize
) {}
43 gfx::IntSize
GetSize() { return gfx::IntSize(mWidth
, mHeight
); }
45 void SetSubmissionIndex(uint64_t aSubmissionIndex
);
46 uint64_t GetSubmissionIndex() const { return mSubmissionIndex
; }
48 const uint32_t mWidth
;
49 const uint32_t mHeight
;
50 const struct ffi::WGPUTextureFormat mFormat
;
51 const ffi::WGPUTextureUsages mUsage
;
54 uint64_t mSubmissionIndex
= 0;
58 } // namespace mozilla
60 #endif // GPU_ExternalTexture_H_