| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 #ifndef SkImageInfo_DEFINED | 8 #ifndef SkImageInfo_DEFINED |
| 9 #define SkImageInfo_DEFINED | 9 #define SkImageInfo_DEFINED |
| 10 | 10 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 void flatten(SkWriteBuffer&) const; | 275 void flatten(SkWriteBuffer&) const; |
| 276 | 276 |
| 277 int64_t getSafeSize64(size_t rowBytes) const { | 277 int64_t getSafeSize64(size_t rowBytes) const { |
| 278 if (0 == fHeight) { | 278 if (0 == fHeight) { |
| 279 return 0; | 279 return 0; |
| 280 } | 280 } |
| 281 return sk_64_mul(fHeight - 1, rowBytes) + fWidth * this->bytesPerPixel()
; | 281 return sk_64_mul(fHeight - 1, rowBytes) + fWidth * this->bytesPerPixel()
; |
| 282 } | 282 } |
| 283 | 283 |
| 284 size_t getSafeSize(size_t rowBytes) const { | 284 size_t getSafeSize(size_t rowBytes) const { |
| 285 return (size_t)this->getSafeSize64(rowBytes); | 285 int64_t size = this->getSafeSize64(rowBytes); |
| 286 if (!sk_64_isS32(size)) { |
| 287 return 0; |
| 288 } |
| 289 return sk_64_asS32(size); |
| 286 } | 290 } |
| 287 | 291 |
| 288 bool validRowBytes(size_t rowBytes) const { | 292 bool validRowBytes(size_t rowBytes) const { |
| 289 uint64_t rb = sk_64_mul(fWidth, this->bytesPerPixel()); | 293 uint64_t rb = sk_64_mul(fWidth, this->bytesPerPixel()); |
| 290 return rowBytes >= rb; | 294 return rowBytes >= rb; |
| 291 } | 295 } |
| 292 | 296 |
| 293 SkDEBUGCODE(void validate() const;) | 297 SkDEBUGCODE(void validate() const;) |
| 294 | 298 |
| 295 #ifdef SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS | 299 #ifdef SK_SUPPORT_LEGACY_PUBLIC_IMAGEINFO_FIELDS |
| (...skipping 12 matching lines...) Expand all Loading... |
| 308 , fHeight(height) | 312 , fHeight(height) |
| 309 , fColorType(ct) | 313 , fColorType(ct) |
| 310 , fAlphaType(at) | 314 , fAlphaType(at) |
| 311 , fProfileType(pt) | 315 , fProfileType(pt) |
| 312 {} | 316 {} |
| 313 | 317 |
| 314 SkColorProfileType fProfileType; | 318 SkColorProfileType fProfileType; |
| 315 }; | 319 }; |
| 316 | 320 |
| 317 #endif | 321 #endif |
| OLD | NEW |