| 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 // size in pixels of each partition per axis, adjust this knob | 10 // size in pixels of each partition per axis, adjust this knob |
| 11 static const int kPartitionSize = 15; | 11 static const int kPartitionSize = 25; |
| 12 | 12 |
| 13 /** | 13 /** |
| 14 * 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. |
| 15 */ | 15 */ |
| 16 static SkScalar approx_arc_length(SkPoint* points, int count) { | 16 static SkScalar approx_arc_length(SkPoint* points, int count) { |
| 17 if (count < 2) { | 17 if (count < 2) { |
| 18 return 0; | 18 return 0; |
| 19 } | 19 } |
| 20 SkScalar arcLength = 0; | 20 SkScalar arcLength = 0; |
| 21 for (int i = 0; i < count - 1; i++) { | 21 for (int i = 0; i < count - 1; i++) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 46 patch.getRightPoints(pts); | 46 patch.getRightPoints(pts); |
| 47 matrix->mapPoints(pts, 4); | 47 matrix->mapPoints(pts, 4); |
| 48 SkScalar rightLength = approx_arc_length(pts, 4); | 48 SkScalar rightLength = approx_arc_length(pts, 4); |
| 49 | 49 |
| 50 // 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 |
| 51 int lodX = static_cast<int>(SkMaxScalar(topLength, bottomLength) / kPartitio
nSize); | 51 int lodX = static_cast<int>(SkMaxScalar(topLength, bottomLength) / kPartitio
nSize); |
| 52 int lodY = static_cast<int>(SkMaxScalar(leftLength, rightLength) / kPartitio
nSize); | 52 int lodY = static_cast<int>(SkMaxScalar(leftLength, rightLength) / kPartitio
nSize); |
| 53 | 53 |
| 54 return SkISize::Make(SkMax32(4, lodX), SkMax32(4, lodY)); | 54 return SkISize::Make(SkMax32(4, lodX), SkMax32(4, lodY)); |
| 55 } | 55 } |
| OLD | NEW |