Bug 1839170 - Refactor Snap pulling, Add Firefox Snap Core22 and GNOME 42 SDK symbols...
[gecko.git] / dom / media / webaudio / WaveShaperNode.h
blob3c5d8c8ef4d37bbd8db0c33637bc05a2f4ede152
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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/. */
7 #ifndef WaveShaperNode_h_
8 #define WaveShaperNode_h_
10 #include "AudioNode.h"
11 #include "mozilla/dom/WaveShaperNodeBinding.h"
12 #include "mozilla/dom/TypedArray.h"
14 namespace mozilla::dom {
16 class AudioContext;
17 struct WaveShaperOptions;
19 class WaveShaperNode final : public AudioNode {
20 public:
21 static already_AddRefed<WaveShaperNode> Create(
22 AudioContext& aAudioContext, const WaveShaperOptions& aOptions,
23 ErrorResult& aRv);
25 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(WaveShaperNode,
27 AudioNode)
29 static already_AddRefed<WaveShaperNode> Constructor(
30 const GlobalObject& aGlobal, AudioContext& aAudioContext,
31 const WaveShaperOptions& aOptions, ErrorResult& aRv) {
32 return Create(aAudioContext, aOptions, aRv);
35 JSObject* WrapObject(JSContext* aCx,
36 JS::Handle<JSObject*> aGivenProto) override;
38 void GetCurve(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval);
39 void SetCurve(const Nullable<Float32Array>& aData, ErrorResult& aRv);
41 OverSampleType Oversample() const { return mType; }
42 void SetOversample(OverSampleType aType);
44 size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override {
45 // Possibly track in the future:
46 // - mCurve
47 return AudioNode::SizeOfExcludingThis(aMallocSizeOf);
50 const char* NodeType() const override { return "WaveShaperNode"; }
52 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override {
53 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
56 private:
57 explicit WaveShaperNode(AudioContext* aContext);
58 ~WaveShaperNode() = default;
60 void SetCurveInternal(const nsTArray<float>& aCurve, ErrorResult& aRv);
61 void CleanCurveInternal();
63 void SendCurveToTrack();
65 nsTArray<float> mCurve;
66 OverSampleType mType;
69 } // namespace mozilla::dom
71 #endif