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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 void SkPatchUtils::getRightCubic(const SkPoint cubics[12], SkPoint points[4]) { | 185 void SkPatchUtils::getRightCubic(const SkPoint cubics[12], SkPoint points[4]) { |
186 points[0] = cubics[kRightP0_CubicCtrlPts]; | 186 points[0] = cubics[kRightP0_CubicCtrlPts]; |
187 points[1] = cubics[kRightP1_CubicCtrlPts]; | 187 points[1] = cubics[kRightP1_CubicCtrlPts]; |
188 points[2] = cubics[kRightP2_CubicCtrlPts]; | 188 points[2] = cubics[kRightP2_CubicCtrlPts]; |
189 points[3] = cubics[kRightP3_CubicCtrlPts]; | 189 points[3] = cubics[kRightP3_CubicCtrlPts]; |
190 } | 190 } |
191 | 191 |
192 bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
ubics[12], | 192 bool SkPatchUtils::getVertexData(SkPatchUtils::VertexData* data, const SkPoint c
ubics[12], |
193 const SkColor colors[4], const SkPoint texCoords[4], int lodX
, int lodY) { | 193 const SkColor colors[4], const SkPoint texCoords[4], int lodX
, int lodY) { |
194 if (lodX < 1 || lodY < 1 || NULL == cubics || NULL == data) { | 194 if (lodX < 1 || lodY < 1 || nullptr == cubics || nullptr == data) { |
195 return false; | 195 return false; |
196 } | 196 } |
197 | 197 |
198 // check for overflow in multiplication | 198 // check for overflow in multiplication |
199 const int64_t lodX64 = (lodX + 1), | 199 const int64_t lodX64 = (lodX + 1), |
200 lodY64 = (lodY + 1), | 200 lodY64 = (lodY + 1), |
201 mult64 = lodX64 * lodY64; | 201 mult64 = lodX64 * lodY64; |
202 if (mult64 > SK_MaxS32) { | 202 if (mult64 > SK_MaxS32) { |
203 return false; | 203 return false; |
204 } | 204 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 data->fIndices[i + 4] = data->fIndices[i + 2]; | 322 data->fIndices[i + 4] = data->fIndices[i + 2]; |
323 data->fIndices[i + 5] = (x + 1) * stride + y; | 323 data->fIndices[i + 5] = (x + 1) * stride + y; |
324 } | 324 } |
325 v = SkScalarClampMax(v + 1.f / lodY, 1); | 325 v = SkScalarClampMax(v + 1.f / lodY, 1); |
326 } | 326 } |
327 u = SkScalarClampMax(u + 1.f / lodX, 1); | 327 u = SkScalarClampMax(u + 1.f / lodX, 1); |
328 } | 328 } |
329 return true; | 329 return true; |
330 | 330 |
331 } | 331 } |
OLD | NEW |