| 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 "SkDistanceFieldGen.h" | 8 #include "SkDistanceFieldGen.h" |
| 9 #include "SkPoint.h" | 9 #include "SkPoint.h" |
| 10 | 10 |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 } else if (dist > distanceMagnitude) { | 322 } else if (dist > distanceMagnitude) { |
| 323 return 0; | 323 return 0; |
| 324 } else { | 324 } else { |
| 325 return (unsigned char)((distanceMagnitude-dist)*128.0f/distanceMagnitude
); | 325 return (unsigned char)((distanceMagnitude-dist)*128.0f/distanceMagnitude
); |
| 326 } | 326 } |
| 327 } | 327 } |
| 328 #endif | 328 #endif |
| 329 | 329 |
| 330 // assumes a padded 8-bit image and distance field | 330 // assumes a padded 8-bit image and distance field |
| 331 // width and height are the original width and height of the image | 331 // width and height are the original width and height of the image |
| 332 bool generate_distance_field_from_image(unsigned char* distanceField, | 332 static bool generate_distance_field_from_image(unsigned char* distanceField, |
| 333 const unsigned char* copyPtr, | 333 const unsigned char* copyPtr, |
| 334 int width, int height) { | 334 int width, int height) { |
| 335 SkASSERT(NULL != distanceField); | 335 SkASSERT(NULL != distanceField); |
| 336 SkASSERT(NULL != copyPtr); | 336 SkASSERT(NULL != copyPtr); |
| 337 | 337 |
| 338 // we expand our temp data by one more on each side to simplify | 338 // we expand our temp data by one more on each side to simplify |
| 339 // the scanning code -- will always be treated as infinitely far away | 339 // the scanning code -- will always be treated as infinitely far away |
| 340 int pad = SK_DistanceFieldPad + 1; | 340 int pad = SK_DistanceFieldPad + 1; |
| 341 | 341 |
| 342 // set params for distance field data | 342 // set params for distance field data |
| 343 int dataWidth = width + 2*pad; | 343 int dataWidth = width + 2*pad; |
| 344 int dataHeight = height + 2*pad; | 344 int dataHeight = height + 2*pad; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 *currDestPtr++ = (mask & (1 << i)) ? 0xff : 0; | 512 *currDestPtr++ = (mask & (1 << i)) ? 0xff : 0; |
| 513 } | 513 } |
| 514 } | 514 } |
| 515 currSrcScanLine += rowBytes; | 515 currSrcScanLine += rowBytes; |
| 516 *currDestPtr++ = 0; | 516 *currDestPtr++ = 0; |
| 517 } | 517 } |
| 518 sk_bzero(currDestPtr, (width+2)*sizeof(char)); | 518 sk_bzero(currDestPtr, (width+2)*sizeof(char)); |
| 519 | 519 |
| 520 return generate_distance_field_from_image(distanceField, copyPtr, width, hei
ght); | 520 return generate_distance_field_from_image(distanceField, copyPtr, width, hei
ght); |
| 521 } | 521 } |
| OLD | NEW |