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 "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 /** | 42 /** |
43 * Receives the 4 control points of the cubic bezier. | 43 * Receives the 4 control points of the cubic bezier. |
44 */ | 44 */ |
45 FwDCubicEvaluator(SkPoint a, SkPoint b, SkPoint c, SkPoint d) { | 45 FwDCubicEvaluator(SkPoint a, SkPoint b, SkPoint c, SkPoint d) { |
46 fPoints[0] = a; | 46 fPoints[0] = a; |
47 fPoints[1] = b; | 47 fPoints[1] = b; |
48 fPoints[2] = c; | 48 fPoints[2] = c; |
49 fPoints[3] = d; | 49 fPoints[3] = d; |
50 | 50 |
51 SkScalar cx[4], cy[4]; | 51 SkCubicToCoeff(fPoints, fCoefs); |
52 SkGetCubicCoeff(fPoints, cx, cy); | |
53 fCoefs[0].set(cx[0], cy[0]); | |
54 fCoefs[1].set(cx[1], cy[1]); | |
55 fCoefs[2].set(cx[2], cy[2]); | |
56 fCoefs[3].set(cx[3], cy[3]); | |
57 | 52 |
58 this->restart(1); | 53 this->restart(1); |
59 } | 54 } |
60 | 55 |
61 explicit FwDCubicEvaluator(const SkPoint points[4]) { | 56 explicit FwDCubicEvaluator(const SkPoint points[4]) { |
62 memcpy(fPoints, points, 4 * sizeof(SkPoint)); | 57 memcpy(fPoints, points, 4 * sizeof(SkPoint)); |
63 | 58 |
64 SkScalar cx[4], cy[4]; | 59 SkCubicToCoeff(fPoints, fCoefs); |
65 SkGetCubicCoeff(fPoints, cx, cy); | |
66 fCoefs[0].set(cx[0], cy[0]); | |
67 fCoefs[1].set(cx[1], cy[1]); | |
68 fCoefs[2].set(cx[2], cy[2]); | |
69 fCoefs[3].set(cx[3], cy[3]); | |
70 | 60 |
71 this->restart(1); | 61 this->restart(1); |
72 } | 62 } |
73 | 63 |
74 /** | 64 /** |
75 * Restarts the forward differences evaluator to the first value of t = 0. | 65 * Restarts the forward differences evaluator to the first value of t = 0. |
76 */ | 66 */ |
77 void restart(int divisions) { | 67 void restart(int divisions) { |
78 fDivisions = divisions; | 68 fDivisions = divisions; |
79 SkScalar h = 1.f / fDivisions; | 69 SkScalar h = 1.f / fDivisions; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 data->fIndices[i + 4] = data->fIndices[i + 2]; | 322 data->fIndices[i + 4] = data->fIndices[i + 2]; |
333 data->fIndices[i + 5] = (x + 1) * stride + y; | 323 data->fIndices[i + 5] = (x + 1) * stride + y; |
334 } | 324 } |
335 v = SkScalarClampMax(v + 1.f / lodY, 1); | 325 v = SkScalarClampMax(v + 1.f / lodY, 1); |
336 } | 326 } |
337 u = SkScalarClampMax(u + 1.f / lodX, 1); | 327 u = SkScalarClampMax(u + 1.f / lodX, 1); |
338 } | 328 } |
339 return true; | 329 return true; |
340 | 330 |
341 } | 331 } |
OLD | NEW |