Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(364)

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/BaseRenderingContext2D.h

Issue 1710633002: Pull up a subset of CanvasRenderingContext2D into BaseRenderingContext2D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixup. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BaseRenderingContext2D_h
6 #define BaseRenderingContext2D_h
7
8 #include "bindings/core/v8/UnionTypesCore.h"
9 #include "bindings/modules/v8/UnionTypesModules.h"
10 #include "core/html/canvas/CanvasRenderingContext.h"
11 #include "modules/ModulesExport.h"
12 #include "modules/canvas2d/CanvasPathMethods.h"
13 #include "modules/canvas2d/CanvasRenderingContext2DState.h"
14
15 namespace blink {
16
17 class CanvasImageSource;
18 class Color;
19 class Image;
20 class ImageBuffer;
21 class Path2D;
22 class SVGMatrixTearOff;
23
24 typedef HTMLImageElementOrHTMLVideoElementOrHTMLCanvasElementOrImageBitmap Canva sImageSourceUnion;
25
26 class MODULES_EXPORT BaseRenderingContext2D : public WillBeGarbageCollectedMixin , public CanvasPathMethods {
27 public:
28 ~BaseRenderingContext2D() override;
29
30 void strokeStyle(StringOrCanvasGradientOrCanvasPattern&) const;
31 void setStrokeStyle(const StringOrCanvasGradientOrCanvasPattern&);
32
33 void fillStyle(StringOrCanvasGradientOrCanvasPattern&) const;
34 void setFillStyle(const StringOrCanvasGradientOrCanvasPattern&);
35
36 double lineWidth() const;
37 void setLineWidth(double);
38
39 String lineCap() const;
40 void setLineCap(const String&);
41
42 String lineJoin() const;
43 void setLineJoin(const String&);
44
45 double miterLimit() const;
46 void setMiterLimit(double);
47
48 const Vector<double>& getLineDash() const;
49 void setLineDash(const Vector<double>&);
50
51 double lineDashOffset() const;
52 void setLineDashOffset(double);
53
54 double shadowOffsetX() const;
55 void setShadowOffsetX(double);
56
57 double shadowOffsetY() const;
58 void setShadowOffsetY(double);
59
60 double shadowBlur() const;
61 void setShadowBlur(double);
62
63 String shadowColor() const;
64 void setShadowColor(const String&);
65
66 double globalAlpha() const;
67 void setGlobalAlpha(double);
68
69 String globalCompositeOperation() const;
70 void setGlobalCompositeOperation(const String&);
71
72 String filter() const;
73 void setFilter(const String&);
74
75 void save();
76 void restore();
77
78 PassRefPtrWillBeRawPtr<SVGMatrixTearOff> currentTransform() const;
79 void setCurrentTransform(PassRefPtrWillBeRawPtr<SVGMatrixTearOff>);
80
81 void scale(double sx, double sy);
82 void rotate(double angleInRadians);
83 void translate(double tx, double ty);
84 void transform(double m11, double m12, double m21, double m22, double dx, do uble dy);
85 void setTransform(double m11, double m12, double m21, double m22, double dx, double dy);
86 void resetTransform();
87
88 void beginPath();
89
90 void fill(const String& winding = "nonzero");
91 void fill(Path2D*, const String& winding = "nonzero");
92 void stroke();
93 void stroke(Path2D*);
94 void clip(const String& winding = "nonzero");
95 void clip(Path2D*, const String& winding = "nonzero");
96
97 bool isPointInPath(const double x, const double y, const String& winding = " nonzero");
98 bool isPointInPath(Path2D*, const double x, const double y, const String& wi nding = "nonzero");
99 bool isPointInStroke(const double x, const double y);
100 bool isPointInStroke(Path2D*, const double x, const double y);
101
102 void clearRect(double x, double y, double width, double height);
103 void fillRect(double x, double y, double width, double height);
104 void strokeRect(double x, double y, double width, double height);
105
106 void drawImage(const CanvasImageSourceUnion&, double x, double y, ExceptionS tate&);
107 void drawImage(const CanvasImageSourceUnion&, double x, double y, double wid th, double height, ExceptionState&);
108 void drawImage(const CanvasImageSourceUnion&, double sx, double sy, double s w, double sh, double dx, double dy, double dw, double dh, ExceptionState&);
109 void drawImage(CanvasImageSource*, double sx, double sy, double sw, double s h, double dx, double dy, double dw, double dh, ExceptionState&);
110
111 CanvasGradient* createLinearGradient(double x0, double y0, double x1, double y1);
112 CanvasGradient* createRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1, ExceptionState&);
113 CanvasPattern* createPattern(const CanvasImageSourceUnion&, const String& re petitionType, ExceptionState&);
114
115 bool imageSmoothingEnabled() const;
116 void setImageSmoothingEnabled(bool);
117 String imageSmoothingQuality() const;
118 void setImageSmoothingQuality(const String&);
119
120 virtual bool originClean() const = 0;
121 virtual void setOriginTainted() = 0;
122 virtual bool wouldTaintOrigin(CanvasImageSource*) = 0;
123
124 virtual int width() const = 0;
125 virtual int height() const = 0;
126
127 virtual bool hasImageBuffer() const = 0;
128 virtual ImageBuffer* imageBuffer() const = 0;
129
130 virtual bool parseColorOrCurrentColor(Color&, const String& colorString) con st = 0;
131
132 virtual SkCanvas* drawingCanvas() const = 0;
133 virtual SkCanvas* existingDrawingCanvas() const = 0;
134 virtual void disableDeferral(DisableDeferralReason) = 0;
135
136 virtual AffineTransform baseTransform() const = 0;
137
138 virtual void didDraw(const SkIRect& dirtyRect) = 0;
139
140 virtual bool stateHasFilter() = 0;
141 virtual SkImageFilter* stateGetFilter() = 0;
142
143 virtual void validateStateStack() = 0;
144
145 virtual bool hasAlpha() const = 0;
146
147 DECLARE_VIRTUAL_TRACE();
148
149 protected:
150 BaseRenderingContext2D();
151
152 CanvasRenderingContext2DState& modifiableState();
153 const CanvasRenderingContext2DState& state() const { return *m_stateStack.la st(); }
154
155 bool computeDirtyRect(const FloatRect& localBounds, SkIRect*);
156 bool computeDirtyRect(const FloatRect& localBounds, const SkIRect& transform edClipBounds, SkIRect*);
157
158 void drawForText(const Font&, const TextRunPaintInfo&, const FloatPoint& loc ation, CanvasRenderingContext2DState::PaintType);
159
160 void inflateStrokeRect(FloatRect&) const;
161
162 enum DrawType {
163 ClipFill, // Fill that is already known to cover the current clip
164 UntransformedUnclippedFill
165 };
166
167 void checkOverdraw(const SkRect&, const SkPaint*, CanvasRenderingContext2DSt ate::ImageType, DrawType);
168
169 WillBeHeapVector<OwnPtrWillBeMember<CanvasRenderingContext2DState>> m_stateS tack;
170 AntiAliasingMode m_clipAntialiasing;
171
172 private:
173 void realizeSaves();
174
175 bool shouldDrawImageAntialiased(const FloatRect& destRect) const;
176
177 template<typename DrawFunc, typename ContainsFunc>
178 bool draw(const DrawFunc&, const ContainsFunc&, const SkRect& bounds, Canvas RenderingContext2DState::PaintType, CanvasRenderingContext2DState::ImageType = C anvasRenderingContext2DState::NoImage);
179 void drawPathInternal(const Path&, CanvasRenderingContext2DState::PaintType, SkPath::FillType = SkPath::kWinding_FillType);
180 void drawImageInternal(SkCanvas*, CanvasImageSource*, Image*, const FloatRec t& srcRect, const FloatRect& dstRect, const SkPaint*);
181 void clipInternal(const Path&, const String& windingRuleString);
182
183 bool isPointInPathInternal(const Path&, const double x, const double y, cons t String& windingRuleString);
184 bool isPointInStrokeInternal(const Path&, const double x, const double y);
185
186 template<typename DrawFunc>
187 void compositedDraw(const DrawFunc&, SkCanvas*, CanvasRenderingContext2DStat e::PaintType, CanvasRenderingContext2DState::ImageType);
188
189 void clearCanvas();
190 bool rectContainsTransformedRect(const FloatRect&, const SkIRect&) const;
191 };
192
193 } // namespace blink
194
195 #endif // BaseRenderingContext2D_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698