dom/camera/DOMCameraDetectedFace.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/camera/DOMCameraDetectedFace.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,126 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef DOM_CAMERA_DOMCAMERADETECTEDFACE_H
     1.9 +#define DOM_CAMERA_DOMCAMERADETECTEDFACE_H
    1.10 +
    1.11 +#include "mozilla/dom/CameraControlBinding.h"
    1.12 +#include "nsCycleCollectionParticipant.h"
    1.13 +#include "nsWrapperCache.h"
    1.14 +#include "mozilla/dom/DOMRect.h"
    1.15 +#include "ICameraControl.h"
    1.16 +
    1.17 +namespace mozilla {
    1.18 +
    1.19 +namespace dom {
    1.20 +
    1.21 +class DOMCameraPoint MOZ_FINAL : public nsISupports
    1.22 +                               , public nsWrapperCache
    1.23 +{
    1.24 +public:
    1.25 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.26 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraPoint)
    1.27 +
    1.28 +  // Because this header's filename doesn't match its C++ or DOM-facing
    1.29 +  // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
    1.30 +  // include the right header for us; instead we must explicitly include a
    1.31 +  // HasSupport() method in each header. We can get rid of these with the
    1.32 +  // Great Renaming proposed in bug 983177.
    1.33 +  static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
    1.34 +
    1.35 +  DOMCameraPoint(nsISupports* aParent, const ICameraControl::Point& aPoint)
    1.36 +    : mParent(aParent)
    1.37 +    , mX(aPoint.x)
    1.38 +    , mY(aPoint.y)
    1.39 +  {
    1.40 +    SetIsDOMBinding();
    1.41 +  }
    1.42 +
    1.43 +  void
    1.44 +  SetPoint(int32_t aX, int32_t aY)
    1.45 +  {
    1.46 +    mX = aX;
    1.47 +    mY = aY;
    1.48 +  }
    1.49 +
    1.50 +  int32_t X() { return mX; }
    1.51 +  int32_t Y() { return mY; }
    1.52 +
    1.53 +  void SetX(int32_t aX) { mX = aX; }
    1.54 +  void SetY(int32_t aY) { mY = aY; }
    1.55 +
    1.56 +  nsISupports*
    1.57 +  GetParentObject() const
    1.58 +  {
    1.59 +    MOZ_ASSERT(mParent);
    1.60 +    return mParent;
    1.61 +  }
    1.62 +
    1.63 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    1.64 +
    1.65 +protected:
    1.66 +  virtual ~DOMCameraPoint() { }
    1.67 +
    1.68 +  nsCOMPtr<nsISupports> mParent;
    1.69 +  int32_t mX;
    1.70 +  int32_t mY;
    1.71 +};
    1.72 +
    1.73 +class DOMCameraDetectedFace MOZ_FINAL : public nsISupports
    1.74 +                                      , public nsWrapperCache
    1.75 +{
    1.76 +public:
    1.77 +  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    1.78 +  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMCameraDetectedFace)
    1.79 +
    1.80 +  // Because this header's filename doesn't match its C++ or DOM-facing
    1.81 +  // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly
    1.82 +  // include the right header for us; instead we must explicitly include a
    1.83 +  // HasSupport() method in each header. We can get rid of these with the
    1.84 +  // Great Renaming proposed in bug 983177.
    1.85 +  static bool HasSupport(JSContext* aCx, JSObject* aGlobal);
    1.86 +
    1.87 +  DOMCameraDetectedFace(nsISupports* aParent, const ICameraControl::Face& aFace);
    1.88 +
    1.89 +  uint32_t Id()       { return mId; }
    1.90 +  uint32_t Score()    { return mScore; }
    1.91 +  bool HasLeftEye()   { return mLeftEye; }
    1.92 +  bool HasRightEye()  { return mRightEye; }
    1.93 +  bool HasMouth()     { return mMouth; }
    1.94 +
    1.95 +  dom::DOMRect* Bounds()        { return mBounds; }
    1.96 +
    1.97 +  DOMCameraPoint* GetLeftEye()  { return mLeftEye; }
    1.98 +  DOMCameraPoint* GetRightEye() { return mRightEye; }
    1.99 +  DOMCameraPoint* GetMouth()    { return mMouth; }
   1.100 +
   1.101 +  nsISupports*
   1.102 +  GetParentObject() const
   1.103 +  {
   1.104 +    MOZ_ASSERT(mParent);
   1.105 +    return mParent;
   1.106 +  }
   1.107 +
   1.108 +  virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
   1.109 +
   1.110 +protected:
   1.111 +  virtual ~DOMCameraDetectedFace() { }
   1.112 +
   1.113 +  nsCOMPtr<nsISupports> mParent;
   1.114 +
   1.115 +  uint32_t mId;
   1.116 +  uint32_t mScore;
   1.117 +
   1.118 +  nsRefPtr<dom::DOMRect> mBounds;
   1.119 +
   1.120 +  nsRefPtr<DOMCameraPoint> mLeftEye;
   1.121 +  nsRefPtr<DOMCameraPoint> mRightEye;
   1.122 +  nsRefPtr<DOMCameraPoint> mMouth;
   1.123 +};
   1.124 +
   1.125 +} // namespace dom
   1.126 +
   1.127 +} // namespace mozilla
   1.128 +
   1.129 +#endif // DOM_CAMERA_DOMCAMERADETECTEDFACE_H

mercurial