Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 // If we used a LRU cache we would fill it and then on next animation loop | 400 // If we used a LRU cache we would fill it and then on next animation loop |
| 401 // we would need to decode all the frames again -- the LRU would give no | 401 // we would need to decode all the frames again -- the LRU would give no |
| 402 // benefit and would consume more memory. | 402 // benefit and would consume more memory. |
| 403 // So instead, simply purge unused frames if caching all of the frames of | 403 // So instead, simply purge unused frames if caching all of the frames of |
| 404 // the image would use more memory than the image decoder is allowed | 404 // the image would use more memory than the image decoder is allowed |
| 405 // (|max_decoded_bytes|) or would overflow 32 bits.. | 405 // (|max_decoded_bytes|) or would overflow 32 bits.. |
| 406 // | 406 // |
| 407 // As we decode we will learn the total number of frames, and thus total | 407 // As we decode we will learn the total number of frames, and thus total |
| 408 // possible image memory used. | 408 // possible image memory used. |
| 409 | 409 |
| 410 const uint64_t frame_area = DecodedSize().Area(); | 410 const uint64_t frame_memory_usage = |
| 411 const uint64_t frame_memory_usage = frame_area * 4; // 4 bytes per pixel | 411 DecodedSize().Area() * 4; // 4 bytes per pixel |
| 412 if (frame_memory_usage / 4 != frame_area) { // overflow occurred | |
|
Srirama
2017/05/30 07:07:39
though it looks like it is doing nothing, this wou
| |
| 413 purge_aggressively_ = true; | |
| 414 return; | |
| 415 } | |
| 416 | |
| 417 const uint64_t total_memory_usage = frame_memory_usage * index; | 412 const uint64_t total_memory_usage = frame_memory_usage * index; |
| 418 if (total_memory_usage / frame_memory_usage != index) { // overflow occurred | 413 if (total_memory_usage / frame_memory_usage != index) { // overflow occurred |
| 419 purge_aggressively_ = true; | 414 purge_aggressively_ = true; |
| 420 return; | 415 return; |
| 421 } | 416 } |
| 422 | 417 |
| 423 if (total_memory_usage > max_decoded_bytes_) { | 418 if (total_memory_usage > max_decoded_bytes_) { |
| 424 purge_aggressively_ = true; | 419 purge_aggressively_ = true; |
| 425 } | 420 } |
| 426 } | 421 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 } | 572 } |
| 578 | 573 |
| 579 // For color spaces without an identifiable gamut, just fall through to | 574 // For color spaces without an identifiable gamut, just fall through to |
| 580 // sRGB. | 575 // sRGB. |
| 581 } | 576 } |
| 582 | 577 |
| 583 return SkColorSpace::MakeSRGB(); | 578 return SkColorSpace::MakeSRGB(); |
| 584 } | 579 } |
| 585 | 580 |
| 586 } // namespace blink | 581 } // namespace blink |
| OLD | NEW |