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 CanvasRenderingContext2D
;
23 } // namespace mozilla
28 class CanvasImageCache
{
29 using SourceSurface
= mozilla::gfx::SourceSurface
;
33 * Notify that image element aImage was drawn to aContext canvas
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::CanvasRenderingContext2D
* aContext
,
40 gfx::DrawTarget
* aTarget
, SourceSurface
* aSource
,
41 const gfx::IntSize
& aSize
,
42 const gfx::IntSize
& aIntrinsicSize
,
43 const Maybe
<gfx::IntRect
>& aCropRect
);
46 * Notify that aContext is being destroyed.
48 static void NotifyCanvasDestroyed(dom::CanvasRenderingContext2D
* aContext
);
51 * Check whether aImage has recently been drawn any canvas. If we return
52 * a non-null surface, then the same image was recently drawn into a canvas.
54 static SourceSurface
* LookupAllCanvas(dom::Element
* aImage
,
55 gfx::DrawTarget
* aTarget
);
58 * Like the top above, but restricts the lookup to only aContext. This is
59 * required for CORS security.
61 static SourceSurface
* LookupCanvas(dom::Element
* aImage
,
62 dom::CanvasRenderingContext2D
* aContext
,
63 gfx::DrawTarget
* aTarget
,
64 gfx::IntSize
* aSizeOut
,
65 gfx::IntSize
* aIntrinsicSizeOut
,
66 Maybe
<gfx::IntRect
>* aCropRectOut
);
69 } // namespace mozilla
71 #endif /* CANVASIMAGECACHE_H_ */