Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: src/utils/SkPatchUtils.cpp

Issue 544233002: "NULL !=" = NULL (Closed) Base URL: https://skia.googlesource.com/skia.git@are
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/utils/SkPatchGrid.cpp ('k') | src/utils/SkRTConf.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 lodY = static_cast<int>(weightY * 200); 226 lodY = static_cast<int>(weightY * 200);
227 data->fVertexCount = (lodX + 1) * (lodY + 1); 227 data->fVertexCount = (lodX + 1) * (lodY + 1);
228 } 228 }
229 data->fIndexCount = lodX * lodY * 6; 229 data->fIndexCount = lodX * lodY * 6;
230 230
231 data->fPoints = SkNEW_ARRAY(SkPoint, data->fVertexCount); 231 data->fPoints = SkNEW_ARRAY(SkPoint, data->fVertexCount);
232 data->fIndices = SkNEW_ARRAY(uint16_t, data->fIndexCount); 232 data->fIndices = SkNEW_ARRAY(uint16_t, data->fIndexCount);
233 233
234 // if colors is not null then create array for colors 234 // if colors is not null then create array for colors
235 SkPMColor colorsPM[kNumCorners]; 235 SkPMColor colorsPM[kNumCorners];
236 if (NULL != colors) { 236 if (colors) {
237 // premultiply colors to avoid color bleeding. 237 // premultiply colors to avoid color bleeding.
238 for (int i = 0; i < kNumCorners; i++) { 238 for (int i = 0; i < kNumCorners; i++) {
239 colorsPM[i] = SkPreMultiplyColor(colors[i]); 239 colorsPM[i] = SkPreMultiplyColor(colors[i]);
240 } 240 }
241 data->fColors = SkNEW_ARRAY(uint32_t, data->fVertexCount); 241 data->fColors = SkNEW_ARRAY(uint32_t, data->fVertexCount);
242 } 242 }
243 243
244 // if texture coordinates are not null then create array for them 244 // if texture coordinates are not null then create array for them
245 if (NULL != texCoords) { 245 if (texCoords) {
246 data->fTexCoords = SkNEW_ARRAY(SkPoint, data->fVertexCount); 246 data->fTexCoords = SkNEW_ARRAY(SkPoint, data->fVertexCount);
247 } 247 }
248 248
249 SkPoint pts[kNumPtsCubic]; 249 SkPoint pts[kNumPtsCubic];
250 SkPatchUtils::getBottomCubic(cubics, pts); 250 SkPatchUtils::getBottomCubic(cubics, pts);
251 FwDCubicEvaluator fBottom(pts); 251 FwDCubicEvaluator fBottom(pts);
252 SkPatchUtils::getTopCubic(cubics, pts); 252 SkPatchUtils::getTopCubic(cubics, pts);
253 FwDCubicEvaluator fTop(pts); 253 FwDCubicEvaluator fTop(pts);
254 SkPatchUtils::getLeftCubic(cubics, pts); 254 SkPatchUtils::getLeftCubic(cubics, pts);
255 FwDCubicEvaluator fLeft(pts); 255 FwDCubicEvaluator fLeft(pts);
(...skipping 23 matching lines...) Expand all
279 (1.0f - v) * ((1.0f - u) * fTop.getCtrlPo ints()[0].x() 279 (1.0f - v) * ((1.0f - u) * fTop.getCtrlPo ints()[0].x()
280 + u * fTop.getCtrlPoints()[ 3].x()) 280 + u * fTop.getCtrlPoints()[ 3].x())
281 + v * ((1.0f - u) * fBottom.getCtrlPoints ()[0].x() 281 + v * ((1.0f - u) * fBottom.getCtrlPoints ()[0].x()
282 + u * fBottom.getCtrlPoints()[3].x ()), 282 + u * fBottom.getCtrlPoints()[3].x ()),
283 (1.0f - v) * ((1.0f - u) * fTop.getCtrlPo ints()[0].y() 283 (1.0f - v) * ((1.0f - u) * fTop.getCtrlPo ints()[0].y()
284 + u * fTop.getCtrlPoints()[ 3].y()) 284 + u * fTop.getCtrlPoints()[ 3].y())
285 + v * ((1.0f - u) * fBottom.getCtrlPoints ()[0].y() 285 + v * ((1.0f - u) * fBottom.getCtrlPoints ()[0].y()
286 + u * fBottom.getCtrlPoints()[3].y ())); 286 + u * fBottom.getCtrlPoints()[3].y ()));
287 data->fPoints[dataIndex] = s0 + s1 - s2; 287 data->fPoints[dataIndex] = s0 + s1 - s2;
288 288
289 if (NULL != colors) { 289 if (colors) {
290 uint8_t a = uint8_t(bilerp(u, v, 290 uint8_t a = uint8_t(bilerp(u, v,
291 SkScalar(SkColorGetA(colorsPM[kTopLeft_Corner ])), 291 SkScalar(SkColorGetA(colorsPM[kTopLeft_Corner ])),
292 SkScalar(SkColorGetA(colorsPM[kTopRight_Corne r])), 292 SkScalar(SkColorGetA(colorsPM[kTopRight_Corne r])),
293 SkScalar(SkColorGetA(colorsPM[kBottomLeft_Cor ner])), 293 SkScalar(SkColorGetA(colorsPM[kBottomLeft_Cor ner])),
294 SkScalar(SkColorGetA(colorsPM[kBottomRight_Co rner])))); 294 SkScalar(SkColorGetA(colorsPM[kBottomRight_Co rner]))));
295 uint8_t r = uint8_t(bilerp(u, v, 295 uint8_t r = uint8_t(bilerp(u, v,
296 SkScalar(SkColorGetR(colorsPM[kTopLeft_Corner ])), 296 SkScalar(SkColorGetR(colorsPM[kTopLeft_Corner ])),
297 SkScalar(SkColorGetR(colorsPM[kTopRight_Corne r])), 297 SkScalar(SkColorGetR(colorsPM[kTopRight_Corne r])),
298 SkScalar(SkColorGetR(colorsPM[kBottomLeft_Cor ner])), 298 SkScalar(SkColorGetR(colorsPM[kBottomLeft_Cor ner])),
299 SkScalar(SkColorGetR(colorsPM[kBottomRight_Co rner])))); 299 SkScalar(SkColorGetR(colorsPM[kBottomRight_Co rner]))));
300 uint8_t g = uint8_t(bilerp(u, v, 300 uint8_t g = uint8_t(bilerp(u, v,
301 SkScalar(SkColorGetG(colorsPM[kTopLeft_Corner ])), 301 SkScalar(SkColorGetG(colorsPM[kTopLeft_Corner ])),
302 SkScalar(SkColorGetG(colorsPM[kTopRight_Corne r])), 302 SkScalar(SkColorGetG(colorsPM[kTopRight_Corne r])),
303 SkScalar(SkColorGetG(colorsPM[kBottomLeft_Cor ner])), 303 SkScalar(SkColorGetG(colorsPM[kBottomLeft_Cor ner])),
304 SkScalar(SkColorGetG(colorsPM[kBottomRight_Co rner])))); 304 SkScalar(SkColorGetG(colorsPM[kBottomRight_Co rner]))));
305 uint8_t b = uint8_t(bilerp(u, v, 305 uint8_t b = uint8_t(bilerp(u, v,
306 SkScalar(SkColorGetB(colorsPM[kTopLeft_Corner ])), 306 SkScalar(SkColorGetB(colorsPM[kTopLeft_Corner ])),
307 SkScalar(SkColorGetB(colorsPM[kTopRight_Corne r])), 307 SkScalar(SkColorGetB(colorsPM[kTopRight_Corne r])),
308 SkScalar(SkColorGetB(colorsPM[kBottomLeft_Cor ner])), 308 SkScalar(SkColorGetB(colorsPM[kBottomLeft_Cor ner])),
309 SkScalar(SkColorGetB(colorsPM[kBottomRight_Co rner])))); 309 SkScalar(SkColorGetB(colorsPM[kBottomRight_Co rner]))));
310 data->fColors[dataIndex] = SkPackARGB32(a,r,g,b); 310 data->fColors[dataIndex] = SkPackARGB32(a,r,g,b);
311 } 311 }
312 312
313 if (NULL != texCoords) { 313 if (texCoords) {
314 data->fTexCoords[dataIndex] = SkPoint::Make( 314 data->fTexCoords[dataIndex] = SkPoint::Make(
315 bilerp(u, v, texCoords[kTopLeft_Corn er].x(), 315 bilerp(u, v, texCoords[kTopLeft_Corn er].x(),
316 texCoords[kTopRight_Corner].x (), 316 texCoords[kTopRight_Corner].x (),
317 texCoords[kBottomLeft_Corner] .x(), 317 texCoords[kBottomLeft_Corner] .x(),
318 texCoords[kBottomRight_Corner ].x()), 318 texCoords[kBottomRight_Corner ].x()),
319 bilerp(u, v, texCoords[kTopLeft_Corn er].y(), 319 bilerp(u, v, texCoords[kTopLeft_Corn er].y(),
320 texCoords[kTopRight_Corner].y (), 320 texCoords[kTopRight_Corner].y (),
321 texCoords[kBottomLeft_Corner] .y(), 321 texCoords[kBottomLeft_Corner] .y(),
322 texCoords[kBottomRight_Corner ].y())); 322 texCoords[kBottomRight_Corner ].y()));
323 323
324 } 324 }
325 325
326 if(x < lodX && y < lodY) { 326 if(x < lodX && y < lodY) {
327 int i = 6 * (x * lodY + y); 327 int i = 6 * (x * lodY + y);
328 data->fIndices[i] = x * stride + y; 328 data->fIndices[i] = x * stride + y;
329 data->fIndices[i + 1] = x * stride + 1 + y; 329 data->fIndices[i + 1] = x * stride + 1 + y;
330 data->fIndices[i + 2] = (x + 1) * stride + 1 + y; 330 data->fIndices[i + 2] = (x + 1) * stride + 1 + y;
331 data->fIndices[i + 3] = data->fIndices[i]; 331 data->fIndices[i + 3] = data->fIndices[i];
332 data->fIndices[i + 4] = data->fIndices[i + 2]; 332 data->fIndices[i + 4] = data->fIndices[i + 2];
333 data->fIndices[i + 5] = (x + 1) * stride + y; 333 data->fIndices[i + 5] = (x + 1) * stride + y;
334 } 334 }
335 v = SkScalarClampMax(v + 1.f / lodY, 1); 335 v = SkScalarClampMax(v + 1.f / lodY, 1);
336 } 336 }
337 u = SkScalarClampMax(u + 1.f / lodX, 1); 337 u = SkScalarClampMax(u + 1.f / lodX, 1);
338 } 338 }
339 return true; 339 return true;
340 340
341 } 341 }
OLDNEW
« no previous file with comments | « src/utils/SkPatchGrid.cpp ('k') | src/utils/SkRTConf.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698