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/Maybe.h"
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/gfx/Rect.h"
17 class HTMLCanvasElement
;
23 } // namespace mozilla
28 class CanvasImageCache
{
29 using SourceSurface
= mozilla::gfx::SourceSurface
;
33 * Notify that image element aImage was drawn to aCanvas element
34 * using the first frame of aRequest's image. The data for the surface is
35 * in aSurface, and the image size is in aSize. aIntrinsicSize is the size
36 * the surface is intended to be rendered at.
38 static void NotifyDrawImage(dom::Element
* aImage
,
39 dom::HTMLCanvasElement
* aCanvas
,
40 gfx::DrawTarget
* aTarget
, SourceSurface
* aSource
,
41 const gfx::IntSize
& aSize
,
42 const gfx::IntSize
& aIntrinsicSize
,
43 const Maybe
<gfx::IntRect
>& aCropRect
);
46 * Check whether aImage has recently been drawn any canvas. If we return
47 * a non-null surface, then the same image was recently drawn into a canvas.
49 static SourceSurface
* LookupAllCanvas(dom::Element
* aImage
,
50 gfx::DrawTarget
* aTarget
);
53 * Like the top above, but restricts the lookup to only aCanvas. This is
54 * required for CORS security.
56 static SourceSurface
* LookupCanvas(dom::Element
* aImage
,
57 dom::HTMLCanvasElement
* aCanvas
,
58 gfx::DrawTarget
* aTarget
,
59 gfx::IntSize
* aSizeOut
,
60 gfx::IntSize
* aIntrinsicSizeOut
,
61 Maybe
<gfx::IntRect
>* aCropRectOut
);
64 } // namespace mozilla
66 #endif /* CANVASIMAGECACHE_H_ */