From 4b01b9680e67ba802e8a16027ffe4b4d435fc1e8 Mon Sep 17 00:00:00 2001 From: "danakj@chromium.org" Date: Tue, 9 Oct 2012 23:17:35 +0000 Subject: Remove implicit flooring Scale() method from Point and Size. When scaling an integer point or size, return a floating point result. Implicitly flooring hides design problems and bugs. Add conversion functions to floor or ceil a SizeF or PointF into an integer format again. All existing behaviour has been preserved by replacing uses of foo.Scale() with ToFlooredFoo(foo.Scale()). R=sky BUG=147395 Review URL: https://chromiumcodereview.appspot.com/11081007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160970 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/gfx/size_conversions.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ui/gfx/size_conversions.cc (limited to 'ui/gfx/size_conversions.cc') diff --git a/ui/gfx/size_conversions.cc b/ui/gfx/size_conversions.cc new file mode 100644 index 0000000..9668aaa --- /dev/null +++ b/ui/gfx/size_conversions.cc @@ -0,0 +1,24 @@ +// Copyright (c) 2012 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. + +#include "ui/gfx/size_conversions.h" + +#include "ui/gfx/safe_floor_ceil.h" + +namespace gfx { + +Size ToFlooredSize(const SizeF& size) { + int w = ToFlooredInt(size.width()); + int h = ToFlooredInt(size.height()); + return Size(w, h); +} + +Size ToCeiledSize(const SizeF& size) { + int w = ToCeiledInt(size.width()); + int h = ToCeiledInt(size.height()); + return Size(w, h); +} + +} // namespace gfx + -- cgit v1.1