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 UI_GFX_FAVICON_SIZE_H_ | 5 #ifndef UI_GFX_FAVICON_SIZE_H_ |
6 #define UI_GFX_FAVICON_SIZE_H_ | 6 #define UI_GFX_FAVICON_SIZE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 | 10 |
11 // Size (along each axis) of the favicon. | 11 // Size (along each axis) of the favicon. |
12 const int kFaviconSize = 16; | 12 const int kFaviconSize = 16; |
13 | 13 |
14 // If the width or height is bigger than the favicon size, a new width/height | 14 // If the width or height is bigger than the favicon size, a new width/height |
15 // is calculated and returned in width/height that maintains the aspect | 15 // is calculated and returned in width/height that maintains the aspect |
16 // ratio of the supplied values. | 16 // ratio of the supplied values. |
17 static void calc_favicon_target_size(int* width, int* height) ALLOW_UNUSED; | 17 static void calc_favicon_target_size(int target_size, |
sky
2011/03/23 22:49:31
Do we really need these changes? Aren't you still
michaelbai
2011/03/23 23:26:49
I thought it might useful for touch_icon in the fu
| |
18 int* width, | |
19 int* height) ALLOW_UNUSED; | |
18 | 20 |
19 // static | 21 // static |
20 void calc_favicon_target_size(int* width, int* height) { | 22 void calc_favicon_target_size(int target_size, int* width, int* height) { |
21 if (*width > kFaviconSize || *height > kFaviconSize) { | 23 if (*width > target_size || *height > target_size) { |
22 // Too big, resize it maintaining the aspect ratio. | 24 // Too big, resize it maintaining the aspect ratio. |
23 float aspect_ratio = static_cast<float>(*width) / | 25 float aspect_ratio = static_cast<float>(*width) / |
24 static_cast<float>(*height); | 26 static_cast<float>(*height); |
25 *height = kFaviconSize; | 27 *height = target_size; |
26 *width = static_cast<int>(aspect_ratio * *height); | 28 *width = static_cast<int>(aspect_ratio * *height); |
27 if (*width > kFaviconSize) { | 29 if (*width > target_size) { |
28 *width = kFaviconSize; | 30 *width = target_size; |
29 *height = static_cast<int>(*width / aspect_ratio); | 31 *height = static_cast<int>(*width / aspect_ratio); |
30 } | 32 } |
31 } | 33 } |
32 } | 34 } |
33 | 35 |
34 #endif // UI_GFX_FAVICON_SIZE_H_ | 36 #endif // UI_GFX_FAVICON_SIZE_H_ |
OLD | NEW |