OLD | NEW |
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 Loading... |
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 // If the requested alpha type is opaque, then leave the pixels uninitialize
d. | 211 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewZeroed(info, rowBytes, null
ptr)); |
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)); | |
216 if (nullptr == pr.get()) { | 212 if (nullptr == pr.get()) { |
217 return nullptr; | 213 return nullptr; |
218 } | 214 } |
219 if (rowBytes) { | 215 if (rowBytes) { |
220 SkASSERT(pr->rowBytes() == rowBytes); | 216 SkASSERT(pr->rowBytes() == rowBytes); |
221 } | 217 } |
222 return sk_make_sp<SkSurface_Raster>(pr, props); | 218 return sk_make_sp<SkSurface_Raster>(pr, props); |
223 } | 219 } |
OLD | NEW |