| 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 |
| 77 Sk2DPathEffect::Sk2DPathEffect(SkReadBuffer& buffer) { |
| 78 buffer.readMatrix(&fMatrix); |
| 79 fMatrixIsInvertible = fMatrix.invert(&fInverse); |
| 80 } |
| 81 #endif |
| 82 |
| 76 /////////////////////////////////////////////////////////////////////////////// | 83 /////////////////////////////////////////////////////////////////////////////// |
| 77 | 84 |
| 78 bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src, | 85 bool SkLine2DPathEffect::filterPath(SkPath* dst, const SkPath& src, |
| 79 SkStrokeRec* rec, const SkRect* cullRect) const { | 86 SkStrokeRec* rec, const SkRect* cullRect) const { |
| 80 if (this->INHERITED::filterPath(dst, src, rec, cullRect)) { | 87 if (this->INHERITED::filterPath(dst, src, rec, cullRect)) { |
| 81 rec->setStrokeStyle(fWidth); | 88 rec->setStrokeStyle(fWidth); |
| 82 return true; | 89 return true; |
| 83 } | 90 } |
| 84 return false; | 91 return false; |
| 85 } | 92 } |
| 86 | 93 |
| 87 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 { |
| 88 if (ucount > 1) { | 95 if (ucount > 1) { |
| 89 SkPoint src[2], dstP[2]; | 96 SkPoint src[2], dstP[2]; |
| 90 | 97 |
| 91 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); |
| 92 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); |
| 93 this->getMatrix().mapPoints(dstP, src, 2); | 100 this->getMatrix().mapPoints(dstP, src, 2); |
| 94 | 101 |
| 95 dst->moveTo(dstP[0]); | 102 dst->moveTo(dstP[0]); |
| 96 dst->lineTo(dstP[1]); | 103 dst->lineTo(dstP[1]); |
| 97 } | 104 } |
| 98 } | 105 } |
| 99 | 106 |
| 107 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 108 SkLine2DPathEffect::SkLine2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer)
{ |
| 109 fWidth = buffer.readScalar(); |
| 110 } |
| 111 #endif |
| 112 |
| 100 SkFlattenable* SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) { | 113 SkFlattenable* SkLine2DPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 101 SkMatrix matrix; | 114 SkMatrix matrix; |
| 102 buffer.readMatrix(&matrix); | 115 buffer.readMatrix(&matrix); |
| 103 SkScalar width = buffer.readScalar(); | 116 SkScalar width = buffer.readScalar(); |
| 104 return SkLine2DPathEffect::Create(width, matrix); | 117 return SkLine2DPathEffect::Create(width, matrix); |
| 105 } | 118 } |
| 106 | 119 |
| 107 void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const { | 120 void SkLine2DPathEffect::flatten(SkWriteBuffer &buffer) const { |
| 108 buffer.writeMatrix(this->getMatrix()); | 121 buffer.writeMatrix(this->getMatrix()); |
| 109 buffer.writeScalar(fWidth); | 122 buffer.writeScalar(fWidth); |
| 110 } | 123 } |
| 111 | 124 |
| 112 /////////////////////////////////////////////////////////////////////////////// | 125 /////////////////////////////////////////////////////////////////////////////// |
| 113 | 126 |
| 114 SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) | 127 SkPath2DPathEffect::SkPath2DPathEffect(const SkMatrix& m, const SkPath& p) |
| 115 : INHERITED(m), fPath(p) { | 128 : INHERITED(m), fPath(p) { |
| 116 } | 129 } |
| 117 | 130 |
| 131 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 132 SkPath2DPathEffect::SkPath2DPathEffect(SkReadBuffer& buffer) : INHERITED(buffer)
{ |
| 133 buffer.readPath(&fPath); |
| 134 } |
| 135 #endif |
| 136 |
| 118 SkFlattenable* SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) { | 137 SkFlattenable* SkPath2DPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 119 SkMatrix matrix; | 138 SkMatrix matrix; |
| 120 buffer.readMatrix(&matrix); | 139 buffer.readMatrix(&matrix); |
| 121 SkPath path; | 140 SkPath path; |
| 122 buffer.readPath(&path); | 141 buffer.readPath(&path); |
| 123 return SkPath2DPathEffect::Create(matrix, path); | 142 return SkPath2DPathEffect::Create(matrix, path); |
| 124 } | 143 } |
| 125 | 144 |
| 126 void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const { | 145 void SkPath2DPathEffect::flatten(SkWriteBuffer& buffer) const { |
| 127 buffer.writeMatrix(this->getMatrix()); | 146 buffer.writeMatrix(this->getMatrix()); |
| 128 buffer.writePath(fPath); | 147 buffer.writePath(fPath); |
| 129 } | 148 } |
| 130 | 149 |
| 131 void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, | 150 void SkPath2DPathEffect::next(const SkPoint& loc, int u, int v, |
| 132 SkPath* dst) const { | 151 SkPath* dst) const { |
| 133 dst->addPath(fPath, loc.fX, loc.fY); | 152 dst->addPath(fPath, loc.fX, loc.fY); |
| 134 } | 153 } |
| OLD | NEW |