| 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 "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 | 51 |
| 52 SkMallocPixelRef* SkMallocPixelRef::NewAllocate(const SkImageInfo& info, | 52 SkMallocPixelRef* SkMallocPixelRef::NewAllocate(const SkImageInfo& info, |
| 53 size_t requestedRowBytes, | 53 size_t requestedRowBytes, |
| 54 SkColorTable* ctable) { | 54 SkColorTable* ctable) { |
| 55 if (!is_valid(info, ctable)) { | 55 if (!is_valid(info, ctable)) { |
| 56 return NULL; | 56 return NULL; |
| 57 } | 57 } |
| 58 | 58 |
| 59 int32_t minRB = SkToS32(info.minRowBytes()); | 59 // only want to permit 31bits of rowBytes |
| 60 if (minRB < 0) { | 60 int64_t minRB = (int64_t)info.minRowBytes64(); |
| 61 if (minRB < 0 || !sk_64_isS32(minRB)) { |
| 61 return NULL; // allocation will be too large | 62 return NULL; // allocation will be too large |
| 62 } | 63 } |
| 63 if (requestedRowBytes > 0 && (int32_t)requestedRowBytes < minRB) { | 64 if (requestedRowBytes > 0 && (int32_t)requestedRowBytes < minRB) { |
| 64 return NULL; // cannot meet requested rowbytes | 65 return NULL; // cannot meet requested rowbytes |
| 65 } | 66 } |
| 66 | 67 |
| 67 int32_t rowBytes; | 68 int32_t rowBytes; |
| 68 if (requestedRowBytes) { | 69 if (requestedRowBytes) { |
| 69 rowBytes = SkToS32(requestedRowBytes); | 70 rowBytes = SkToS32(requestedRowBytes); |
| 70 } else { | 71 } else { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const { | 199 size_t SkMallocPixelRef::getAllocatedSizeInBytes() const { |
| 199 return this->info().getSafeSize(fRB); | 200 return this->info().getSafeSize(fRB); |
| 200 } | 201 } |
| 201 | 202 |
| 202 /////////////////////////////////////////////////////////////////////////////// | 203 /////////////////////////////////////////////////////////////////////////////// |
| 203 | 204 |
| 204 SkPixelRef* SkMallocPixelRef::PRFactory::create(const SkImageInfo& info, size_t
rowBytes, | 205 SkPixelRef* SkMallocPixelRef::PRFactory::create(const SkImageInfo& info, size_t
rowBytes, |
| 205 SkColorTable* ctable) { | 206 SkColorTable* ctable) { |
| 206 return SkMallocPixelRef::NewAllocate(info, rowBytes, ctable); | 207 return SkMallocPixelRef::NewAllocate(info, rowBytes, ctable); |
| 207 } | 208 } |
| OLD | NEW |