1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef mozilla_dom_CanvasPattern_h
6 #define mozilla_dom_CanvasPattern_h
8 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
9 #include "mozilla/RefPtr.h"
10 #include "nsISupports.h"
11 #include "nsWrapperCache.h"
21 class CanvasRenderingContext2D
;
22 struct DOMMatrix2DInit
;
24 class CanvasPattern final
: public nsWrapperCache
{
28 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CanvasPattern
)
29 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(CanvasPattern
)
31 enum class RepeatMode
: uint8_t { REPEAT
, REPEATX
, REPEATY
, NOREPEAT
};
33 CanvasPattern(CanvasRenderingContext2D
* aContext
,
34 gfx::SourceSurface
* aSurface
, RepeatMode aRepeat
,
35 nsIPrincipal
* principalForSecurityCheck
, bool forceWriteOnly
,
38 JSObject
* WrapObject(JSContext
* aCx
,
39 JS::Handle
<JSObject
*> aGivenProto
) override
{
40 return CanvasPattern_Binding::Wrap(aCx
, this, aGivenProto
);
43 CanvasRenderingContext2D
* GetParentObject() { return mContext
; }
46 void SetTransform(const DOMMatrix2DInit
& aInit
, ErrorResult
& aError
);
48 RefPtr
<CanvasRenderingContext2D
> mContext
;
49 RefPtr
<gfx::SourceSurface
> mSurface
;
50 nsCOMPtr
<nsIPrincipal
> mPrincipal
;
51 mozilla::gfx::Matrix mTransform
;
52 const bool mForceWriteOnly
;
54 const RepeatMode mRepeat
;
58 } // namespace mozilla
60 #endif // mozilla_dom_CanvasPattern_h