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

Unified Diff: src/core/SkDistanceFieldGen.cpp

Issue 1544983004: df generation: single allocation with calloc (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: swap 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDistanceFieldGen.cpp
diff --git a/src/core/SkDistanceFieldGen.cpp b/src/core/SkDistanceFieldGen.cpp
index 30354e09f83cb783c49ee018af74b3d8e236b272..147aefad79052428453494e33fb98ea4e21e9d43 100755
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -343,15 +343,10 @@ static bool generate_distance_field_from_image(unsigned char* distanceField,
int dataWidth = width + 2*pad;
int dataHeight = height + 2*pad;
- // create temp data
- size_t dataSize = dataWidth*dataHeight*sizeof(DFData);
- SkAutoSMalloc<1024> dfStorage(dataSize);
- DFData* dataPtr = (DFData*) dfStorage.get();
- sk_bzero(dataPtr, dataSize);
-
- SkAutoSMalloc<1024> edgeStorage(dataWidth*dataHeight*sizeof(char));
- unsigned char* edgePtr = (unsigned char*) edgeStorage.get();
- sk_bzero(edgePtr, dataWidth*dataHeight*sizeof(char));
+ // create zeroed temp DFData+edge storage
+ SkAutoFree storage(sk_calloc_throw(dataWidth*dataHeight*(sizeof(DFData) + 1)));
+ DFData* dataPtr = (DFData*)storage.get();
+ unsigned char* edgePtr = (unsigned char*)storage.get() + dataWidth*dataHeight*sizeof(DFData);
// copy glyph into distance field storage
init_glyph_data(dataPtr, edgePtr, copyPtr,
« 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