1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_DOM_OFFSCREENCANVASRENDERINGCONTEXT2D_H_
8 #define MOZILLA_DOM_OFFSCREENCANVASRENDERINGCONTEXT2D_H_
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/dom/CanvasRenderingContext2D.h"
14 class nsIGlobalObject
;
16 namespace mozilla::dom
{
17 class OffscreenCanvas
;
19 class OffscreenCanvasRenderingContext2D final
20 : public CanvasRenderingContext2D
{
22 // nsISupports interface + CC
23 NS_DECL_ISUPPORTS_INHERITED
24 NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS_INHERITED(
25 OffscreenCanvasRenderingContext2D
, CanvasRenderingContext2D
)
27 explicit OffscreenCanvasRenderingContext2D(
28 layers::LayersBackend aCompositorBackend
);
30 nsIGlobalObject
* GetParentObject() const;
32 JSObject
* WrapObject(JSContext
* aCx
,
33 JS::Handle
<JSObject
*> aGivenProto
) override
;
35 OffscreenCanvas
* Canvas() { return mOffscreenCanvas
; }
36 const OffscreenCanvas
* Canvas() const { return mOffscreenCanvas
; }
38 void Commit(ErrorResult
& aRv
);
40 NS_IMETHOD
InitializeWithDrawTarget(
41 nsIDocShell
* aShell
, NotNull
<gfx::DrawTarget
*> aTarget
) override
;
44 void AddZoneWaitingForGC() override
;
45 void AddAssociatedMemory() override
;
46 void RemoveAssociatedMemory() override
;
48 ~OffscreenCanvasRenderingContext2D() override
;
51 size_t BindingJSObjectMallocBytes(OffscreenCanvasRenderingContext2D
* aContext
);
53 } // namespace mozilla::dom
55 #endif // MOZILLA_DOM_OFFSCREENCANVASRENDERINGCONTEXT2D_H_