tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

wgpu.h (2165B)


      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 WGPU_h
      8 #define WGPU_h
      9 
     10 // We have to include nsString.h before wgpu_ffi_generated.h because the
     11 // latter is wrapped in an extern "C" declaration but ends up including
     12 // nsString.h (See bug 1784086)
     13 #include "nsString.h"
     14 
     15 // Prelude of types necessary before including wgpu_ffi_generated.h
     16 namespace mozilla {
     17 namespace ipc {
     18 class ByteBuf;
     19 }  // namespace ipc
     20 namespace webgpu {
     21 namespace ffi {
     22 
     23 #define WGPU_INLINE
     24 #define WGPU_FUNC
     25 
     26 extern "C" {
     27 #include "mozilla/webgpu/ffi/wgpu_ffi_generated.h"
     28 }
     29 
     30 #undef WGPU_INLINE
     31 #undef WGPU_FUNC
     32 
     33 }  // namespace ffi
     34 
     35 inline ffi::WGPUByteBuf* ToFFI(mozilla::ipc::ByteBuf* x) {
     36  return reinterpret_cast<ffi::WGPUByteBuf*>(x);
     37 }
     38 inline const ffi::WGPUByteBuf* ToFFI(const mozilla::ipc::ByteBuf* x) {
     39  return reinterpret_cast<const ffi::WGPUByteBuf*>(x);
     40 }
     41 inline mozilla::ipc::ByteBuf* FromFFI(ffi::WGPUByteBuf* x) {
     42  return reinterpret_cast<mozilla::ipc::ByteBuf*>(x);
     43 }
     44 inline const mozilla::ipc::ByteBuf* FromFFI(const ffi::WGPUByteBuf* x) {
     45  return reinterpret_cast<const mozilla::ipc::ByteBuf*>(x);
     46 }
     47 
     48 }  // namespace webgpu
     49 
     50 }  // namespace mozilla
     51 
     52 namespace std {
     53 template <>
     54 struct default_delete<mozilla::webgpu::ffi::WGPUClient> {
     55 public:
     56  void operator()(mozilla::webgpu::ffi::WGPUClient* aPtr) const {
     57    mozilla::webgpu::ffi::wgpu_client_delete(aPtr);
     58  }
     59 };
     60 
     61 template <>
     62 struct default_delete<mozilla::webgpu::ffi::WGPUGlobal> {
     63 public:
     64  void operator()(mozilla::webgpu::ffi::WGPUGlobal* aPtr) const {
     65    mozilla::webgpu::ffi::wgpu_server_delete(aPtr);
     66  }
     67 };
     68 
     69 template <>
     70 struct default_delete<mozilla::webgpu::ffi::WGPUMetalSharedEventHandle> {
     71 public:
     72  void operator()(
     73      mozilla::webgpu::ffi::WGPUMetalSharedEventHandle* aPtr) const {
     74    mozilla::webgpu::ffi::wgpu_server_delete_metal_shared_event(aPtr);
     75  }
     76 };
     77 
     78 }  // namespace std
     79 
     80 #endif  // WGPU_h