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"
14 #include "ObjectModel.h"
20 struct GPURequestAdapterOptions
;
28 class Instance final
: public nsWrapperCache
{
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 {
44 return dom::GPUTextureFormat::Rgba8unorm
;
46 return dom::GPUTextureFormat::Bgra8unorm
;
50 explicit Instance(nsIGlobalObject
* aOwner
);
54 nsCOMPtr
<nsIGlobalObject
> mOwner
;
60 } // namespace mozilla
62 #endif // GPU_INSTANCE_H_