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

Side by Side Diff: ui/gfx/win/rect_util.h

Issue 1679393002: Multiple DPI Tracking for ScreenWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to b4da629 and a few equivalent comparison tweaks in rect_util Created 4 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2016 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 #ifndef UI_GFX_WIN_RECT_UTIL_H_
6 #define UI_GFX_WIN_RECT_UTIL_H_
7
8 #include <stdint.h>
9
10 #include "ui/gfx/gfx_export.h"
11
12 namespace gfx {
13
14 class Rect;
15
16 namespace win {
sky 2016/02/17 04:40:28 This file name is very generic. I don't think we w
robliao 2016/02/18 00:34:39 Given that this is primarily used by ScreenWin, ho
sky 2016/02/18 17:02:58 SGTM
17
18 enum class RectEdge {
19 BOTTOM = 0,
20 LEFT = 1,
21 TOP = 2,
22 RIGHT = 3,
23 NONE = 4,
24 };
25
26 // Returns |ref|'s RectEdge touching |test|.
sky 2016/02/17 17:28:48 Clarify if the two rects are guaranteed to touch.
robliao 2016/02/18 00:34:39 Done.
27 GFX_EXPORT RectEdge FindTouchingRectEdge(const gfx::Rect& ref,
28 const gfx::Rect& test);
29
30 // Returns a scaled and positioned rect based off of target_rect and context.
sky 2016/02/17 04:40:29 there is no context param.
robliao 2016/02/18 00:34:39 Clarified.
31 // The reference rectangle and target rectangle may scale at different rates.
32 // This function attempts to preserve the relative positioning of the target
33 // rectangle with respect to the scaled rectangle in the face of differing
34 // scale factors.
sky 2016/02/17 04:40:29 Without looking at the implementation this descrip
sky 2016/02/17 17:28:48 One more comment. It is also isn't clear if the re
robliao 2016/02/18 00:34:39 Clarified the comment and added another example. F
35 //
36 // Examples:
37 // +--------------+ Since both rectangles are of the same
38 // | | scale factor, positions and sizes
39 // | | remain the same.
40 // | REF 1x +----------+
41 // | | |
42 // +--------------+ 1x |
43 // | |
44 // +----------+
45 //
46 // Original
47 // +--------------+ The 2x rectangle is scaled down while
48 // | | maintaining a similar neighboring relationship
49 // | | with the 1x rectangle.
50 // | REF 1x +----------+
51 // | | |
52 // +--------------+ 2x |
53 // | |
54 // +----------+
55 // Scaled
56 // +--------------+
57 // | |
58 // | |
59 // | REF 1x |
60 // | +-----+
61 // +--------------+ 2x |
62 // +-----+
63 GFX_EXPORT gfx::Rect ScaleAndPositionRect(gfx::Rect ref_scaled_rect,
sky 2016/02/17 04:40:29 const& on the params here and below. Use different
robliao 2016/02/18 00:34:39 Done.
64 gfx::Rect ref_original_rect,
65 gfx::Rect target_rect,
sky 2016/02/17 17:28:48 It's not clear if target_rect is scaled or not.
robliao 2016/02/18 00:34:39 Clarified via rename.
66 float target_scale_factor);
67
68 // Returns the squared distance between two rects.
69 // The distance between two rects is the length of the shortest segment that can
70 // be drawn between two rectangles. This segment generally connects two opposing
71 // corners between rectangles like this...
72 //
73 // +----------+
74 // | |
75 // +----------+
76 // \ <--- Shortest Segment
77 // \
78 // +---+
79 // | |
80 // | |
81 // +---+
82 //
83 // For rectangles that share coordinates within the same axis, that generally
84 // means the segment is parallel to the axis and perpendicular to the edges.
85 //
86 // One of many shortest segments
87 // +----------+ / \ +--------+
88 // | | | \ | |
89 // | | V +---+ \ +--------+
90 // | |-----| | \-->|
91 // +----------+ | | +----+
92 // | | | |
93 // +---+ +----+
94 //
95 // For rectangles that intersect each other, the distance is 0.
96 //
97 // The squared distance is used to avoid taking the square root as the common
98 // usage is to compare distances greater than 1 unit.
99 GFX_EXPORT int64_t SquaredDistanceBetweenRects(gfx::Rect ref, gfx::Rect rect);
100
101 } // namespace win
102 } // namespace gfx
103
104 #endif // UI_GFX_WIN_RECT_UTIL_H_
OLDNEW
« no previous file with comments | « ui/gfx/win/dpi.cc ('k') | ui/gfx/win/rect_util.cc » ('j') | ui/gfx/win/rect_util.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698