Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/CanvasPath.h
Line
Count
Source (jump to first uncovered line)
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3
 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5
#ifndef CanvasPath_h
6
#define CanvasPath_h
7
8
#include "mozilla/Attributes.h"
9
#include "mozilla/RefPtr.h"
10
#include "nsWrapperCache.h"
11
#include "mozilla/gfx/2D.h"
12
#include "mozilla/dom/BindingDeclarations.h"
13
#include "mozilla/ErrorResult.h"
14
15
namespace mozilla {
16
namespace dom {
17
18
enum class CanvasWindingRule : uint8_t;
19
class SVGMatrix;
20
21
class CanvasPath final :
22
  public nsWrapperCache
23
{
24
public:
25
  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CanvasPath)
26
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CanvasPath)
27
28
0
  nsCOMPtr<nsISupports> GetParentObject() { return mParent; }
29
30
  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
31
32
  static already_AddRefed<CanvasPath> Constructor(const GlobalObject& aGlobal,
33
                                                  ErrorResult& rv);
34
  static already_AddRefed<CanvasPath> Constructor(const GlobalObject& aGlobal,
35
                                                  CanvasPath& aCanvasPath,
36
                                                  ErrorResult& rv);
37
  static already_AddRefed<CanvasPath> Constructor(const GlobalObject& aGlobal,
38
                                                  const nsAString& aPathString,
39
                                                  ErrorResult& rv);
40
41
  void ClosePath();
42
  void MoveTo(double x, double y);
43
  void LineTo(double x, double y);
44
  void QuadraticCurveTo(double cpx, double cpy, double x, double y);
45
  void BezierCurveTo(double cp1x, double cp1y,
46
                     double cp2x, double cp2y,
47
                     double x, double y);
48
  void ArcTo(double x1, double y1, double x2, double y2, double radius,
49
             ErrorResult& error);
50
  void Rect(double x, double y, double w, double h);
51
  void Arc(double x, double y, double radius,
52
           double startAngle, double endAngle, bool anticlockwise,
53
           ErrorResult& error);
54
  void Ellipse(double x, double y, double radiusX, double radiusY,
55
               double rotation, double startAngle, double endAngle,
56
               bool anticlockwise, ErrorResult& error);
57
58
  void LineTo(const gfx::Point& aPoint);
59
  void BezierTo(const gfx::Point& aCP1,
60
                const gfx::Point& aCP2,
61
                const gfx::Point& aCP3);
62
63
  already_AddRefed<gfx::Path> GetPath(const CanvasWindingRule& aWinding,
64
                                  const gfx::DrawTarget* aTarget) const;
65
66
  explicit CanvasPath(nsISupports* aParent);
67
  // already_AddRefed arg because the return value from Path::CopyToBuilder()
68
  // is passed directly and we can't drop the only ref to have a raw pointer.
69
  CanvasPath(nsISupports* aParent,
70
             already_AddRefed<gfx::PathBuilder> aPathBuilder);
71
72
  void AddPath(CanvasPath& aCanvasPath,
73
               const Optional<NonNull<SVGMatrix>>& aMatrix);
74
75
private:
76
0
  virtual ~CanvasPath() {}
77
78
  nsCOMPtr<nsISupports> mParent;
79
0
  static gfx::Float ToFloat(double aValue) { return gfx::Float(aValue); }
80
81
  mutable RefPtr<gfx::Path> mPath;
82
  mutable RefPtr<gfx::PathBuilder> mPathBuilder;
83
84
  void EnsurePathBuilder() const;
85
};
86
87
} // namespace dom
88
} // namespace mozilla
89
90
#endif /* CanvasPath_h */
91