summaryrefslogtreecommitdiffstats
path: root/ui/gfx/canvas.cc
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-09 23:17:35 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-09 23:17:35 +0000
commit4b01b9680e67ba802e8a16027ffe4b4d435fc1e8 (patch)
tree675aa1ca07fa8f0d3bb1f0f4249822a6bf4e817d /ui/gfx/canvas.cc
parent0c77646718f41510a03905f1ed31cd382109a6c4 (diff)
downloadchromium_src-4b01b9680e67ba802e8a16027ffe4b4d435fc1e8.zip
chromium_src-4b01b9680e67ba802e8a16027ffe4b4d435fc1e8.tar.gz
chromium_src-4b01b9680e67ba802e8a16027ffe4b4d435fc1e8.tar.bz2
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
Diffstat (limited to 'ui/gfx/canvas.cc')
-rw-r--r--ui/gfx/canvas.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/ui/gfx/canvas.cc b/ui/gfx/canvas.cc
index c4f98d6..78badf1 100644
--- a/ui/gfx/canvas.cc
+++ b/ui/gfx/canvas.cc
@@ -13,6 +13,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/rect.h"
+#include "ui/gfx/size_conversions.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/transform.h"
@@ -28,7 +29,8 @@ Canvas::Canvas(const gfx::Size& size,
: scale_factor_(scale_factor),
owned_canvas_(NULL),
canvas_(NULL) {
- gfx::Size pixel_size = size.Scale(ui::GetScaleFactorScale(scale_factor));
+ gfx::Size pixel_size = gfx::ToFlooredSize(size.Scale(
+ ui::GetScaleFactorScale(scale_factor)));
owned_canvas_.reset(new skia::PlatformCanvas(pixel_size.width(),
pixel_size.height(),
is_opaque));
@@ -74,7 +76,8 @@ void Canvas::RecreateBackingCanvas(const gfx::Size& size,
ui::ScaleFactor scale_factor,
bool is_opaque) {
scale_factor_ = scale_factor;
- gfx::Size pixel_size = size.Scale(ui::GetScaleFactorScale(scale_factor));
+ gfx::Size pixel_size = gfx::ToFlooredSize(
+ size.Scale(ui::GetScaleFactorScale(scale_factor)));
owned_canvas_.reset(new skia::PlatformCanvas(pixel_size.width(),
pixel_size.height(),
is_opaque));