diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 02:23:31 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 02:23:31 +0000 |
commit | 3712621396b5ffa5572bc5c0728a63efe9f7476e (patch) | |
tree | a55fc85f01bafbe1ae86e43c5f1ce9638db5b621 /app/gfx/favicon_size.h | |
parent | af9a8c86fc50e8d789bf795347302e6c94ad6854 (diff) | |
download | chromium_src-3712621396b5ffa5572bc5c0728a63efe9f7476e.zip chromium_src-3712621396b5ffa5572bc5c0728a63efe9f7476e.tar.gz chromium_src-3712621396b5ffa5572bc5c0728a63efe9f7476e.tar.bz2 |
Move: drag_drop_types, favicon_size, icon_util, insets, path, message_box_flags, os_exchange_data to src/app
http://crbug.com/11387
Review URL: http://codereview.chromium.org/115012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/gfx/favicon_size.h')
-rw-r--r-- | app/gfx/favicon_size.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/gfx/favicon_size.h b/app/gfx/favicon_size.h new file mode 100644 index 0000000..fb66411 --- /dev/null +++ b/app/gfx/favicon_size.h @@ -0,0 +1,33 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef APP_GFX_FAVICON_SIZE_H_ +#define APP_GFX_FAVICON_SIZE_H_ + +#include "base/compiler_specific.h" + +// Size (along each axis) of the favicon. +const int kFavIconSize = 16; + +// If the width or height is bigger than the favicon size, a new width/height +// is calculated and returned in width/height that maintains the aspect +// ratio of the supplied values. +static void calc_favicon_target_size(int* width, int* height) ALLOW_UNUSED; + +// static +void calc_favicon_target_size(int* width, int* height) { + if (*width > kFavIconSize || *height > kFavIconSize) { + // Too big, resize it maintaining the aspect ratio. + float aspect_ratio = static_cast<float>(*width) / + static_cast<float>(*height); + *height = kFavIconSize; + *width = static_cast<int>(aspect_ratio * *height); + if (*width > kFavIconSize) { + *width = kFavIconSize; + *height = static_cast<int>(*width / aspect_ratio); + } + } +} + +#endif // APP_GFX_FAVICON_SIZE_H_ |