content/media/webaudio/WaveShaperNode.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webaudio/WaveShaperNode.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,73 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef WaveShaperNode_h_
    1.11 +#define WaveShaperNode_h_
    1.12 +
    1.13 +#include "AudioNode.h"
    1.14 +#include "mozilla/dom/WaveShaperNodeBinding.h"
    1.15 +#include "mozilla/dom/TypedArray.h"
    1.16 +
    1.17 +namespace mozilla {
    1.18 +namespace dom {
    1.19 +
    1.20 +class AudioContext;
    1.21 +
    1.22 +class WaveShaperNode : public AudioNode
    1.23 +{
    1.24 +public:
    1.25 +  explicit WaveShaperNode(AudioContext *aContext);
    1.26 +  virtual ~WaveShaperNode();
    1.27 +
    1.28 +  NS_DECL_ISUPPORTS_INHERITED
    1.29 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(WaveShaperNode, AudioNode)
    1.30 +
    1.31 +  virtual JSObject* WrapObject(JSContext *aCx) MOZ_OVERRIDE;
    1.32 +
    1.33 +  void GetCurve(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval) const
    1.34 +  {
    1.35 +    if (mCurve) {
    1.36 +      JS::ExposeObjectToActiveJS(mCurve);
    1.37 +    }
    1.38 +    aRetval.set(mCurve);
    1.39 +  }
    1.40 +  void SetCurve(const Nullable<Float32Array>& aData);
    1.41 +
    1.42 +  OverSampleType Oversample() const
    1.43 +  {
    1.44 +    return mType;
    1.45 +  }
    1.46 +  void SetOversample(OverSampleType aType);
    1.47 +
    1.48 +  virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
    1.49 +  {
    1.50 +    // Possibly track in the future:
    1.51 +    // - mCurve
    1.52 +    return AudioNode::SizeOfExcludingThis(aMallocSizeOf);
    1.53 +  }
    1.54 +
    1.55 +  virtual const char* NodeType() const
    1.56 +  {
    1.57 +    return "WaveShaperNode";
    1.58 +  }
    1.59 +
    1.60 +  virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const MOZ_OVERRIDE
    1.61 +  {
    1.62 +    return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
    1.63 +  }
    1.64 +
    1.65 +private:
    1.66 +  void ClearCurve();
    1.67 +
    1.68 +private:
    1.69 +  JS::Heap<JSObject*> mCurve;
    1.70 +  OverSampleType mType;
    1.71 +};
    1.72 +
    1.73 +}
    1.74 +}
    1.75 +
    1.76 +#endif

mercurial