tor-browser

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

WaveShaperNode.h (2279B)


      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/. */
      6 
      7 #ifndef WaveShaperNode_h_
      8 #define WaveShaperNode_h_
      9 
     10 #include "AudioNode.h"
     11 #include "mozilla/dom/TypedArray.h"
     12 #include "mozilla/dom/WaveShaperNodeBinding.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 class AudioContext;
     17 struct WaveShaperOptions;
     18 
     19 class WaveShaperNode final : public AudioNode {
     20 public:
     21  static already_AddRefed<WaveShaperNode> Create(
     22      AudioContext& aAudioContext, const WaveShaperOptions& aOptions,
     23      ErrorResult& aRv);
     24 
     25  NS_DECL_ISUPPORTS_INHERITED
     26  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(WaveShaperNode,
     27                                                         AudioNode)
     28 
     29  static already_AddRefed<WaveShaperNode> Constructor(
     30      const GlobalObject& aGlobal, AudioContext& aAudioContext,
     31      const WaveShaperOptions& aOptions, ErrorResult& aRv) {
     32    return Create(aAudioContext, aOptions, aRv);
     33  }
     34 
     35  JSObject* WrapObject(JSContext* aCx,
     36                       JS::Handle<JSObject*> aGivenProto) override;
     37 
     38  void GetCurve(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
     39                ErrorResult& aRv);
     40  void SetCurve(const Nullable<Float32Array>& aData, ErrorResult& aRv);
     41 
     42  OverSampleType Oversample() const { return mType; }
     43  void SetOversample(OverSampleType aType);
     44 
     45  size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override {
     46    // Possibly track in the future:
     47    // - mCurve
     48    return AudioNode::SizeOfExcludingThis(aMallocSizeOf);
     49  }
     50 
     51  const char* NodeType() const override { return "WaveShaperNode"; }
     52 
     53  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override {
     54    return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
     55  }
     56 
     57 private:
     58  explicit WaveShaperNode(AudioContext* aContext);
     59  ~WaveShaperNode() = default;
     60 
     61  void SetCurveInternal(const nsTArray<float>& aCurve, ErrorResult& aRv);
     62  void CleanCurveInternal();
     63 
     64  void SendCurveToTrack();
     65 
     66  nsTArray<float> mCurve;
     67  OverSampleType mType;
     68 };
     69 
     70 }  // namespace mozilla::dom
     71 
     72 #endif