diff options
author | mtklein <mtklein@chromium.org> | 2016-01-04 18:56:57 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-04 18:56:57 -0800 |
commit | c8be09aaf2bbfa004c574553fc9d194ac7f1ce1a (patch) | |
tree | fc0a0fc1f19afcef4be066157abc386048b39f4c /dm | |
parent | 29dd813b13719b9d7082a017ce79590f1706dccd (diff) |
Two malloc+bzero -> calloc.
I was profiling DM and noticed a couple spots where we malloc then bzero.
These might as well call calloc instead:
- any time DM itself allocates bitmaps for raster drawing;
- any time Skia allocates memory for a raster SkSurface.
We could use malloc for opaque surfaces, but it seems simpler to always calloc.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1557713003
Review URL: https://codereview.chromium.org/1557713003
Diffstat (limited to 'dm')
-rw-r--r-- | dm/DMSrcSink.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp index 5bc5e5a30d..fa600ff4eb 100644 --- a/dm/DMSrcSink.cpp +++ b/dm/DMSrcSink.cpp @@ -14,6 +14,7 @@ #include "SkDocument.h" #include "SkError.h" #include "SkImageGenerator.h" +#include "SkMallocPixelRef.h" #include "SkMultiPictureDraw.h" #include "SkNullCanvas.h" #include "SkOSFile.h" @@ -973,8 +974,10 @@ Error RasterSink::draw(const Src& src, SkBitmap* dst, SkWStream*, SkString*) con SkAlphaType alphaType = kPremul_SkAlphaType; (void)SkColorTypeValidateAlphaType(fColorType, alphaType, &alphaType); - dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), fColorType, alphaType)); - dst->eraseColor(SK_ColorTRANSPARENT); + SkMallocPixelRef::ZeroedPRFactory factory; + dst->allocPixels(SkImageInfo::Make(size.width(), size.height(), fColorType, alphaType), + &factory, + nullptr/*colortable*/); SkCanvas canvas(*dst); return src.draw(&canvas); } |