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/core/SkDistanceFieldGen.cpp

Issue 1643143002: Generate Signed Distance Field directly from vector path (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Move implementation to src/gpu Created 4 years, 10 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
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 "SkDistanceFieldGen.h" 8 #include "SkDistanceFieldGen.h"
9 #include "SkPoint.h" 9 #include "SkPoint.h"
10 10
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 curr->fDistSq = distSq; 310 curr->fDistSq = distSq;
311 curr->fDistVector = distVec; 311 curr->fDistVector = distVec;
312 } 312 }
313 } 313 }
314 314
315 // enable this to output edge data rather than the distance field 315 // enable this to output edge data rather than the distance field
316 #define DUMP_EDGE 0 316 #define DUMP_EDGE 0
317 317
318 #if !DUMP_EDGE 318 #if !DUMP_EDGE
319 static unsigned char pack_distance_field_val(float dist, float distanceMagnitude ) { 319 static unsigned char pack_distance_field_val(float dist, float distanceMagnitude ) {
320 if (dist <= -distanceMagnitude) { 320 if (dist <= -(distanceMagnitude*(1.0f-1.0f/128.0f))) {
bsalomon 2016/02/02 18:03:48 Can you add a comment that explains this constant?
Joel.Liang 2016/02/04 12:12:04 Done. And I'd like to give a example here: If dis
jvanverth1 2016/02/04 14:21:22 Thanks, that equation is a lot clearer (and thanks
Joel.Liang 2016/02/22 07:34:00 Actually, the example I gave here is wrong(The inp
321 return 255; 321 return 255;
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
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 *currDestPtr++ = (mask & (1 << i)) ? 0xff : 0; 507 *currDestPtr++ = (mask & (1 << i)) ? 0xff : 0;
508 } 508 }
509 } 509 }
510 currSrcScanLine += rowBytes; 510 currSrcScanLine += rowBytes;
511 *currDestPtr++ = 0; 511 *currDestPtr++ = 0;
512 } 512 }
513 sk_bzero(currDestPtr, (width+2)*sizeof(char)); 513 sk_bzero(currDestPtr, (width+2)*sizeof(char));
514 514
515 return generate_distance_field_from_image(distanceField, copyPtr, width, hei ght); 515 return generate_distance_field_from_image(distanceField, copyPtr, width, hei ght);
516 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698