Chromium Code Reviews| 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 "ui/gfx/favicon_size.h" | 5 #include "ui/gfx/favicon_size.h" |
| 6 | 6 |
| 7 namespace gfx { | 7 namespace gfx { |
| 8 | 8 |
| 9 const int kFaviconSize = 16; | 9 const int kFaviconSize = 16; |
| 10 | 10 |
| 11 const int kHdpiFaviconSize = 32; | |
|
sky
2017/01/31 23:28:45
This isn't entirely accurate. High dpi generally m
chengx
2017/02/02 20:52:58
Acknowledged.
| |
| 12 | |
| 11 void CalculateFaviconTargetSize(int* width, int* height) { | 13 void CalculateFaviconTargetSize(int* width, int* height) { |
| 12 if (*width > kFaviconSize || *height > kFaviconSize) { | 14 if (*width > kFaviconSize || *height > kFaviconSize) { |
| 13 // Too big, resize it maintaining the aspect ratio. | 15 // Too big, resize it maintaining the aspect ratio. |
| 14 float aspect_ratio = static_cast<float>(*width) / | 16 float aspect_ratio = static_cast<float>(*width) / |
| 15 static_cast<float>(*height); | 17 static_cast<float>(*height); |
| 16 *height = kFaviconSize; | 18 *height = kFaviconSize; |
| 17 *width = static_cast<int>(aspect_ratio * *height); | 19 *width = static_cast<int>(aspect_ratio * *height); |
| 18 if (*width > kFaviconSize) { | 20 if (*width > kFaviconSize) { |
| 19 *width = kFaviconSize; | 21 *width = kFaviconSize; |
| 20 *height = static_cast<int>(*width / aspect_ratio); | 22 *height = static_cast<int>(*width / aspect_ratio); |
| 21 } | 23 } |
| 22 } | 24 } |
| 23 } | 25 } |
| 24 | 26 |
| 25 } // namespace gfx | 27 } // namespace gfx |
| OLD | NEW |