summaryrefslogtreecommitdiffstats
path: root/dom/canvas/BasicRenderingContext2D.h
blob: 4938c1f5a13b558e7f1f6267fb4399828dd3a6c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef BasicRenderingContext2D_h
#define BasicRenderingContext2D_h

#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
#include "mozilla/dom/DOMMatrix.h"

namespace mozilla::dom {

class
    HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrOffscreenCanvasOrImageBitmap;
typedef HTMLImageElementOrSVGImageElementOrHTMLCanvasElementOrHTMLVideoElementOrOffscreenCanvasOrImageBitmap
    CanvasImageSource;

/*
 * BasicRenderingContext2D
 */
class BasicRenderingContext2D {
 public:
  //
  // CanvasState
  //
  virtual void Save() = 0;
  virtual void Restore() = 0;

  //
  // CanvasTransform
  //
  virtual void Scale(double aX, double aY, mozilla::ErrorResult& aError) = 0;
  virtual void Rotate(double aAngle, mozilla::ErrorResult& aError) = 0;
  virtual void Translate(double aX, double aY,
                         mozilla::ErrorResult& aError) = 0;
  virtual void Transform(double aM11, double aM12, double aM21, double aM22,
                         double aDx, double aDy,
                         mozilla::ErrorResult& aError) = 0;
  virtual already_AddRefed<DOMMatrix> GetTransform(
      mozilla::ErrorResult& aError) = 0;
  virtual void SetTransform(double aM11, double aM12, double aM21, double aM22,
                            double aDx, double aDy,
                            mozilla::ErrorResult& aError) = 0;
  virtual void SetTransform(const DOMMatrix2DInit& aInit,
                            mozilla::ErrorResult& aError) = 0;
  virtual void ResetTransform(mozilla::ErrorResult& aError) = 0;

  //
  // CanvasCompositing
  //
  virtual double GlobalAlpha() = 0;
  virtual void SetGlobalAlpha(double aGlobalAlpha) = 0;
  virtual void GetGlobalCompositeOperation(nsAString& aOp,
                                           mozilla::ErrorResult& aError) = 0;
  virtual void SetGlobalCompositeOperation(const nsAString& aOp,
                                           mozilla::ErrorResult& aError) = 0;

  //
  // CanvasImageSmoothing
  //
  virtual bool ImageSmoothingEnabled() = 0;
  virtual void SetImageSmoothingEnabled(bool aImageSmoothingEnabled) = 0;

  //
  // CanvasFillStrokeStyles
  //
  virtual void GetStrokeStyle(
      OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
  virtual void SetStrokeStyle(
      const UTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
  virtual void GetFillStyle(
      OwningUTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
  virtual void SetFillStyle(
      const UTF8StringOrCanvasGradientOrCanvasPattern& aValue) = 0;
  virtual already_AddRefed<CanvasGradient> CreateLinearGradient(double aX0,
                                                                double aY0,
                                                                double aX1,
                                                                double aY1) = 0;
  virtual already_AddRefed<CanvasGradient> CreateRadialGradient(
      double aX0, double aY0, double aR0, double aX1, double aY1, double aR1,
      ErrorResult& aError) = 0;
  virtual already_AddRefed<CanvasGradient> CreateConicGradient(double aAngle,
                                                               double aCx,
                                                               double aCy) = 0;
  virtual already_AddRefed<CanvasPattern> CreatePattern(
      const CanvasImageSource& aElement, const nsAString& aRepeat,
      ErrorResult& aError) = 0;
  //
  // CanvasShadowStyles
  //
  virtual double ShadowOffsetX() = 0;
  virtual void SetShadowOffsetX(double aShadowOffsetX) = 0;
  virtual double ShadowOffsetY() = 0;
  virtual void SetShadowOffsetY(double aShadowOffsetY) = 0;
  virtual double ShadowBlur() = 0;
  virtual void SetShadowBlur(double aShadowBlur) = 0;
  virtual void GetShadowColor(nsACString& aShadowColor) = 0;
  virtual void SetShadowColor(const nsACString& aShadowColor) = 0;

  //
  // CanvasRect
  //
  virtual void ClearRect(double aX, double aY, double aW, double aH) = 0;
  virtual void FillRect(double aX, double aY, double aW, double aH) = 0;
  virtual void StrokeRect(double aX, double aY, double aW, double aH) = 0;

  //
  // CanvasDrawImage
  //
  virtual void DrawImage(const CanvasImageSource& aImage, double aDx,
                         double aDy, mozilla::ErrorResult& aError) = 0;
  virtual void DrawImage(const CanvasImageSource& aImage, double aDx,
                         double aDy, double aDw, double aDh,
                         mozilla::ErrorResult& aError) = 0;
  virtual void DrawImage(const CanvasImageSource& aImage, double aSx,
                         double aSy, double aSw, double aSh, double aDx,
                         double aDy, double aDw, double aDh,
                         mozilla::ErrorResult& aError) = 0;

  //
  // CanvasPathDrawingStyles
  //
  virtual double LineWidth() = 0;
  virtual void SetLineWidth(double aWidth) = 0;
  virtual void GetLineCap(nsAString& aLinecapStyle) = 0;
  virtual void SetLineCap(const nsAString& aLinecapStyle) = 0;
  virtual void GetLineJoin(nsAString& aLinejoinStyle,
                           mozilla::ErrorResult& aError) = 0;
  virtual void SetLineJoin(const nsAString& aLinejoinStyle) = 0;
  virtual double MiterLimit() = 0;
  virtual void SetMiterLimit(double aMiter) = 0;
  virtual void SetLineDash(const Sequence<double>& aSegments,
                           mozilla::ErrorResult& aRv) = 0;
  virtual void GetLineDash(nsTArray<double>& aSegments) const = 0;
  virtual void SetLineDashOffset(double aOffset) = 0;
  virtual double LineDashOffset() const = 0;

  //
  // CanvasPath
  //
  virtual void ClosePath() = 0;
  virtual void MoveTo(double aX, double aY) = 0;
  virtual void LineTo(double aX, double aY) = 0;
  virtual void QuadraticCurveTo(double aCpx, double aCpy, double aX,
                                double aY) = 0;
  virtual void BezierCurveTo(double aCp1x, double aCp1y, double aCp2x,
                             double aCp2y, double aX, double aY) = 0;
  virtual void ArcTo(double aX1, double aY1, double aX2, double aY2,
                     double aRadius, mozilla::ErrorResult& aError) = 0;
  virtual void Rect(double aX, double aY, double aW, double aH) = 0;
  virtual void Arc(double aX, double aY, double aRadius, double aStartAngle,
                   double aEndAngle, bool aAnticlockwise,
                   mozilla::ErrorResult& aError) = 0;
  virtual void Ellipse(double aX, double aY, double aRadiusX, double aRadiusY,
                       double aRotation, double aStartAngle, double aEndAngle,
                       bool aAnticlockwise, ErrorResult& aError) = 0;
};

}  // namespace mozilla::dom

#endif /* BasicRenderingContext2D_h */