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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/core/SkSurface.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSurface_Base.h" 8 #include "SkSurface_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 const SkSurfaceProps* props) { 201 const SkSurfaceProps* props) {
202 return MakeRasterDirectReleaseProc(info, pixels, rowBytes, nullptr, nullptr, props); 202 return MakeRasterDirectReleaseProc(info, pixels, rowBytes, nullptr, nullptr, props);
203 } 203 }
204 204
205 sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& info, size_t rowBytes, 205 sk_sp<SkSurface> SkSurface::MakeRaster(const SkImageInfo& info, size_t rowBytes,
206 const SkSurfaceProps* props) { 206 const SkSurfaceProps* props) {
207 if (!SkSurface_Raster::Valid(info)) { 207 if (!SkSurface_Raster::Valid(info)) {
208 return nullptr; 208 return nullptr;
209 } 209 }
210 210
211 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, null ptr)); 211 // If the requested alpha type is opaque, then leave the pixels uninitialize d.
212 // Alpha formats can be safely initialiezd to zero.
213 SkAutoTUnref<SkPixelRef> pr(info.isOpaque()
214 ? SkMallocPixelRef::NewAllocate(info, rowBytes, nullptr)
215 : SkMallocPixelRef::NewZeroed(info, rowBytes, nu llptr));
212 if (nullptr == pr.get()) { 216 if (nullptr == pr.get()) {
213 return nullptr; 217 return nullptr;
214 } 218 }
215 if (rowBytes) { 219 if (rowBytes) {
216 SkASSERT(pr->rowBytes() == rowBytes); 220 SkASSERT(pr->rowBytes() == rowBytes);
217 } 221 }
218 return sk_make_sp<SkSurface_Raster>(pr, props); 222 return sk_make_sp<SkSurface_Raster>(pr, props);
219 } 223 }
OLDNEW
« 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