| 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 "build/build_config.h" | |
| 9 | |
| 10 // Size (along each axis) of the favicon. | 8 // Size (along each axis) of the favicon. |
| 11 const int kFavIconSize = 16; | 9 const int kFavIconSize = 16; |
| 12 | 10 |
| 13 #if !defined(OS_LINUX) | |
| 14 // GCC 4.2 complains that this function is not used, and currently | |
| 15 // it's not used by any file compiled on Linux. GCC 4.3 does not complain. | |
| 16 | |
| 17 // If the width or height is bigger than the favicon size, a new width/height | 11 // If the width or height is bigger than the favicon size, a new width/height |
| 18 // is calculated and returned in width/height that maintains the aspect | 12 // is calculated and returned in width/height that maintains the aspect |
| 19 // ratio of the supplied values. | 13 // ratio of the supplied values. |
| 20 static void calc_favicon_target_size(int* width, int* height) { | 14 static void calc_favicon_target_size(int* width, int* height) { |
| 21 if (*width > kFavIconSize || *height > kFavIconSize) { | 15 if (*width > kFavIconSize || *height > kFavIconSize) { |
| 22 // Too big, resize it maintaining the aspect ratio. | 16 // Too big, resize it maintaining the aspect ratio. |
| 23 float aspect_ratio = static_cast<float>(*width) / | 17 float aspect_ratio = static_cast<float>(*width) / |
| 24 static_cast<float>(*height); | 18 static_cast<float>(*height); |
| 25 *height = kFavIconSize; | 19 *height = kFavIconSize; |
| 26 *width = static_cast<int>(aspect_ratio * *height); | 20 *width = static_cast<int>(aspect_ratio * *height); |
| 27 if (*width > kFavIconSize) { | 21 if (*width > kFavIconSize) { |
| 28 *width = kFavIconSize; | 22 *width = kFavIconSize; |
| 29 *height = static_cast<int>(*width / aspect_ratio); | 23 *height = static_cast<int>(*width / aspect_ratio); |
| 30 } | 24 } |
| 31 } | 25 } |
| 32 } | 26 } |
| 33 | 27 |
| 34 #endif // !defined(OS_LINUX) | |
| 35 | |
| 36 #endif // CHROME_COMMON_GFX_FAVICON_SIZE_H__ | 28 #endif // CHROME_COMMON_GFX_FAVICON_SIZE_H__ |
| 37 | 29 |
| OLD | NEW |