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

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

Issue 830033003: change API contract: disallow zero-sized images or surfaces (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 11 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 | « src/image/SkSurface.cpp ('k') | src/lazy/SkDiscardablePixelRef.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 21 matching lines...) Expand all
32 private: 32 private:
33 SkBitmap fBitmap; 33 SkBitmap fBitmap;
34 bool fWeOwnThePixels; 34 bool fWeOwnThePixels;
35 35
36 typedef SkSurface_Base INHERITED; 36 typedef SkSurface_Base INHERITED;
37 }; 37 };
38 38
39 /////////////////////////////////////////////////////////////////////////////// 39 ///////////////////////////////////////////////////////////////////////////////
40 40
41 bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) { 41 bool SkSurface_Raster::Valid(const SkImageInfo& info, size_t rowBytes) {
42 if (info.isEmpty()) {
43 return false;
44 }
45
42 static const size_t kMaxTotalSize = SK_MaxS32; 46 static const size_t kMaxTotalSize = SK_MaxS32;
43 47
44 int shift = 0; 48 int shift = 0;
45 switch (info.colorType()) { 49 switch (info.colorType()) {
46 case kAlpha_8_SkColorType: 50 case kAlpha_8_SkColorType:
47 shift = 0; 51 shift = 0;
48 break; 52 break;
49 case kRGB_565_SkColorType: 53 case kRGB_565_SkColorType:
50 shift = 1; 54 shift = 1;
51 break; 55 break;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 if (!SkSurface_Raster::Valid(info)) { 169 if (!SkSurface_Raster::Valid(info)) {
166 return NULL; 170 return NULL;
167 } 171 }
168 172
169 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL)); 173 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewAllocate(info, 0, NULL));
170 if (NULL == pr.get()) { 174 if (NULL == pr.get()) {
171 return NULL; 175 return NULL;
172 } 176 }
173 return SkNEW_ARGS(SkSurface_Raster, (pr, props)); 177 return SkNEW_ARGS(SkSurface_Raster, (pr, props));
174 } 178 }
OLDNEW
« no previous file with comments | « src/image/SkSurface.cpp ('k') | src/lazy/SkDiscardablePixelRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698