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

Side by Side Diff: src/core/SkDistanceFieldGen.cpp

Issue 1556263002: Revert of df generation: single allocation with calloc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | no next file » | 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 "SkDistanceFieldGen.h" 8 #include "SkDistanceFieldGen.h"
9 #include "SkPoint.h" 9 #include "SkPoint.h"
10 10
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 SkASSERT(copyPtr); 336 SkASSERT(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;
345 345
346 // create zeroed temp edge+DFData storage 346 // create temp data
347 SkAutoFree storage(sk_calloc_throw(dataWidth*dataHeight*(1 + sizeof(DFData)) )); 347 size_t dataSize = dataWidth*dataHeight*sizeof(DFData);
348 unsigned char* edgePtr = (unsigned char*)storage.get(); 348 SkAutoSMalloc<1024> dfStorage(dataSize);
349 DFData* dataPtr = (DFData*)(edgePtr + dataWidth*dataHeight); 349 DFData* dataPtr = (DFData*) dfStorage.get();
350 sk_bzero(dataPtr, dataSize);
351
352 SkAutoSMalloc<1024> edgeStorage(dataWidth*dataHeight*sizeof(char));
353 unsigned char* edgePtr = (unsigned char*) edgeStorage.get();
354 sk_bzero(edgePtr, dataWidth*dataHeight*sizeof(char));
350 355
351 // copy glyph into distance field storage 356 // copy glyph into distance field storage
352 init_glyph_data(dataPtr, edgePtr, copyPtr, 357 init_glyph_data(dataPtr, edgePtr, copyPtr,
353 dataWidth, dataHeight, 358 dataWidth, dataHeight,
354 width+2, height+2, SK_DistanceFieldPad); 359 width+2, height+2, SK_DistanceFieldPad);
355 360
356 // create initial distance data, particularly at edges 361 // create initial distance data, particularly at edges
357 init_distances(dataPtr, edgePtr, dataWidth, dataHeight); 362 init_distances(dataPtr, edgePtr, dataWidth, dataHeight);
358 363
359 // now perform Euclidean distance transform to propagate distances 364 // now perform Euclidean distance transform to propagate distances
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 *currDestPtr++ = (mask & (1 << i)) ? 0xff : 0; 512 *currDestPtr++ = (mask & (1 << i)) ? 0xff : 0;
508 } 513 }
509 } 514 }
510 currSrcScanLine += rowBytes; 515 currSrcScanLine += rowBytes;
511 *currDestPtr++ = 0; 516 *currDestPtr++ = 0;
512 } 517 }
513 sk_bzero(currDestPtr, (width+2)*sizeof(char)); 518 sk_bzero(currDestPtr, (width+2)*sizeof(char));
514 519
515 return generate_distance_field_from_image(distanceField, copyPtr, width, hei ght); 520 return generate_distance_field_from_image(distanceField, copyPtr, width, hei ght);
516 } 521 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698