| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_COMMON_GFX_FAVICON_SIZE_H__ | 5 #ifndef CHROME_COMMON_GFX_FAVICON_SIZE_H__ |
| 6 #define CHROME_COMMON_GFX_FAVICON_SIZE_H__ | 6 #define CHROME_COMMON_GFX_FAVICON_SIZE_H__ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" |
| 9 |
| 8 // Size (along each axis) of the favicon. | 10 // Size (along each axis) of the favicon. |
| 9 const int kFavIconSize = 16; | 11 const int kFavIconSize = 16; |
| 10 | 12 |
| 11 // If the width or height is bigger than the favicon size, a new width/height | 13 // If the width or height is bigger than the favicon size, a new width/height |
| 12 // is calculated and returned in width/height that maintains the aspect | 14 // is calculated and returned in width/height that maintains the aspect |
| 13 // ratio of the supplied values. | 15 // ratio of the supplied values. |
| 14 static void calc_favicon_target_size(int* width, int* height) { | 16 static void calc_favicon_target_size(int* width, int* height) ALLOW_UNUSED; |
| 17 |
| 18 // static |
| 19 void calc_favicon_target_size(int* width, int* height) { |
| 15 if (*width > kFavIconSize || *height > kFavIconSize) { | 20 if (*width > kFavIconSize || *height > kFavIconSize) { |
| 16 // Too big, resize it maintaining the aspect ratio. | 21 // Too big, resize it maintaining the aspect ratio. |
| 17 float aspect_ratio = static_cast<float>(*width) / | 22 float aspect_ratio = static_cast<float>(*width) / |
| 18 static_cast<float>(*height); | 23 static_cast<float>(*height); |
| 19 *height = kFavIconSize; | 24 *height = kFavIconSize; |
| 20 *width = static_cast<int>(aspect_ratio * *height); | 25 *width = static_cast<int>(aspect_ratio * *height); |
| 21 if (*width > kFavIconSize) { | 26 if (*width > kFavIconSize) { |
| 22 *width = kFavIconSize; | 27 *width = kFavIconSize; |
| 23 *height = static_cast<int>(*width / aspect_ratio); | 28 *height = static_cast<int>(*width / aspect_ratio); |
| 24 } | 29 } |
| 25 } | 30 } |
| 26 } | 31 } |
| 27 | 32 |
| 28 #endif // CHROME_COMMON_GFX_FAVICON_SIZE_H__ | 33 #endif // CHROME_COMMON_GFX_FAVICON_SIZE_H__ |
| 29 | 34 |
| OLD | NEW |