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

Unified 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, 12 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 4f4de56a46f4c0d8282c7d427153be2536396bbe..30354e09f83cb783c49ee018af74b3d8e236b272 100755
--- a/src/core/SkDistanceFieldGen.cpp
+++ b/src/core/SkDistanceFieldGen.cpp
@@ -343,10 +343,15 @@
int dataWidth = width + 2*pad;
int dataHeight = height + 2*pad;
- // create zeroed temp edge+DFData storage
- SkAutoFree storage(sk_calloc_throw(dataWidth*dataHeight*(1 + sizeof(DFData))));
- unsigned char* edgePtr = (unsigned char*)storage.get();
- DFData* dataPtr = (DFData*)(edgePtr + dataWidth*dataHeight);
+ // 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));
// 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