diff options
author | lsalzman <lsalzman@mozilla.com> | 2016-10-12 16:50:16 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-10-12 16:50:16 -0700 |
commit | c64ef3563dc8badac3d64544513b03df826cf8c3 (patch) | |
tree | 9e3f320873fb159acf85a6c891f927fdaa1ba253 /src/image/SkSurface_Raster.cpp | |
parent | 88fa7476ab923923022bcf75b72d94adf8a3b5bc (diff) |
leave pixel memory uninitialized for opaque alpha type in SkSurface::MakeRaster
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2412633002
Review-Url: https://codereview.chromium.org/2412633002
Diffstat (limited to 'src/image/SkSurface_Raster.cpp')
-rw-r--r-- | src/image/SkSurface_Raster.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp index f2cb94a04f..2b2bf64526 100644 --- a/src/image/SkSurface_Raster.cpp +++ b/src/image/SkSurface_Raster.cpp @@ -208,7 +208,11 @@ sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& info, size_t rowBytes, return nullptr; } - SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, nullptr)); + // If the requested alpha type is opaque, then leave the pixels uninitialized. + // Alpha formats can be safely initialiezd to zero. + SkAutoTUnref<SkPixelRef> pr(info.isOpaque() + ? SkMallocPixelRef::NewAllocate(info, rowBytes, nullptr) + : SkMallocPixelRef::NewZeroed(info, rowBytes, nullptr)); if (nullptr == pr.get()) { return nullptr; } |