| Index: ui/gfx/image/image_skia.cc
|
| diff --git a/ui/gfx/image/image_skia.cc b/ui/gfx/image/image_skia.cc
|
| index 20349b4baf14c71cd7fd7200697b559abc4fcf84..9c4ef646ecac6af3b4e0bd1ca98911e7b67b621e 100644
|
| --- a/ui/gfx/image/image_skia.cc
|
| +++ b/ui/gfx/image/image_skia.cc
|
| @@ -219,18 +219,8 @@ std::vector<ImageSkiaRep>::iterator ImageSkiaStorage::FindRepresentation(
|
|
|
| ImageSkiaRep image;
|
| float resource_scale = scale;
|
| - if (!HasRepresentationAtAllScales() && g_supported_scales) {
|
| - if (g_supported_scales->back() <= scale) {
|
| - resource_scale = g_supported_scales->back();
|
| - } else {
|
| - for (size_t i = 0; i < g_supported_scales->size(); ++i) {
|
| - if ((*g_supported_scales)[i] + kFallbackToSmallerScaleDiff >= scale) {
|
| - resource_scale = (*g_supported_scales)[i];
|
| - break;
|
| - }
|
| - }
|
| - }
|
| - }
|
| + if (!HasRepresentationAtAllScales() && g_supported_scales)
|
| + resource_scale = ImageSkia::MapToSupportedScale(scale);
|
| if (scale != resource_scale) {
|
| std::vector<ImageSkiaRep>::iterator iter =
|
| FindRepresentation(resource_scale, fetch_new_image);
|
| @@ -331,6 +321,15 @@ float ImageSkia::GetMaxSupportedScale() {
|
| }
|
|
|
| // static
|
| +float ImageSkia::MapToSupportedScale(float scale) {
|
| + for (float supported_scale : *g_supported_scales) {
|
| + if (supported_scale + kFallbackToSmallerScaleDiff >= scale)
|
| + return supported_scale;
|
| + }
|
| + return g_supported_scales->back();
|
| +}
|
| +
|
| +// static
|
| ImageSkia ImageSkia::CreateFrom1xBitmap(const SkBitmap& bitmap) {
|
| return ImageSkia(ImageSkiaRep(bitmap, 0.0f));
|
| }
|
|
|