| OLD | NEW |
| 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 #include "SkDashPathEffect.h" | 8 #include "SkDashPathEffect.h" |
| 9 | 9 |
| 10 #include "SkDashPathPriv.h" | 10 #include "SkDashPathPriv.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 rect->outset(radius, radius); | 52 rect->outset(radius, radius); |
| 53 } | 53 } |
| 54 | 54 |
| 55 // Attempt to trim the line to minimally cover the cull rect (currently | 55 // Attempt to trim the line to minimally cover the cull rect (currently |
| 56 // only works for horizontal and vertical lines). | 56 // only works for horizontal and vertical lines). |
| 57 // Return true if processing should continue; false otherwise. | 57 // Return true if processing should continue; false otherwise. |
| 58 static bool cull_line(SkPoint* pts, const SkStrokeRec& rec, | 58 static bool cull_line(SkPoint* pts, const SkStrokeRec& rec, |
| 59 const SkMatrix& ctm, const SkRect* cullRect, | 59 const SkMatrix& ctm, const SkRect* cullRect, |
| 60 const SkScalar intervalLength) { | 60 const SkScalar intervalLength) { |
| 61 if (NULL == cullRect) { | 61 if (nullptr == cullRect) { |
| 62 SkASSERT(false); // Shouldn't ever occur in practice | 62 SkASSERT(false); // Shouldn't ever occur in practice |
| 63 return false; | 63 return false; |
| 64 } | 64 } |
| 65 | 65 |
| 66 SkScalar dx = pts[1].x() - pts[0].x(); | 66 SkScalar dx = pts[1].x() - pts[0].x(); |
| 67 SkScalar dy = pts[1].y() - pts[0].y(); | 67 SkScalar dy = pts[1].y() - pts[0].y(); |
| 68 | 68 |
| 69 if ((dx && dy) || (!dx && !dy)) { | 69 if ((dx && dy) || (!dx && !dy)) { |
| 70 return false; | 70 return false; |
| 71 } | 71 } |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 buffer.writeScalarArray(fIntervals, fCount); | 360 buffer.writeScalarArray(fIntervals, fCount); |
| 361 } | 361 } |
| 362 | 362 |
| 363 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { | 363 SkFlattenable* SkDashPathEffect::CreateProc(SkReadBuffer& buffer) { |
| 364 const SkScalar phase = buffer.readScalar(); | 364 const SkScalar phase = buffer.readScalar(); |
| 365 uint32_t count = buffer.getArrayCount(); | 365 uint32_t count = buffer.getArrayCount(); |
| 366 SkAutoSTArray<32, SkScalar> intervals(count); | 366 SkAutoSTArray<32, SkScalar> intervals(count); |
| 367 if (buffer.readScalarArray(intervals.get(), count)) { | 367 if (buffer.readScalarArray(intervals.get(), count)) { |
| 368 return Create(intervals.get(), SkToInt(count), phase); | 368 return Create(intervals.get(), SkToInt(count), phase); |
| 369 } | 369 } |
| 370 return NULL; | 370 return nullptr; |
| 371 } | 371 } |
| 372 | 372 |
| 373 #ifndef SK_IGNORE_TO_STRING | 373 #ifndef SK_IGNORE_TO_STRING |
| 374 void SkDashPathEffect::toString(SkString* str) const { | 374 void SkDashPathEffect::toString(SkString* str) const { |
| 375 str->appendf("SkDashPathEffect: ("); | 375 str->appendf("SkDashPathEffect: ("); |
| 376 str->appendf("count: %d phase %.2f intervals: (", fCount, fPhase); | 376 str->appendf("count: %d phase %.2f intervals: (", fCount, fPhase); |
| 377 for (int i = 0; i < fCount; ++i) { | 377 for (int i = 0; i < fCount; ++i) { |
| 378 str->appendf("%.2f", fIntervals[i]); | 378 str->appendf("%.2f", fIntervals[i]); |
| 379 if (i < fCount-1) { | 379 if (i < fCount-1) { |
| 380 str->appendf(", "); | 380 str->appendf(", "); |
| 381 } | 381 } |
| 382 } | 382 } |
| 383 str->appendf("))"); | 383 str->appendf("))"); |
| 384 } | 384 } |
| 385 #endif | 385 #endif |
| OLD | NEW |