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

Side by Side Diff: include/effects/Sk2DPathEffect.h

Issue 166583002: Factory methods for heap-allocated SkPathEffect and SkXfermode objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update experimental/PdfViewer Created 6 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
« no previous file with comments | « include/effects/Sk1DPathEffect.h ('k') | include/effects/SkAvoidXfermode.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef Sk2DPathEffect_DEFINED 8 #ifndef Sk2DPathEffect_DEFINED
9 #define Sk2DPathEffect_DEFINED 9 #define Sk2DPathEffect_DEFINED
10 10
11 #include "SkPath.h" 11 #include "SkPath.h"
12 #include "SkPathEffect.h" 12 #include "SkPathEffect.h"
13 #include "SkMatrix.h" 13 #include "SkMatrix.h"
14 14
15 class SK_API Sk2DPathEffect : public SkPathEffect { 15 class SK_API Sk2DPathEffect : public SkPathEffect {
16 public: 16 public:
17 Sk2DPathEffect(const SkMatrix& mat); 17 static Sk2DPathEffect* Create(const SkMatrix& mat) {
18 return SkNEW_ARGS(Sk2DPathEffect, (mat));
19 }
18 20
19 virtual bool filterPath(SkPath*, const SkPath&, 21 virtual bool filterPath(SkPath*, const SkPath&,
20 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 22 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
21 23
22 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) 24 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect)
23 25
24 protected: 26 protected:
25 /** New virtual, to be overridden by subclasses. 27 /** New virtual, to be overridden by subclasses.
26 This is called once from filterPath, and provides the 28 This is called once from filterPath, and provides the
27 uv parameter bounds for the path. Subsequent calls to 29 uv parameter bounds for the path. Subsequent calls to
28 next() will receive u and v values within these bounds, 30 next() will receive u and v values within these bounds,
29 and then a call to end() will signal the end of processing. 31 and then a call to end() will signal the end of processing.
30 */ 32 */
31 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const; 33 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const;
32 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const; 34 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const;
33 virtual void end(SkPath* dst) const; 35 virtual void end(SkPath* dst) const;
34 36
35 /** Low-level virtual called per span of locations in the u-direction. 37 /** Low-level virtual called per span of locations in the u-direction.
36 The default implementation calls next() repeatedly with each 38 The default implementation calls next() repeatedly with each
37 location. 39 location.
38 */ 40 */
39 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const; 41 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const;
40 42
41 const SkMatrix& getMatrix() const { return fMatrix; } 43 const SkMatrix& getMatrix() const { return fMatrix; }
42 44
43 // protected so that subclasses can call this during unflattening 45 // protected so that subclasses can call this during unflattening
44 Sk2DPathEffect(SkReadBuffer&); 46 Sk2DPathEffect(SkReadBuffer&);
45 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 47 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
46 48
49 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
50 public:
51 #endif
52 Sk2DPathEffect(const SkMatrix& mat);
53
47 private: 54 private:
48 SkMatrix fMatrix, fInverse; 55 SkMatrix fMatrix, fInverse;
49 bool fMatrixIsInvertible; 56 bool fMatrixIsInvertible;
50 57
51 // illegal 58 // illegal
52 Sk2DPathEffect(const Sk2DPathEffect&); 59 Sk2DPathEffect(const Sk2DPathEffect&);
53 Sk2DPathEffect& operator=(const Sk2DPathEffect&); 60 Sk2DPathEffect& operator=(const Sk2DPathEffect&);
54 61
55 friend class Sk2DPathEffectBlitter; 62 friend class Sk2DPathEffectBlitter;
56 typedef SkPathEffect INHERITED; 63 typedef SkPathEffect INHERITED;
57 }; 64 };
58 65
59 class SK_API SkLine2DPathEffect : public Sk2DPathEffect { 66 class SK_API SkLine2DPathEffect : public Sk2DPathEffect {
60 public: 67 public:
61 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) 68 static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) {
62 : Sk2DPathEffect(matrix), fWidth(width) {} 69 return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix));
70 }
63 71
64 virtual bool filterPath(SkPath* dst, const SkPath& src, 72 virtual bool filterPath(SkPath* dst, const SkPath& src,
65 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; 73 SkStrokeRec*, const SkRect*) const SK_OVERRIDE;
66 74
67 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) 75 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect)
68 76
69 protected: 77 protected:
70 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; 78 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE;
71 79
72 SkLine2DPathEffect(SkReadBuffer&); 80 SkLine2DPathEffect(SkReadBuffer&);
73 81
74 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 82 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
75 83
84 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
85 public:
86 #endif
87 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix)
88 : Sk2DPathEffect(matrix), fWidth(width) {}
89
76 private: 90 private:
77 SkScalar fWidth; 91 SkScalar fWidth;
78 92
79 typedef Sk2DPathEffect INHERITED; 93 typedef Sk2DPathEffect INHERITED;
80 }; 94 };
81 95
82 class SK_API SkPath2DPathEffect : public Sk2DPathEffect { 96 class SK_API SkPath2DPathEffect : public Sk2DPathEffect {
83 public: 97 public:
84 /** 98 /**
85 * Stamp the specified path to fill the shape, using the matrix to define 99 * Stamp the specified path to fill the shape, using the matrix to define
86 * the latice. 100 * the latice.
87 */ 101 */
88 SkPath2DPathEffect(const SkMatrix&, const SkPath&); 102 static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path ) {
103 return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path));
104 }
89 105
90 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) 106 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect)
91 107
92 protected: 108 protected:
93 SkPath2DPathEffect(SkReadBuffer& buffer); 109 SkPath2DPathEffect(SkReadBuffer& buffer);
94 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; 110 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE;
95 111
96 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; 112 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE;
97 113
114 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS
115 public:
116 #endif
117 SkPath2DPathEffect(const SkMatrix&, const SkPath&);
118
98 private: 119 private:
99 SkPath fPath; 120 SkPath fPath;
100 121
101 typedef Sk2DPathEffect INHERITED; 122 typedef Sk2DPathEffect INHERITED;
102 }; 123 };
103 124
104 #endif 125 #endif
OLDNEW
« no previous file with comments | « include/effects/Sk1DPathEffect.h ('k') | include/effects/SkAvoidXfermode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698