Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: ui/gfx/rect_conversions.cc

Issue 10996037: Do not convert from RectF to Rect by flooring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/gfx/rect_conversions.h"
6
7 #include "ui/gfx/safe_floor_ceil.h"
8
9 namespace gfx {
10
11 Rect ToEnclosingRect(const RectF& rect) {
12 int min_x = ToFlooredInt(rect.origin().x());
13 int min_y = ToFlooredInt(rect.origin().y());
14 float max_x = rect.origin().x() + rect.size().width();
15 float max_y = rect.origin().y() + rect.size().height();
16 int width = std::max(ToCeiledInt(max_x) - min_x, 0);
17 int height = std::max(ToCeiledInt(max_y) - min_y, 0);
18 return Rect(min_x, min_y, width, height);
19 }
20
21 Rect ToEnclosedRect(const RectF& rect) {
22 int min_x = ToCeiledInt(rect.origin().x());
23 int min_y = ToCeiledInt(rect.origin().y());
24 float max_x = rect.origin().x() + rect.size().width();
25 float max_y = rect.origin().y() + rect.size().height();
26 int width = std::max(ToFlooredInt(max_x) - min_x, 0);
27 int height = std::max(ToFlooredInt(max_y) - min_y, 0);
28 return Rect(min_x, min_y, width, height);
29 }
30
31 } // namespace gfx
32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698