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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 SkScalar weightX = static_cast<SkScalar>(lodX) / (lodX + lodY); | 210 SkScalar weightX = static_cast<SkScalar>(lodX) / (lodX + lodY); |
211 SkScalar weightY = static_cast<SkScalar>(lodY) / (lodX + lodY); | 211 SkScalar weightY = static_cast<SkScalar>(lodY) / (lodX + lodY); |
212 | 212 |
213 // 200 comes from the 100 * 2 which is the max value of vertices because
of the limit of | 213 // 200 comes from the 100 * 2 which is the max value of vertices because
of the limit of |
214 // 60000 indices ( sqrt(60000 / 6) that comes from data->fIndexCount = l
odX * lodY * 6) | 214 // 60000 indices ( sqrt(60000 / 6) that comes from data->fIndexCount = l
odX * lodY * 6) |
215 lodX = static_cast<int>(weightX * 200); | 215 lodX = static_cast<int>(weightX * 200); |
216 lodY = static_cast<int>(weightY * 200); | 216 lodY = static_cast<int>(weightY * 200); |
217 data->fVertexCount = (lodX + 1) * (lodY + 1); | 217 data->fVertexCount = (lodX + 1) * (lodY + 1); |
218 } | 218 } |
219 data->fIndexCount = lodX * lodY * 6; | 219 data->fIndexCount = lodX * lodY * 6; |
220 | 220 |
221 data->fPoints = SkNEW_ARRAY(SkPoint, data->fVertexCount); | 221 data->fPoints = new SkPoint[data->fVertexCount]; |
222 data->fIndices = SkNEW_ARRAY(uint16_t, data->fIndexCount); | 222 data->fIndices = new uint16_t[data->fIndexCount]; |
223 | 223 |
224 // if colors is not null then create array for colors | 224 // if colors is not null then create array for colors |
225 SkPMColor colorsPM[kNumCorners]; | 225 SkPMColor colorsPM[kNumCorners]; |
226 if (colors) { | 226 if (colors) { |
227 // premultiply colors to avoid color bleeding. | 227 // premultiply colors to avoid color bleeding. |
228 for (int i = 0; i < kNumCorners; i++) { | 228 for (int i = 0; i < kNumCorners; i++) { |
229 colorsPM[i] = SkPreMultiplyColor(colors[i]); | 229 colorsPM[i] = SkPreMultiplyColor(colors[i]); |
230 } | 230 } |
231 data->fColors = SkNEW_ARRAY(uint32_t, data->fVertexCount); | 231 data->fColors = new uint32_t[data->fVertexCount]; |
232 } | 232 } |
233 | 233 |
234 // if texture coordinates are not null then create array for them | 234 // if texture coordinates are not null then create array for them |
235 if (texCoords) { | 235 if (texCoords) { |
236 data->fTexCoords = SkNEW_ARRAY(SkPoint, data->fVertexCount); | 236 data->fTexCoords = new SkPoint[data->fVertexCount]; |
237 } | 237 } |
238 | 238 |
239 SkPoint pts[kNumPtsCubic]; | 239 SkPoint pts[kNumPtsCubic]; |
240 SkPatchUtils::getBottomCubic(cubics, pts); | 240 SkPatchUtils::getBottomCubic(cubics, pts); |
241 FwDCubicEvaluator fBottom(pts); | 241 FwDCubicEvaluator fBottom(pts); |
242 SkPatchUtils::getTopCubic(cubics, pts); | 242 SkPatchUtils::getTopCubic(cubics, pts); |
243 FwDCubicEvaluator fTop(pts); | 243 FwDCubicEvaluator fTop(pts); |
244 SkPatchUtils::getLeftCubic(cubics, pts); | 244 SkPatchUtils::getLeftCubic(cubics, pts); |
245 FwDCubicEvaluator fLeft(pts); | 245 FwDCubicEvaluator fLeft(pts); |
246 SkPatchUtils::getRightCubic(cubics, pts); | 246 SkPatchUtils::getRightCubic(cubics, pts); |
(...skipping 75 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 |