OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "Sk2DPathEffect.h" | 10 #include "Sk2DPathEffect.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) const {
} | 66 void Sk2DPathEffect::next(const SkPoint& loc, int u, int v, SkPath* dst) const {
} |
67 void Sk2DPathEffect::end(SkPath* dst) const {} | 67 void Sk2DPathEffect::end(SkPath* dst) const {} |
68 | 68 |
69 /////////////////////////////////////////////////////////////////////////////// | 69 /////////////////////////////////////////////////////////////////////////////// |
70 | 70 |
71 void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const { | 71 void Sk2DPathEffect::flatten(SkWriteBuffer& buffer) const { |
72 this->INHERITED::flatten(buffer); | 72 this->INHERITED::flatten(buffer); |
73 buffer.writeMatrix(fMatrix); | 73 buffer.writeMatrix(fMatrix); |
74 } | 74 } |
75 | 75 |
| 76 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
76 Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) { | 77 Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) { |
77 buffer.readMatrix(&fMatrix); | 78 buffer.readMatrix(&fMatrix); |
78 fMatrixIsInvertible = fMatrix.invert(&fInverse); | 79 fMatrixIsInvertible = fMatrix.invert(&fInverse); |
79 } | 80 } |
| 81 #endif |
80 | 82 |
81 /////////////////////////////////////////////////////////////////////////////// | 83 /////////////////////////////////////////////////////////////////////////////// |
82 | 84 |
83 bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src, | 85 bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src, |
84 SkStrokeRec* rec, const SkRect* cullRect) const { | 86 SkStrokeRec* rec, const SkRect* cullRect) const { |
85 if (this->INHERITED::filterPath(dst, src, rec, cullRect)) { | 87 if (this->INHERITED::filterPath(dst, src, rec, cullRect)) { |
86 rec->setStrokeStyle(fWidth); | 88 rec->setStrokeStyle(fWidth); |
87 return true; | 89 return true; |
88 } | 90 } |
89 return false; | 91 return false; |
90 } | 92 } |
91 | 93 |
92 void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const { | 94 void SkLine2DPathEffect::nextSpan(int u, int v, int ucount, SkPath* dst) const { |
93 if (ucount > 1) { | 95 if (ucount > 1) { |
94 SkPoint src[2], dstP[2]; | 96 SkPoint src[2], dstP[2]; |
95 | 97 |
96 src[0].set(SkIntToScalar(u) + SK_ScalarHalf, SkIntToScalar(v) + SK_Scala
rHalf); | 98 src[0].set(SkIntToScalar(u) + SK_ScalarHalf, SkIntToScalar(v) + SK_Scala
rHalf); |
97 src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf, SkIntToScalar(v) + S
K_ScalarHalf); | 99 src[1].set(SkIntToScalar(u+ucount) + SK_ScalarHalf, SkIntToScalar(v) + S
K_ScalarHalf); |
98 this->getMatrix().mapPoints(dstP, src, 2); | 100 this->getMatrix().mapPoints(dstP, src, 2); |
99 | 101 |
100 dst->moveTo(dstP[0]); | 102 dst->moveTo(dstP[0]); |
101 dst->lineTo(dstP[1]); | 103 dst->lineTo(dstP[1]); |
102 } | 104 } |
103 } | 105 } |
104 | 106 |
| 107 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
105 SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer)
{ | 108 SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer)
{ |
106 fWidth = buffer.readScalar(); | 109 fWidth = buffer.readScalar(); |
107 } | 110 } |
| 111 #endif |
| 112 |
| 113 SkFlattenable* SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 114 SkMatrix matrix; |
| 115 buffer.readMatrix(&matrix); |
| 116 SkScalar width = buffer.readScalar(); |
| 117 return SkLine2DPathEffect::Create(width, matrix); |
| 118 } |
108 | 119 |
109 void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const { | 120 void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const { |
110 this->INHERITED::flatten(buffer); | 121 buffer.writeMatrix(this->getMatrix()); |
111 buffer.writeScalar(fWidth); | 122 buffer.writeScalar(fWidth); |
112 } | 123 } |
113 | 124 |
114 /////////////////////////////////////////////////////////////////////////////// | 125 /////////////////////////////////////////////////////////////////////////////// |
115 | 126 |
116 SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) | 127 SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) |
117 : INHERITED(m), fPath(p) { | 128 : INHERITED(m), fPath(p) { |
118 } | 129 } |
119 | 130 |
120 SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer) | 131 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
121 : INHERITED(buffer) { | 132 SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer)
{ |
122 buffer.readPath(&fPath); | 133 buffer.readPath(&fPath); |
123 } | 134 } |
| 135 #endif |
| 136 |
| 137 SkFlattenable* SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 138 SkMatrix matrix; |
| 139 buffer.readMatrix(&matrix); |
| 140 SkPath path; |
| 141 buffer.readPath(&path); |
| 142 return SkPath2DPathEffect::Create(matrix, path); |
| 143 } |
124 | 144 |
125 void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const { | 145 void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const { |
126 this->INHERITED::flatten(buffer); | 146 buffer.writeMatrix(this->getMatrix()); |
127 buffer.writePath(fPath); | 147 buffer.writePath(fPath); |
128 } | 148 } |
129 | 149 |
130 void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, | 150 void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, |
131 SkPath* dst) const { | 151 SkPath* dst) const { |
132 dst->addPath(fPath, loc.fX, loc.fY); | 152 dst->addPath(fPath, loc.fX, loc.fY); |
133 } | 153 } |
OLD | NEW |