| OLD | NEW |
| 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 Loading... |
| 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 int64_t bigSize = (int64_t)info.fHeight * rowBytes; | 67 Sk64 bigSize; |
| 68 if (!sk_64_isS32(bigSize)) { | 68 bigSize.setMul(info.fHeight, rowBytes); |
| 69 if (!bigSize.is32()) { |
| 69 return NULL; | 70 return NULL; |
| 70 } | 71 } |
| 71 | 72 |
| 72 size_t size = sk_64_asS32(bigSize); | 73 size_t size = bigSize.get32(); |
| 73 void* addr = sk_malloc_flags(size, 0); | 74 void* addr = sk_malloc_flags(size, 0); |
| 74 if (NULL == addr) { | 75 if (NULL == addr) { |
| 75 return NULL; | 76 return NULL; |
| 76 } | 77 } |
| 77 | 78 |
| 78 return SkNEW_ARGS(SkMallocPixelRef, (info, addr, rowBytes, ctable, true)); | 79 return SkNEW_ARGS(SkMallocPixelRef, (info, addr, rowBytes, ctable, true)); |
| 79 } | 80 } |
| 80 | 81 |
| 81 /////////////////////////////////////////////////////////////////////////////// | 82 /////////////////////////////////////////////////////////////////////////////// |
| 82 | 83 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 } | 151 } |
| 151 | 152 |
| 152 if (buffer.readBool()) { | 153 if (buffer.readBool()) { |
| 153 fCTable = SkNEW_ARGS(SkColorTable, (buffer)); | 154 fCTable = SkNEW_ARGS(SkColorTable, (buffer)); |
| 154 } else { | 155 } else { |
| 155 fCTable = NULL; | 156 fCTable = NULL; |
| 156 } | 157 } |
| 157 | 158 |
| 158 this->setPreLocked(fStorage, fCTable); | 159 this->setPreLocked(fStorage, fCTable); |
| 159 } | 160 } |
| OLD | NEW |