2012-03-16 09:44:08 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:set ts=2 sw=2 et tw=78: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_ImageData_h
|
|
|
|
#define mozilla_dom_ImageData_h
|
|
|
|
|
|
|
|
#include "nsIDOMCanvasRenderingContext2D.h"
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
2014-01-28 13:04:40 +00:00
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
#include "mozilla/dom/TypedArray.h"
|
2013-07-30 14:25:31 +00:00
|
|
|
#include <stdint.h>
|
2012-03-16 09:44:08 +00:00
|
|
|
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2014-02-26 21:36:35 +00:00
|
|
|
#include "nsISupportsImpl.h"
|
2013-09-09 03:28:48 +00:00
|
|
|
#include "js/GCAPI.h"
|
2012-03-16 09:44:08 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2012-10-22 17:08:52 +00:00
|
|
|
class ImageData MOZ_FINAL : public nsISupports
|
2012-03-16 09:44:08 +00:00
|
|
|
{
|
2014-06-26 13:30:49 +00:00
|
|
|
~ImageData()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ImageData);
|
|
|
|
DropData();
|
|
|
|
}
|
|
|
|
|
2012-03-16 09:44:08 +00:00
|
|
|
public:
|
|
|
|
ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
|
|
|
|
: mWidth(aWidth)
|
|
|
|
, mHeight(aHeight)
|
|
|
|
, mData(&aData)
|
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ImageData);
|
|
|
|
HoldData();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
|
|
|
|
|
2014-08-27 22:43:55 +00:00
|
|
|
static already_AddRefed<ImageData>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const uint32_t aWidth,
|
|
|
|
const uint32_t aHeight,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
|
|
static already_AddRefed<ImageData>
|
|
|
|
Constructor(const GlobalObject& aGlobal,
|
|
|
|
const Uint8ClampedArray& aData,
|
|
|
|
const uint32_t aWidth,
|
|
|
|
const Optional<uint32_t>& aHeight,
|
|
|
|
ErrorResult& aRv);
|
2014-01-28 13:04:40 +00:00
|
|
|
|
2012-10-22 17:08:52 +00:00
|
|
|
uint32_t Width() const
|
2012-03-16 09:44:08 +00:00
|
|
|
{
|
|
|
|
return mWidth;
|
|
|
|
}
|
2012-10-22 17:08:52 +00:00
|
|
|
uint32_t Height() const
|
2012-03-16 09:44:08 +00:00
|
|
|
{
|
|
|
|
return mHeight;
|
|
|
|
}
|
2014-06-11 20:26:52 +00:00
|
|
|
void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData) const
|
2012-06-13 15:14:15 +00:00
|
|
|
{
|
2014-06-11 20:26:52 +00:00
|
|
|
aData.set(GetDataObject());
|
2012-06-13 15:14:15 +00:00
|
|
|
}
|
2012-10-22 17:08:52 +00:00
|
|
|
JSObject* GetDataObject() const
|
2012-03-16 09:44:08 +00:00
|
|
|
{
|
2013-09-09 03:28:48 +00:00
|
|
|
JS::ExposeObjectToActiveJS(mData);
|
2012-03-16 09:44:08 +00:00
|
|
|
return mData;
|
|
|
|
}
|
|
|
|
|
2014-04-08 22:27:18 +00:00
|
|
|
JSObject* WrapObject(JSContext* cx);
|
2012-10-22 17:08:52 +00:00
|
|
|
|
2012-03-16 09:44:08 +00:00
|
|
|
private:
|
|
|
|
void HoldData();
|
|
|
|
void DropData();
|
|
|
|
|
|
|
|
ImageData() MOZ_DELETE;
|
|
|
|
|
|
|
|
uint32_t mWidth, mHeight;
|
2013-06-18 10:00:38 +00:00
|
|
|
JS::Heap<JSObject*> mData;
|
2012-03-16 09:44:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_ImageData_h
|