aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image/SkSurface_Raster.cpp
diff options
context:
space:
mode:
authorGravatar lsalzman <lsalzman@mozilla.com>2016-10-12 16:50:16 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-12 16:50:16 -0700
commitc64ef3563dc8badac3d64544513b03df826cf8c3 (patch)
tree9e3f320873fb159acf85a6c891f927fdaa1ba253 /src/image/SkSurface_Raster.cpp
parent88fa7476ab923923022bcf75b72d94adf8a3b5bc (diff)
leave pixel memory uninitialized for opaque alpha type in SkSurface::MakeRaster
Diffstat (limited to 'src/image/SkSurface_Raster.cpp')
-rw-r--r--src/image/SkSurface_Raster.cpp6
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;
}