Bug 1831122 [wpt PR 39823] - Update wpt metadata, a=testonly
[gecko.git] / dom / canvas / CanvasImageCache.h
blob58486c5a8d01c1b0006c03ef3c3733eed6986ca8
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef CANVASIMAGECACHE_H_
7 #define CANVASIMAGECACHE_H_
9 #include "mozilla/RefPtr.h"
10 #include "nsSize.h"
12 namespace mozilla {
13 namespace dom {
14 class Element;
15 class HTMLCanvasElement;
16 } // namespace dom
17 namespace gfx {
18 class DrawTarget;
19 class SourceSurface;
20 } // namespace gfx
21 } // namespace mozilla
22 class imgIContainer;
24 namespace mozilla {
26 class CanvasImageCache {
27 using SourceSurface = mozilla::gfx::SourceSurface;
29 public:
30 /**
31 * Notify that image element aImage was drawn to aCanvas element
32 * using the first frame of aRequest's image. The data for the surface is
33 * in aSurface, and the image size is in aSize. aIntrinsicSize is the size
34 * the surface is intended to be rendered at.
36 static void NotifyDrawImage(dom::Element* aImage,
37 dom::HTMLCanvasElement* aCanvas,
38 gfx::DrawTarget* aTarget, SourceSurface* aSource,
39 const gfx::IntSize& aSize,
40 const gfx::IntSize& aIntrinsicSize);
42 /**
43 * Check whether aImage has recently been drawn any canvas. If we return
44 * a non-null surface, then the same image was recently drawn into a canvas.
46 static SourceSurface* LookupAllCanvas(dom::Element* aImage,
47 gfx::DrawTarget* aTarget);
49 /**
50 * Like the top above, but restricts the lookup to only aCanvas. This is
51 * required for CORS security.
53 static SourceSurface* LookupCanvas(dom::Element* aImage,
54 dom::HTMLCanvasElement* aCanvas,
55 gfx::DrawTarget* aTarget,
56 gfx::IntSize* aSizeOut,
57 gfx::IntSize* aIntrinsicSizeOut);
60 } // namespace mozilla
62 #endif /* CANVASIMAGECACHE_H_ */