tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CanvasImageCache.h (2447B)


      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/. */
      5 
      6 #ifndef CANVASIMAGECACHE_H_
      7 #define CANVASIMAGECACHE_H_
      8 
      9 #include "mozilla/Maybe.h"
     10 #include "mozilla/gfx/Rect.h"
     11 #include "nsSize.h"
     12 
     13 namespace mozilla {
     14 namespace dom {
     15 class Element;
     16 class CanvasRenderingContext2D;
     17 }  // namespace dom
     18 namespace gfx {
     19 class DrawTarget;
     20 class SourceSurface;
     21 }  // namespace gfx
     22 }  // namespace mozilla
     23 class imgIContainer;
     24 
     25 namespace mozilla {
     26 
     27 class CanvasImageCache {
     28  using SourceSurface = mozilla::gfx::SourceSurface;
     29 
     30 public:
     31  /**
     32   * Notify that image element aImage was drawn to aContext canvas
     33   * using the first frame of aRequest's image. The data for the surface is
     34   * in aSurface, and the image size is in aSize. aIntrinsicSize is the size
     35   * the surface is intended to be rendered at.
     36   */
     37  static void NotifyDrawImage(dom::Element* aImage,
     38                              dom::CanvasRenderingContext2D* aContext,
     39                              gfx::DrawTarget* aTarget, SourceSurface* aSource,
     40                              const gfx::IntSize& aSize,
     41                              const gfx::IntSize& aIntrinsicSize,
     42                              const Maybe<gfx::IntRect>& aCropRect);
     43 
     44  /**
     45   * Notify that aContext is being destroyed.
     46   */
     47  static void NotifyCanvasDestroyed(dom::CanvasRenderingContext2D* aContext);
     48 
     49  /**
     50   * Check whether aImage has recently been drawn any canvas. If we return
     51   * a non-null surface, then the same image was recently drawn into a canvas.
     52   */
     53  static SourceSurface* LookupAllCanvas(dom::Element* aImage,
     54                                        gfx::DrawTarget* aTarget);
     55 
     56  /**
     57   * Like the top above, but restricts the lookup to only aContext. This is
     58   * required for CORS security.
     59   */
     60  static SourceSurface* LookupCanvas(dom::Element* aImage,
     61                                     dom::CanvasRenderingContext2D* aContext,
     62                                     gfx::DrawTarget* aTarget,
     63                                     gfx::IntSize* aSizeOut,
     64                                     gfx::IntSize* aIntrinsicSizeOut,
     65                                     Maybe<gfx::IntRect>* aCropRectOut);
     66 };
     67 
     68 }  // namespace mozilla
     69 
     70 #endif /* CANVASIMAGECACHE_H_ */