gfx/2d/PathSkia.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:9e4443fd9c51
1 /* -*- Mode: C++; tab-width: 20; 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 MOZILLA_GFX_PATH_SKIA_H_
7 #define MOZILLA_GFX_PATH_SKIA_H_
8
9 #include "2D.h"
10 #include "skia/SkPath.h"
11
12 namespace mozilla {
13 namespace gfx {
14
15 class PathSkia;
16
17 class PathBuilderSkia : public PathBuilder
18 {
19 public:
20 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathBuilderSkia)
21 PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath, FillRule aFillRule);
22 PathBuilderSkia(FillRule aFillRule);
23
24 virtual void MoveTo(const Point &aPoint);
25 virtual void LineTo(const Point &aPoint);
26 virtual void BezierTo(const Point &aCP1,
27 const Point &aCP2,
28 const Point &aCP3);
29 virtual void QuadraticBezierTo(const Point &aCP1,
30 const Point &aCP2);
31 virtual void Close();
32 virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle,
33 float aEndAngle, bool aAntiClockwise = false);
34 virtual Point CurrentPoint() const;
35 virtual TemporaryRef<Path> Finish();
36
37 void AppendPath(const SkPath &aPath);
38
39 private:
40
41 void SetFillRule(FillRule aFillRule);
42
43 SkPath mPath;
44 FillRule mFillRule;
45 };
46
47 class PathSkia : public Path
48 {
49 public:
50 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(PathSkia)
51 PathSkia(SkPath& aPath, FillRule aFillRule)
52 : mFillRule(aFillRule)
53 {
54 mPath.swap(aPath);
55 }
56
57 virtual BackendType GetBackendType() const { return BackendType::SKIA; }
58
59 virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
60 virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
61 FillRule aFillRule = FillRule::FILL_WINDING) const;
62
63 virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
64
65 virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
66 const Point &aPoint,
67 const Matrix &aTransform) const;
68
69 virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
70
71 virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
72 const Matrix &aTransform = Matrix()) const;
73
74 virtual void StreamToSink(PathSink *aSink) const;
75
76 virtual FillRule GetFillRule() const { return mFillRule; }
77
78 const SkPath& GetPath() const { return mPath; }
79
80 private:
81 friend class DrawTargetSkia;
82
83 SkPath mPath;
84 FillRule mFillRule;
85 };
86
87 }
88 }
89
90 #endif /* MOZILLA_GFX_PATH_SKIA_H_ */

mercurial