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

Side by Side Diff: ui/gfx/mac/coordinate_conversion.mm

Issue 789763002: MacViews: Implement capture using NSEvent local+global monitors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20140812-MacViews-LAYERS2-PRESQUASH
Patch Set: NULL -> nullptr Created 6 years 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/mac/coordinate_conversion.h ('k') | ui/gfx/mac/coordinate_conversion_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/gfx/mac/coordinate_conversion.h" 5 #import "ui/gfx/mac/coordinate_conversion.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/point.h"
10 11
11 namespace gfx { 12 namespace gfx {
12 13
13 namespace { 14 namespace {
14 15
15 // The height of the primary display, which OSX defines as the monitor with the 16 // The height of the primary display, which OSX defines as the monitor with the
16 // menubar. This is always at index 0. 17 // menubar. This is always at index 0.
17 CGFloat PrimaryDisplayHeight() { 18 CGFloat PrimaryDisplayHeight() {
18 return NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]); 19 return NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]);
19 } 20 }
20 21
21 } // namespace 22 } // namespace
22 23
23 NSRect ScreenRectToNSRect(const gfx::Rect& rect) { 24 NSRect ScreenRectToNSRect(const gfx::Rect& rect) {
24 return NSMakeRect(rect.x(), 25 return NSMakeRect(rect.x(),
25 PrimaryDisplayHeight() - rect.y() - rect.height(), 26 PrimaryDisplayHeight() - rect.y() - rect.height(),
26 rect.width(), 27 rect.width(),
27 rect.height()); 28 rect.height());
28 } 29 }
29 30
30 gfx::Rect ScreenRectFromNSRect(const NSRect& rect) { 31 gfx::Rect ScreenRectFromNSRect(const NSRect& rect) {
31 return gfx::Rect(rect.origin.x, 32 return gfx::Rect(rect.origin.x,
32 PrimaryDisplayHeight() - rect.origin.y - rect.size.height, 33 PrimaryDisplayHeight() - rect.origin.y - rect.size.height,
33 rect.size.width, 34 rect.size.width,
34 rect.size.height); 35 rect.size.height);
35 } 36 }
36 37
38 NSPoint ScreenPointToNSPoint(const gfx::Point& point) {
39 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y());
40 }
41
42 gfx::Point ScreenPointFromNSPoint(const NSPoint& point) {
43 return gfx::Point(point.x, PrimaryDisplayHeight() - point.y);
44 }
45
37 } // namespace gfx 46 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/mac/coordinate_conversion.h ('k') | ui/gfx/mac/coordinate_conversion_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698