SharedTextureMacIOSurface.h (1804B)
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_SharedTextureMacIOSurface_H_ 7 #define GPU_SharedTextureMacIOSurface_H_ 8 9 #include "mozilla/WeakPtr.h" 10 #include "mozilla/gfx/FileHandleWrapper.h" 11 #include "mozilla/webgpu/SharedTexture.h" 12 13 class MacIOSurface; 14 15 namespace mozilla { 16 17 namespace webgpu { 18 19 class SharedTextureMacIOSurface final : public SharedTexture { 20 public: 21 static UniquePtr<SharedTextureMacIOSurface> Create( 22 WebGPUParent* aParent, const ffi::WGPUDeviceId aDeviceId, 23 const uint32_t aWidth, const uint32_t aHeight, 24 const struct ffi::WGPUTextureFormat aFormat, 25 const ffi::WGPUTextureUsages aUsage); 26 27 SharedTextureMacIOSurface(WebGPUParent* aParent, 28 const ffi::WGPUDeviceId aDeviceId, 29 const uint32_t aWidth, const uint32_t aHeight, 30 const struct ffi::WGPUTextureFormat aFormat, 31 const ffi::WGPUTextureUsages aUsage, 32 RefPtr<MacIOSurface>&& aSurface); 33 virtual ~SharedTextureMacIOSurface(); 34 35 Maybe<layers::SurfaceDescriptor> ToSurfaceDescriptor() override; 36 37 void GetSnapshot(const ipc::Shmem& aDestShmem, 38 const gfx::IntSize& aSize) override; 39 40 SharedTextureMacIOSurface* AsSharedTextureMacIOSurface() override { 41 return this; 42 } 43 44 uint32_t GetIOSurfaceId(); 45 46 protected: 47 const WeakPtr<WebGPUParent> mParent; 48 const RawId mDeviceId; 49 const RefPtr<MacIOSurface> mSurface; 50 }; 51 52 } // namespace webgpu 53 } // namespace mozilla 54 55 #endif // GPU_Texture_H_