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

Side by Side Diff: src/image/SkSurface_Raster.cpp

Issue 111323005: Remvoe duplicate impl for SkImageInfo flattening (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | src/images/SkImageRef.cpp » ('j') | 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 } 148 }
149 149
150 return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rowBytes)); 150 return SkNEW_ARGS(SkSurface_Raster, (info, pixels, rowBytes));
151 } 151 }
152 152
153 SkSurface* SkSurface::NewRaster(const SkImageInfo& info) { 153 SkSurface* SkSurface::NewRaster(const SkImageInfo& info) {
154 if (!SkSurface_Raster::Valid(info)) { 154 if (!SkSurface_Raster::Valid(info)) {
155 return NULL; 155 return NULL;
156 } 156 }
157 157
158 static const size_t kMaxTotalSize = SK_MaxS32; 158 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL));
159 size_t rowBytes = SkImageMinRowBytes(info); 159 if (NULL == pr.get()) {
160 uint64_t size64 = (uint64_t)info.fHeight * rowBytes;
161 if (size64 > kMaxTotalSize) {
162 return NULL; 160 return NULL;
163 } 161 }
164 162 return SkNEW_ARGS(SkSurface_Raster, (info, pr, info.minRowBytes()));
165 size_t size = (size_t)size64;
166 void* pixels = sk_malloc_throw(size);
167 if (NULL == pixels) {
168 return NULL;
169 }
170
171 SkAutoTUnref<SkPixelRef> pr(SkNEW_ARGS(SkMallocPixelRef, (pixels, size, NULL , true)));
172 return SkNEW_ARGS(SkSurface_Raster, (info, pr, rowBytes));
173 } 163 }
OLDNEW
« no previous file with comments | « src/image/SkImage_Raster.cpp ('k') | src/images/SkImageRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698