| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/resource/resource_bundle.h" | 5 #include "ui/base/resource/resource_bundle.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 | 823 |
| 824 NOTREACHED() << "Unable to decode theme image resource " << resource_id; | 824 NOTREACHED() << "Unable to decode theme image resource " << resource_id; |
| 825 return false; | 825 return false; |
| 826 } | 826 } |
| 827 | 827 |
| 828 bool ResourceBundle::LoadBitmap(int resource_id, | 828 bool ResourceBundle::LoadBitmap(int resource_id, |
| 829 ScaleFactor* scale_factor, | 829 ScaleFactor* scale_factor, |
| 830 SkBitmap* bitmap, | 830 SkBitmap* bitmap, |
| 831 bool* fell_back_to_1x) const { | 831 bool* fell_back_to_1x) const { |
| 832 DCHECK(fell_back_to_1x); | 832 DCHECK(fell_back_to_1x); |
| 833 for (const auto& pack : data_packs_) { | 833 for (auto* pack : data_packs_) { |
| 834 if (pack->GetScaleFactor() == ui::SCALE_FACTOR_NONE && | 834 if (pack->GetScaleFactor() == ui::SCALE_FACTOR_NONE && |
| 835 LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) { | 835 LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) { |
| 836 DCHECK(!*fell_back_to_1x); | 836 DCHECK(!*fell_back_to_1x); |
| 837 *scale_factor = ui::SCALE_FACTOR_NONE; | 837 *scale_factor = ui::SCALE_FACTOR_NONE; |
| 838 return true; | 838 return true; |
| 839 } | 839 } |
| 840 | 840 |
| 841 if (pack->GetScaleFactor() == *scale_factor && | 841 if (pack->GetScaleFactor() == *scale_factor && |
| 842 LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) { | 842 LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) { |
| 843 return true; | 843 return true; |
| 844 } | 844 } |
| 845 } | 845 } |
| 846 | 846 |
| 847 // Unit tests may only have 1x data pack. Allow them to fallback to 1x | 847 // Unit tests may only have 1x data pack. Allow them to fallback to 1x |
| 848 // resources. | 848 // resources. |
| 849 if (is_test_resources_ && *scale_factor != ui::SCALE_FACTOR_100P) { | 849 if (is_test_resources_ && *scale_factor != ui::SCALE_FACTOR_100P) { |
| 850 for (const auto& pack : data_packs_) { | 850 for (auto* pack : data_packs_) { |
| 851 if (pack->GetScaleFactor() == ui::SCALE_FACTOR_100P && | 851 if (pack->GetScaleFactor() == ui::SCALE_FACTOR_100P && |
| 852 LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) { | 852 LoadBitmap(*pack, resource_id, bitmap, fell_back_to_1x)) { |
| 853 *fell_back_to_1x = true; | 853 *fell_back_to_1x = true; |
| 854 return true; | 854 return true; |
| 855 } | 855 } |
| 856 } | 856 } |
| 857 } | 857 } |
| 858 | 858 |
| 859 return false; | 859 return false; |
| 860 } | 860 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 // static | 908 // static |
| 909 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 909 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 910 size_t size, | 910 size_t size, |
| 911 SkBitmap* bitmap, | 911 SkBitmap* bitmap, |
| 912 bool* fell_back_to_1x) { | 912 bool* fell_back_to_1x) { |
| 913 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 913 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 914 return gfx::PNGCodec::Decode(buf, size, bitmap); | 914 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 915 } | 915 } |
| 916 | 916 |
| 917 } // namespace ui | 917 } // namespace ui |
| OLD | NEW |