1 : /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Corporation code.
16 : *
17 : * The Initial Developer of the Original Code is Mozilla Foundation.
18 : * Portions created by the Initial Developer are Copyright (C) 2011
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Matt Woodrow <mwoodrow@mozilla.com>
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef MOZILLA_GFX_PATH_SKIA_H_
39 : #define MOZILLA_GFX_PATH_SKIA_H_
40 :
41 : #include "2D.h"
42 : #include "skia/SkPath.h"
43 :
44 : namespace mozilla {
45 : namespace gfx {
46 :
47 : class PathSkia;
48 :
49 : class PathBuilderSkia : public PathBuilder
50 0 : {
51 : public:
52 : PathBuilderSkia(const Matrix& aTransform, const SkPath& aPath, FillRule aFillRule);
53 : PathBuilderSkia(FillRule aFillRule);
54 :
55 : virtual void MoveTo(const Point &aPoint);
56 : virtual void LineTo(const Point &aPoint);
57 : virtual void BezierTo(const Point &aCP1,
58 : const Point &aCP2,
59 : const Point &aCP3);
60 : virtual void QuadraticBezierTo(const Point &aCP1,
61 : const Point &aCP2);
62 : virtual void Close();
63 : virtual void Arc(const Point &aOrigin, float aRadius, float aStartAngle,
64 : float aEndAngle, bool aAntiClockwise = false);
65 : virtual Point CurrentPoint() const;
66 : virtual TemporaryRef<Path> Finish();
67 :
68 : private:
69 : void SetFillRule(FillRule aFillRule);
70 :
71 : SkPath mPath;
72 : FillRule mFillRule;
73 : };
74 :
75 : class PathSkia : public Path
76 0 : {
77 : public:
78 0 : PathSkia(SkPath& aPath, FillRule aFillRule)
79 0 : : mFillRule(aFillRule)
80 : {
81 0 : mPath.swap(aPath);
82 0 : }
83 :
84 0 : virtual BackendType GetBackendType() const { return BACKEND_SKIA; }
85 :
86 : virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
87 : virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
88 : FillRule aFillRule = FILL_WINDING) const;
89 :
90 : virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
91 :
92 : virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
93 :
94 : virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
95 : const Matrix &aTransform = Matrix()) const;
96 :
97 0 : virtual FillRule GetFillRule() const { return mFillRule; }
98 :
99 0 : const SkPath& GetPath() const { return mPath; }
100 :
101 : private:
102 : friend class DrawTargetSkia;
103 :
104 : SkPath mPath;
105 : FillRule mFillRule;
106 : };
107 :
108 : }
109 : }
110 :
111 : #endif /* MOZILLA_GFX_PATH_SKIA_H_ */
|