| 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 "Sk1DPathEffect.h" | 10 #include "Sk1DPathEffect.h" |
| 11 #include "SkFlattenableBuffers.h" | 11 #include "SkReadBuffer.h" |
| 12 #include "SkWriteBuffer.h" |
| 12 #include "SkPathMeasure.h" | 13 #include "SkPathMeasure.h" |
| 13 | 14 |
| 14 bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, | 15 bool Sk1DPathEffect::filterPath(SkPath* dst, const SkPath& src, |
| 15 SkStrokeRec*, const SkRect*) const { | 16 SkStrokeRec*, const SkRect*) const { |
| 16 SkPathMeasure meas(src, false); | 17 SkPathMeasure meas(src, false); |
| 17 do { | 18 do { |
| 18 SkScalar length = meas.getLength(); | 19 SkScalar length = meas.getLength(); |
| 19 SkScalar distance = this->begin(length); | 20 SkScalar distance = this->begin(length); |
| 20 while (distance < length) { | 21 while (distance < length) { |
| 21 SkScalar delta = this->next(dst, distance, meas); | 22 SkScalar delta = this->next(dst, distance, meas); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 case SkPath::kClose_Verb: | 140 case SkPath::kClose_Verb: |
| 140 dst->close(); | 141 dst->close(); |
| 141 break; | 142 break; |
| 142 default: | 143 default: |
| 143 SkDEBUGFAIL("unknown verb"); | 144 SkDEBUGFAIL("unknown verb"); |
| 144 break; | 145 break; |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 | 149 |
| 149 SkPath1DPathEffect::SkPath1DPathEffect(SkFlattenableReadBuffer& buffer) { | 150 SkPath1DPathEffect::SkPath1DPathEffect(SkReadBuffer& buffer) { |
| 150 fAdvance = buffer.readScalar(); | 151 fAdvance = buffer.readScalar(); |
| 151 if (fAdvance > 0) { | 152 if (fAdvance > 0) { |
| 152 buffer.readPath(&fPath); | 153 buffer.readPath(&fPath); |
| 153 fInitialOffset = buffer.readScalar(); | 154 fInitialOffset = buffer.readScalar(); |
| 154 fStyle = (Style) buffer.readUInt(); | 155 fStyle = (Style) buffer.readUInt(); |
| 155 } else { | 156 } else { |
| 156 SkDEBUGF(("SkPath1DPathEffect can't use advance <= 0\n")); | 157 SkDEBUGF(("SkPath1DPathEffect can't use advance <= 0\n")); |
| 157 // Make Coverity happy. | 158 // Make Coverity happy. |
| 158 fInitialOffset = 0; | 159 fInitialOffset = 0; |
| 159 fStyle = kStyleCount; | 160 fStyle = kStyleCount; |
| 160 } | 161 } |
| 161 } | 162 } |
| 162 | 163 |
| 163 SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) const { | 164 SkScalar SkPath1DPathEffect::begin(SkScalar contourLength) const { |
| 164 return fInitialOffset; | 165 return fInitialOffset; |
| 165 } | 166 } |
| 166 | 167 |
| 167 void SkPath1DPathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { | 168 void SkPath1DPathEffect::flatten(SkWriteBuffer& buffer) const { |
| 168 this->INHERITED::flatten(buffer); | 169 this->INHERITED::flatten(buffer); |
| 169 buffer.writeScalar(fAdvance); | 170 buffer.writeScalar(fAdvance); |
| 170 if (fAdvance > 0) { | 171 if (fAdvance > 0) { |
| 171 buffer.writePath(fPath); | 172 buffer.writePath(fPath); |
| 172 buffer.writeScalar(fInitialOffset); | 173 buffer.writeScalar(fInitialOffset); |
| 173 buffer.writeUInt(fStyle); | 174 buffer.writeUInt(fStyle); |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 | 177 |
| 177 SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance, | 178 SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 191 } break; | 192 } break; |
| 192 case kMorph_Style: | 193 case kMorph_Style: |
| 193 morphpath(dst, fPath, meas, distance); | 194 morphpath(dst, fPath, meas, distance); |
| 194 break; | 195 break; |
| 195 default: | 196 default: |
| 196 SkDEBUGFAIL("unknown Style enum"); | 197 SkDEBUGFAIL("unknown Style enum"); |
| 197 break; | 198 break; |
| 198 } | 199 } |
| 199 return fAdvance; | 200 return fAdvance; |
| 200 } | 201 } |
| OLD | NEW |