no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / dom / webgpu / Instance.h
blobc50a6f9bbd9f8f275fe823cc3dd9626970e3ea36
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_INSTANCE_H_
7 #define GPU_INSTANCE_H_
9 #include "mozilla/AlreadyAddRefed.h"
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/dom/WebGPUBinding.h"
12 #include "mozilla/layers/BuildConstants.h"
13 #include "nsCOMPtr.h"
14 #include "ObjectModel.h"
16 namespace mozilla {
17 class ErrorResult;
18 namespace dom {
19 class Promise;
20 struct GPURequestAdapterOptions;
21 } // namespace dom
23 namespace webgpu {
24 class Adapter;
25 class GPUAdapter;
26 class WebGPUChild;
28 class Instance final : public nsWrapperCache {
29 public:
30 GPU_DECL_CYCLE_COLLECTION(Instance)
31 GPU_DECL_JS_WRAP(Instance)
33 nsIGlobalObject* GetParentObject() const { return mOwner; }
35 static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
37 static already_AddRefed<Instance> Create(nsIGlobalObject* aOwner);
39 already_AddRefed<dom::Promise> RequestAdapter(
40 const dom::GPURequestAdapterOptions& aOptions, ErrorResult& aRv);
42 dom::GPUTextureFormat GetPreferredCanvasFormat() const {
43 if (kIsAndroid) {
44 return dom::GPUTextureFormat::Rgba8unorm;
46 return dom::GPUTextureFormat::Bgra8unorm;
49 private:
50 explicit Instance(nsIGlobalObject* aOwner);
51 virtual ~Instance();
52 void Cleanup();
54 nsCOMPtr<nsIGlobalObject> mOwner;
56 public:
59 } // namespace webgpu
60 } // namespace mozilla
62 #endif // GPU_INSTANCE_H_