| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/views/tab_icon_view.h" | 5 #include "chrome/browser/ui/views/tab_icon_view.h" |
| 6 | 6 |
| 7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif | 10 #endif |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 int src_y, | 106 int src_y, |
| 107 int src_w, | 107 int src_w, |
| 108 int src_h, | 108 int src_h, |
| 109 bool filter) { | 109 bool filter) { |
| 110 // For source images smaller than the favicon square, scale them as if they | 110 // For source images smaller than the favicon square, scale them as if they |
| 111 // were padded to fit the favicon square, so we don't blow up tiny favicons | 111 // were padded to fit the favicon square, so we don't blow up tiny favicons |
| 112 // into larger or nonproportional results. | 112 // into larger or nonproportional results. |
| 113 float float_src_w = static_cast<float>(src_w); | 113 float float_src_w = static_cast<float>(src_w); |
| 114 float float_src_h = static_cast<float>(src_h); | 114 float float_src_h = static_cast<float>(src_h); |
| 115 float scalable_w, scalable_h; | 115 float scalable_w, scalable_h; |
| 116 if (src_w <= kFavIconSize && src_h <= kFavIconSize) { | 116 if (src_w <= kFaviconSize && src_h <= kFaviconSize) { |
| 117 scalable_w = scalable_h = kFavIconSize; | 117 scalable_w = scalable_h = kFaviconSize; |
| 118 } else { | 118 } else { |
| 119 scalable_w = float_src_w; | 119 scalable_w = float_src_w; |
| 120 scalable_h = float_src_h; | 120 scalable_h = float_src_h; |
| 121 } | 121 } |
| 122 | 122 |
| 123 // Scale proportionately. | 123 // Scale proportionately. |
| 124 float scale = std::min(static_cast<float>(width()) / scalable_w, | 124 float scale = std::min(static_cast<float>(width()) / scalable_w, |
| 125 static_cast<float>(height()) / scalable_h); | 125 static_cast<float>(height()) / scalable_h); |
| 126 int dest_w = static_cast<int>(float_src_w * scale); | 126 int dest_w = static_cast<int>(float_src_w * scale); |
| 127 int dest_h = static_cast<int>(float_src_h * scale); | 127 int dest_h = static_cast<int>(float_src_h * scale); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 144 rendered = true; | 144 rendered = true; |
| 145 PaintFavIcon(canvas, favicon); | 145 PaintFavIcon(canvas, favicon); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 if (!rendered) | 149 if (!rendered) |
| 150 PaintFavIcon(canvas, *g_default_fav_icon); | 150 PaintFavIcon(canvas, *g_default_fav_icon); |
| 151 } | 151 } |
| 152 | 152 |
| 153 gfx::Size TabIconView::GetPreferredSize() { | 153 gfx::Size TabIconView::GetPreferredSize() { |
| 154 return gfx::Size(kFavIconSize, kFavIconSize); | 154 return gfx::Size(kFaviconSize, kFaviconSize); |
| 155 } | 155 } |
| OLD | NEW |