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

Unified Diff: src/image/SkSurface_Raster.cpp

Issue 2412633002: leave pixel memory uninitialized for opaque alpha type in SkSurface::MakeRaster (Closed)
Patch Set: Created 4 years, 2 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 | « include/core/SkSurface.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkSurface_Raster.cpp
diff --git a/src/image/SkSurface_Raster.cpp b/src/image/SkSurface_Raster.cpp
index f2cb94a04f75f48501a362cf840e3d9fee741504..2b2bf645260e2b3fc983ba1b6d0f638627b27849 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;
}
« no previous file with comments | « include/core/SkSurface.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698