tor-browser

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

MockDrawTarget.h (6745B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      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/. */
      6 
      7 #ifndef FUZZ_MOCKDRAWTARGET_H
      8 #define FUZZ_MOCKDRAWTARGET_H
      9 
     10 #include "mozilla/gfx/2D.h"
     11 
     12 class MockDrawTarget : public mozilla::gfx::DrawTarget {
     13 public:
     14  using Rect = mozilla::gfx::Rect;
     15  using Point = mozilla::gfx::Point;
     16  using DrawTargetType = mozilla::gfx::DrawTargetType;
     17  using BackendType = mozilla::gfx::BackendType;
     18  using SourceSurface = mozilla::gfx::SourceSurface;
     19  using IntSize = mozilla::gfx::IntSize;
     20  using DrawSurfaceOptions = mozilla::gfx::DrawSurfaceOptions;
     21  using DrawOptions = mozilla::gfx::DrawOptions;
     22  using FilterNode = mozilla::gfx::FilterNode;
     23  using ShadowOptions = mozilla::gfx::ShadowOptions;
     24  using CompositionOp = mozilla::gfx::CompositionOp;
     25  using IntRect = mozilla::gfx::IntRect;
     26  using IntPoint = mozilla::gfx::IntPoint;
     27  using Pattern = mozilla::gfx::Pattern;
     28  using StrokeOptions = mozilla::gfx::StrokeOptions;
     29  using Path = mozilla::gfx::Path;
     30  using ScaledFont = mozilla::gfx::ScaledFont;
     31  using GlyphBuffer = mozilla::gfx::GlyphBuffer;
     32  using Float = mozilla::gfx::Float;
     33  using Matrix = mozilla::gfx::Matrix;
     34  using SurfaceFormat = mozilla::gfx::SurfaceFormat;
     35  using NativeSurface = mozilla::gfx::NativeSurface;
     36  using PathBuilder = mozilla::gfx::PathBuilder;
     37  using GradientStop = mozilla::gfx::GradientStop;
     38  using GradientStops = mozilla::gfx::GradientStops;
     39  using FillRule = mozilla::gfx::FillRule;
     40  using ExtendMode = mozilla::gfx::ExtendMode;
     41  using FilterType = mozilla::gfx::FilterType;
     42 
     43  class MockGradientStops : public GradientStops {
     44   public:
     45    MockGradientStops() {}
     46    virtual ~MockGradientStops() = default;
     47    BackendType GetBackendType() const final { return BackendType::NONE; }
     48  };
     49 
     50  MockDrawTarget() {}
     51  virtual ~MockDrawTarget() = default;
     52 
     53  DrawTargetType GetType() const final {
     54    return DrawTargetType::SOFTWARE_RASTER;
     55  }
     56  BackendType GetBackendType() const final { return BackendType::NONE; }
     57  already_AddRefed<SourceSurface> Snapshot() final { return nullptr; }
     58  already_AddRefed<SourceSurface> GetBackingSurface() final { return nullptr; }
     59  IntSize GetSize() const final { return IntSize(100, 100); }
     60  void Flush() final {}
     61  void DrawSurface(
     62      SourceSurface* aSurface, const Rect& aDest, const Rect& aSource,
     63      const DrawSurfaceOptions& aSurfOptions = DrawSurfaceOptions(),
     64      const DrawOptions& aOptions = DrawOptions()) final {}
     65  void DrawFilter(FilterNode* aNode, const Rect& aSourceRect,
     66                  const Point& aDestPoint,
     67                  const DrawOptions& aOptions = DrawOptions()) final {}
     68  void DrawSurfaceWithShadow(SourceSurface* aSurface, const Point& aDest,
     69                             const ShadowOptions& aShadow,
     70                             CompositionOp aOperator) final {}
     71  void ClearRect(const Rect& aRect) final {}
     72  void CopySurface(SourceSurface* aSurface, const IntRect& aSourceRect,
     73                   const IntPoint& aDestination) final {}
     74  void FillRect(const Rect& aRect, const Pattern& aPattern,
     75                const DrawOptions& aOptions = DrawOptions()) final {}
     76  void StrokeRect(const Rect& aRect, const Pattern& aPattern,
     77                  const StrokeOptions& aStrokeOptions = StrokeOptions(),
     78                  const DrawOptions& aOptions = DrawOptions()) final {}
     79  void StrokeLine(const Point& aStart, const Point& aEnd,
     80                  const Pattern& aPattern,
     81                  const StrokeOptions& aStrokeOptions = StrokeOptions(),
     82                  const DrawOptions& aOptions = DrawOptions()) final {}
     83  void Stroke(const Path* aPath, const Pattern& aPattern,
     84              const StrokeOptions& aStrokeOptions = StrokeOptions(),
     85              const DrawOptions& aOptions = DrawOptions()) final {}
     86  void Fill(const Path* aPath, const Pattern& aPattern,
     87            const DrawOptions& aOptions = DrawOptions()) final {}
     88  void FillGlyphs(ScaledFont* aFont, const GlyphBuffer& aBuffer,
     89                  const Pattern& aPattern,
     90                  const DrawOptions& aOptions = DrawOptions()) final {}
     91  void Mask(const Pattern& aSource, const Pattern& aMask,
     92            const DrawOptions& aOptions = DrawOptions()) final {}
     93  void MaskSurface(const Pattern& aSource, SourceSurface* aMask, Point aOffset,
     94                   const DrawOptions& aOptions = DrawOptions()) final {}
     95  void PushClip(const Path* aPath) final {}
     96  void PushClipRect(const Rect& aRect) final {}
     97  void PopClip() final {}
     98  void PushLayer(bool aOpaque, Float aOpacity, SourceSurface* aMask,
     99                 const Matrix& aMaskTransform,
    100                 const IntRect& aBounds = IntRect(),
    101                 bool aCopyBackground = false) final {}
    102  void PushLayerWithBlend(bool aOpaque, Float aOpacity, SourceSurface* aMask,
    103                          const Matrix& aMaskTransform,
    104                          const IntRect& aBounds = IntRect(),
    105                          bool aCopyBackground = false,
    106                          CompositionOp = CompositionOp::OP_OVER) final {}
    107  void PopLayer() final {}
    108  already_AddRefed<SourceSurface> CreateSourceSurfaceFromData(
    109      unsigned char* aData, const IntSize& aSize, int32_t aStride,
    110      SurfaceFormat aFormat) const final {
    111    return nullptr;
    112  }
    113  already_AddRefed<SourceSurface> OptimizeSourceSurface(
    114      SourceSurface* aSurface) const final {
    115    return nullptr;
    116  }
    117  already_AddRefed<SourceSurface> CreateSourceSurfaceFromNativeSurface(
    118      const NativeSurface& aSurface) const final {
    119    return nullptr;
    120  }
    121  already_AddRefed<DrawTarget> CreateSimilarDrawTarget(
    122      const IntSize& aSize, SurfaceFormat aFormat) const final {
    123    return nullptr;
    124  }
    125  bool CanCreateSimilarDrawTarget(const IntSize& aSize,
    126                                  SurfaceFormat aFormat) const final {
    127    return false;
    128  }
    129  RefPtr<DrawTarget> CreateClippedDrawTarget(const Rect& aBounds,
    130                                             SurfaceFormat aFormat) final {
    131    return nullptr;
    132  }
    133  already_AddRefed<PathBuilder> CreatePathBuilder(
    134      FillRule aFillRule = FillRule::FILL_WINDING) const final {
    135    return nullptr;
    136  }
    137  already_AddRefed<GradientStops> CreateGradientStops(
    138      GradientStop* aStops, uint32_t aNumStops,
    139      ExtendMode aExtendMode = ExtendMode::CLAMP) const final {
    140    RefPtr rv = new MockGradientStops();
    141    return rv.forget();
    142  }
    143  already_AddRefed<FilterNode> CreateFilter(FilterType aType) final {
    144    return nullptr;
    145  }
    146  void DetachAllSnapshots() final {}
    147 };
    148 
    149 #endif