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

Side by Side Diff: ui/gfx/geometry/rect_f.cc

Issue 1271123002: Mac: Enable partial swap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 4 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
« no previous file with comments | « ui/gfx/geometry/rect_f.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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/geometry/rect_f.h" 5 #include "ui/gfx/geometry/rect_f.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #if defined(OS_IOS)
10 #include <CoreGraphics/CoreGraphics.h>
11 #elif defined(OS_MACOSX)
12 #include <ApplicationServices/ApplicationServices.h>
13 #endif
14
9 #include "base/logging.h" 15 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
11 #include "ui/gfx/geometry/insets_f.h" 17 #include "ui/gfx/geometry/insets_f.h"
12 #include "ui/gfx/geometry/safe_integer_conversions.h" 18 #include "ui/gfx/geometry/safe_integer_conversions.h"
13 19
14 namespace gfx { 20 namespace gfx {
15 21
16 static void AdjustAlongAxis(float dst_origin, 22 static void AdjustAlongAxis(float dst_origin,
17 float dst_size, 23 float dst_size,
18 float* origin, 24 float* origin,
19 float* size) { 25 float* size) {
20 *size = std::min(dst_size, *size); 26 *size = std::min(dst_size, *size);
21 if (*origin < dst_origin) 27 if (*origin < dst_origin)
22 *origin = dst_origin; 28 *origin = dst_origin;
23 else 29 else
24 *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; 30 *origin = std::min(dst_origin + dst_size, *origin + *size) - *size;
25 } 31 }
26 32
33 #if defined(OS_MACOSX)
34 RectF::RectF(const CGRect& r)
35 : origin_(r.origin.x, r.origin.y), size_(r.size.width, r.size.height) {
36 }
37
38 CGRect RectF::ToCGRect() const {
39 return CGRectMake(x(), y(), width(), height());
40 }
41 #endif
42
27 void RectF::Inset(const InsetsF& insets) { 43 void RectF::Inset(const InsetsF& insets) {
28 Inset(insets.left(), insets.top(), insets.right(), insets.bottom()); 44 Inset(insets.left(), insets.top(), insets.right(), insets.bottom());
29 } 45 }
30 46
31 void RectF::Inset(float left, float top, float right, float bottom) { 47 void RectF::Inset(float left, float top, float right, float bottom) {
32 origin_ += Vector2dF(left, top); 48 origin_ += Vector2dF(left, top);
33 set_width(std::max(width() - left - right, static_cast<float>(0))); 49 set_width(std::max(width() - left - right, static_cast<float>(0)));
34 set_height(std::max(height() - top - bottom, static_cast<float>(0))); 50 set_height(std::max(height() - top - bottom, static_cast<float>(0)));
35 } 51 }
36 52
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 253
238 RectF BoundingRect(const PointF& p1, const PointF& p2) { 254 RectF BoundingRect(const PointF& p1, const PointF& p2) {
239 float rx = std::min(p1.x(), p2.x()); 255 float rx = std::min(p1.x(), p2.x());
240 float ry = std::min(p1.y(), p2.y()); 256 float ry = std::min(p1.y(), p2.y());
241 float rr = std::max(p1.x(), p2.x()); 257 float rr = std::max(p1.x(), p2.x());
242 float rb = std::max(p1.y(), p2.y()); 258 float rb = std::max(p1.y(), p2.y());
243 return RectF(rx, ry, rr - rx, rb - ry); 259 return RectF(rx, ry, rr - rx, rb - ry);
244 } 260 }
245 261
246 } // namespace gfx 262 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/rect_f.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698