Bumping manifests a=b2g-bump
[gecko.git] / dom / canvas / ImageData.h
blob35f0a81ca6508a9b00c8e906ef4e4980021c0072
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 et tw=78: */
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_ImageData_h
8 #define mozilla_dom_ImageData_h
10 #include "nsIDOMCanvasRenderingContext2D.h"
12 #include "mozilla/Attributes.h"
13 #include "mozilla/dom/BindingUtils.h"
14 #include "mozilla/dom/TypedArray.h"
15 #include <stdint.h>
17 #include "nsCycleCollectionParticipant.h"
18 #include "nsISupportsImpl.h"
19 #include "js/GCAPI.h"
21 namespace mozilla {
22 namespace dom {
24 class ImageData MOZ_FINAL : public nsISupports
26 ~ImageData()
28 MOZ_COUNT_DTOR(ImageData);
29 DropData();
32 public:
33 ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
34 : mWidth(aWidth)
35 , mHeight(aHeight)
36 , mData(&aData)
38 MOZ_COUNT_CTOR(ImageData);
39 HoldData();
42 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
43 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
45 static already_AddRefed<ImageData>
46 Constructor(const GlobalObject& aGlobal,
47 const uint32_t aWidth,
48 const uint32_t aHeight,
49 ErrorResult& aRv);
51 static already_AddRefed<ImageData>
52 Constructor(const GlobalObject& aGlobal,
53 const Uint8ClampedArray& aData,
54 const uint32_t aWidth,
55 const Optional<uint32_t>& aHeight,
56 ErrorResult& aRv);
58 uint32_t Width() const
60 return mWidth;
62 uint32_t Height() const
64 return mHeight;
66 void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData) const
68 aData.set(GetDataObject());
70 JSObject* GetDataObject() const
72 JS::ExposeObjectToActiveJS(mData);
73 return mData;
76 JSObject* WrapObject(JSContext* cx);
78 private:
79 void HoldData();
80 void DropData();
82 ImageData() = delete;
84 uint32_t mWidth, mHeight;
85 JS::Heap<JSObject*> mData;
88 } // namespace dom
89 } // namespace mozilla
91 #endif // mozilla_dom_ImageData_h