tor-browser

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

ObjectModel.cpp (1736B)


      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 #include "ObjectModel.h"
      7 
      8 #include "Adapter.h"
      9 #include "CommandEncoder.h"
     10 #include "CompilationInfo.h"
     11 #include "Device.h"
     12 #include "Instance.h"
     13 #include "ShaderModule.h"
     14 #include "Texture.h"
     15 #include "ipc/WebGPUChild.h"
     16 #include "nsIGlobalObject.h"
     17 
     18 namespace mozilla::webgpu {
     19 
     20 template <typename T>
     21 ChildOf<T>::ChildOf(T* const parent) : mParent(parent) {}
     22 
     23 template <typename T>
     24 ChildOf<T>::~ChildOf() = default;
     25 
     26 template <typename T>
     27 nsIGlobalObject* ChildOf<T>::GetParentObject() const {
     28  return mParent->GetParentObject();
     29 }
     30 
     31 void ObjectBase::GetLabel(nsAString& aValue) const { aValue = mLabel; }
     32 void ObjectBase::SetLabel(const nsAString& aLabel) { mLabel = aLabel; }
     33 
     34 WebGPUChild* ObjectBase::GetChild() const { return mChild; }
     35 ffi::WGPUClient* ObjectBase::GetClient() const { return mChild->GetClient(); }
     36 
     37 ObjectBase::ObjectBase(WebGPUChild* const aChild, RawId aId,
     38                       void (*aDropFnPtr)(const struct ffi::WGPUClient* aClient,
     39                                          RawId aId))
     40    : mChild(aChild), mId(aId), mDropFnPtr(aDropFnPtr) {
     41  MOZ_RELEASE_ASSERT(aId);
     42 }
     43 
     44 ObjectBase::~ObjectBase() { mDropFnPtr(GetClient(), mId); }
     45 
     46 template class ChildOf<Adapter>;
     47 template class ChildOf<ShaderModule>;
     48 template class ChildOf<CompilationInfo>;
     49 template class ChildOf<CommandEncoder>;
     50 template class ChildOf<Device>;
     51 template class ChildOf<Instance>;
     52 template class ChildOf<Texture>;
     53 
     54 }  // namespace mozilla::webgpu