Chromium Code Reviews| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 SkBitmap image; | 130 SkBitmap image; |
| 131 bool fell_back_to_1x = false; | 131 bool fell_back_to_1x = false; |
| 132 ScaleFactor scale_factor = GetSupportedScaleFactor(scale); | 132 ScaleFactor scale_factor = GetSupportedScaleFactor(scale); |
| 133 bool found = rb_->LoadBitmap(resource_id_, &scale_factor, | 133 bool found = rb_->LoadBitmap(resource_id_, &scale_factor, |
| 134 &image, &fell_back_to_1x); | 134 &image, &fell_back_to_1x); |
| 135 if (!found) { | 135 if (!found) { |
| 136 #if defined(OS_ANDROID) | 136 #if defined(OS_ANDROID) |
| 137 // TODO(oshima): Android unit_tests runs at DSF=3 with 100P assets. | 137 // TODO(oshima): Android unit_tests runs at DSF=3 with 100P assets. |
| 138 return gfx::ImageSkiaRep(); | 138 return gfx::ImageSkiaRep(); |
| 139 #else | 139 #else |
| 140 NOTREACHED() << "Unable to load image with id " << resource_id_ | 140 // TODO: Remove before submitting. |
|
rjkroege
2016/09/21 13:23:47
please complete TODO
kylechar
2016/09/22 20:03:27
Done.
| |
| 141 << ", scale=" << scale; | 141 // NOTREACHED() << "Unable to load image with id " << resource_id_ |
| 142 return gfx::ImageSkiaRep(CreateEmptyBitmap(), scale); | 142 // << ", scale=" << scale; |
| 143 // return gfx::ImageSkiaRep(CreateEmptyBitmap(), scale); | |
| 143 #endif | 144 #endif |
| 144 } | 145 } |
| 145 | 146 |
| 146 // If the resource is in the package with SCALE_FACTOR_NONE, it | 147 // If the resource is in the package with SCALE_FACTOR_NONE, it |
| 147 // can be used in any scale factor. The image is maked as "unscaled" | 148 // can be used in any scale factor. The image is maked as "unscaled" |
| 148 // so that the ImageSkia do not automatically scale. | 149 // so that the ImageSkia do not automatically scale. |
| 149 if (scale_factor == ui::SCALE_FACTOR_NONE) | 150 if (scale_factor == ui::SCALE_FACTOR_NONE) |
| 150 return gfx::ImageSkiaRep(image, 0.0f); | 151 return gfx::ImageSkiaRep(image, 0.0f); |
| 151 | 152 |
| 152 if (fell_back_to_1x) { | 153 if (fell_back_to_1x) { |
| (...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 // static | 902 // static |
| 902 bool ResourceBundle::DecodePNG(const unsigned char* buf, | 903 bool ResourceBundle::DecodePNG(const unsigned char* buf, |
| 903 size_t size, | 904 size_t size, |
| 904 SkBitmap* bitmap, | 905 SkBitmap* bitmap, |
| 905 bool* fell_back_to_1x) { | 906 bool* fell_back_to_1x) { |
| 906 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); | 907 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); |
| 907 return gfx::PNGCodec::Decode(buf, size, bitmap); | 908 return gfx::PNGCodec::Decode(buf, size, bitmap); |
| 908 } | 909 } |
| 909 | 910 |
| 910 } // namespace ui | 911 } // namespace ui |
| OLD | NEW |