| 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" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 | 153 |
| 154 SkFlattenable* SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) { | 154 SkFlattenable* SkPath1DPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 155 SkScalar advance = buffer.readScalar(); | 155 SkScalar advance = buffer.readScalar(); |
| 156 if (advance > 0) { | 156 if (advance > 0) { |
| 157 SkPath path; | 157 SkPath path; |
| 158 buffer.readPath(&path); | 158 buffer.readPath(&path); |
| 159 SkScalar phase = buffer.readScalar(); | 159 SkScalar phase = buffer.readScalar(); |
| 160 Style style = (Style)buffer.readUInt(); | 160 Style style = (Style)buffer.readUInt(); |
| 161 return SkPath1DPathEffect::Create(path, advance, phase, style); | 161 return SkPath1DPathEffect::Create(path, advance, phase, style); |
| 162 } | 162 } |
| 163 return NULL; | 163 return nullptr; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SkPath1DPathEffect::flatten(SkWriteBuffer& buffer) const { | 166 void SkPath1DPathEffect::flatten(SkWriteBuffer& buffer) const { |
| 167 buffer.writeScalar(fAdvance); | 167 buffer.writeScalar(fAdvance); |
| 168 if (fAdvance > 0) { | 168 if (fAdvance > 0) { |
| 169 buffer.writePath(fPath); | 169 buffer.writePath(fPath); |
| 170 buffer.writeScalar(fInitialOffset); | 170 buffer.writeScalar(fInitialOffset); |
| 171 buffer.writeUInt(fStyle); | 171 buffer.writeUInt(fStyle); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance, | 175 SkScalar SkPath1DPathEffect::next(SkPath* dst, SkScalar distance, |
| 176 SkPathMeasure& meas) const { | 176 SkPathMeasure& meas) const { |
| 177 switch (fStyle) { | 177 switch (fStyle) { |
| 178 case kTranslate_Style: { | 178 case kTranslate_Style: { |
| 179 SkPoint pos; | 179 SkPoint pos; |
| 180 if (meas.getPosTan(distance, &pos, NULL)) { | 180 if (meas.getPosTan(distance, &pos, nullptr)) { |
| 181 dst->addPath(fPath, pos.fX, pos.fY); | 181 dst->addPath(fPath, pos.fX, pos.fY); |
| 182 } | 182 } |
| 183 } break; | 183 } break; |
| 184 case kRotate_Style: { | 184 case kRotate_Style: { |
| 185 SkMatrix matrix; | 185 SkMatrix matrix; |
| 186 if (meas.getMatrix(distance, &matrix)) { | 186 if (meas.getMatrix(distance, &matrix)) { |
| 187 dst->addPath(fPath, matrix); | 187 dst->addPath(fPath, matrix); |
| 188 } | 188 } |
| 189 } break; | 189 } break; |
| 190 case kMorph_Style: | 190 case kMorph_Style: |
| 191 morphpath(dst, fPath, meas, distance); | 191 morphpath(dst, fPath, meas, distance); |
| 192 break; | 192 break; |
| 193 default: | 193 default: |
| 194 SkDEBUGFAIL("unknown Style enum"); | 194 SkDEBUGFAIL("unknown Style enum"); |
| 195 break; | 195 break; |
| 196 } | 196 } |
| 197 return fAdvance; | 197 return fAdvance; |
| 198 } | 198 } |
| 199 | 199 |
| 200 | 200 |
| 201 #ifndef SK_IGNORE_TO_STRING | 201 #ifndef SK_IGNORE_TO_STRING |
| 202 void SkPath1DPathEffect::toString(SkString* str) const { | 202 void SkPath1DPathEffect::toString(SkString* str) const { |
| 203 str->appendf("SkPath1DPathEffect: ("); | 203 str->appendf("SkPath1DPathEffect: ("); |
| 204 // TODO: add path and style | 204 // TODO: add path and style |
| 205 str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset); | 205 str->appendf("advance: %.2f phase %.2f", fAdvance, fInitialOffset); |
| 206 str->appendf(")"); | 206 str->appendf(")"); |
| 207 } | 207 } |
| 208 #endif | 208 #endif |
| OLD | NEW |