| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 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 "SkPatchUtils.h" | 8 #include "SkPatchUtils.h" |
| 9 | 9 |
| 10 #include "SkGeometry.h" | |
| 11 | |
| 12 // size in pixels of each partition per axis, adjust this knob | 10 // size in pixels of each partition per axis, adjust this knob |
| 13 static const int kPartitionSize = 30; | 11 static const int kPartitionSize = 15; |
| 14 | 12 |
| 15 /** | 13 /** |
| 16 * Calculate the approximate arc length given a bezier curve's control points. | 14 * Calculate the approximate arc length given a bezier curve's control points. |
| 17 */ | 15 */ |
| 18 static SkScalar approx_arc_length(SkPoint* points, int count) { | 16 static SkScalar approx_arc_length(SkPoint* points, int count) { |
| 19 if (count < 2) { | 17 if (count < 2) { |
| 20 return 0; | 18 return 0; |
| 21 } | 19 } |
| 22 SkScalar arcLength = 0; | 20 SkScalar arcLength = 0; |
| 23 for (int i = 0; i < count - 1; i++) { | 21 for (int i = 0; i < count - 1; i++) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 48 patch.getRightPoints(pts); | 46 patch.getRightPoints(pts); |
| 49 matrix->mapPoints(pts, 4); | 47 matrix->mapPoints(pts, 4); |
| 50 SkScalar rightLength = approx_arc_length(pts, 4); | 48 SkScalar rightLength = approx_arc_length(pts, 4); |
| 51 | 49 |
| 52 // Level of detail per axis, based on the larger side between top and bottom
or left and right | 50 // Level of detail per axis, based on the larger side between top and bottom
or left and right |
| 53 int lodX = static_cast<int>(SkMaxScalar(topLength, bottomLength) / kPartitio
nSize); | 51 int lodX = static_cast<int>(SkMaxScalar(topLength, bottomLength) / kPartitio
nSize); |
| 54 int lodY = static_cast<int>(SkMaxScalar(leftLength, rightLength) / kPartitio
nSize); | 52 int lodY = static_cast<int>(SkMaxScalar(leftLength, rightLength) / kPartitio
nSize); |
| 55 | 53 |
| 56 return SkISize::Make(SkMax32(4, lodX), SkMax32(4, lodY)); | 54 return SkISize::Make(SkMax32(4, lodX), SkMax32(4, lodY)); |
| 57 } | 55 } |
| OLD | NEW |