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

Side by Side Diff: src/core/SkMallocPixelRef.cpp

Issue 122293002: Revert "Revert of https://codereview.chromium.org/113823003/" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/core/SkMipMap.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 2011 Google Inc. 2 * Copyright 2011 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 "SkMallocPixelRef.h" 8 #include "SkMallocPixelRef.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkFlattenableBuffers.h" 10 #include "SkFlattenableBuffers.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 return NULL; // cannot meet requested rowbytes 57 return NULL; // cannot meet requested rowbytes
58 } 58 }
59 59
60 int32_t rowBytes; 60 int32_t rowBytes;
61 if (requestedRowBytes) { 61 if (requestedRowBytes) {
62 rowBytes = requestedRowBytes; 62 rowBytes = requestedRowBytes;
63 } else { 63 } else {
64 rowBytes = minRB; 64 rowBytes = minRB;
65 } 65 }
66 66
67 Sk64 bigSize; 67 int64_t bigSize = (int64_t)info.fHeight * rowBytes;
68 bigSize.setMul(info.fHeight, rowBytes); 68 if (!sk_64_isS32(bigSize)) {
69 if (!bigSize.is32()) {
70 return NULL; 69 return NULL;
71 } 70 }
72 71
73 size_t size = bigSize.get32(); 72 size_t size = sk_64_asS32(bigSize);
74 void* addr = sk_malloc_flags(size, 0); 73 void* addr = sk_malloc_flags(size, 0);
75 if (NULL == addr) { 74 if (NULL == addr) {
76 return NULL; 75 return NULL;
77 } 76 }
78 77
79 return SkNEW_ARGS(SkMallocPixelRef, (info, addr, rowBytes, ctable, true)); 78 return SkNEW_ARGS(SkMallocPixelRef, (info, addr, rowBytes, ctable, true));
80 } 79 }
81 80
82 /////////////////////////////////////////////////////////////////////////////// 81 ///////////////////////////////////////////////////////////////////////////////
83 82
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 150 }
152 151
153 if (buffer.readBool()) { 152 if (buffer.readBool()) {
154 fCTable = SkNEW_ARGS(SkColorTable, (buffer)); 153 fCTable = SkNEW_ARGS(SkColorTable, (buffer));
155 } else { 154 } else {
156 fCTable = NULL; 155 fCTable = NULL;
157 } 156 }
158 157
159 this->setPreLocked(fStorage, fCTable); 158 this->setPreLocked(fStorage, fCTable);
160 } 159 }
OLDNEW
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/core/SkMipMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698