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

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: Add rect_util_unittests to GN 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 {
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|.
27 GFX_EXPORT RectEdge FindTouchingRectEdge(gfx::Rect ref, gfx::Rect test);
oshima 2016/02/11 22:59:58 const &
robliao 2016/02/12 01:52:53 These actually started as const gfx::Rect& and the
oshima 2016/02/12 23:18:26 For correctness, I'd rely on the unit tests rather
robliao 2016/02/13 01:27:49 Thanks for the intersecting rect pointer. I probab
oshima 2016/02/16 06:03:26 Ok. I'll leave the rest to owners review. (I don't
28
29 // Returns a scaled and positioned rect based off of target_rect and context.
30 // The reference rectangle and target rectangle may scale at different rates.
31 // This function attempts to preserve the relative positioning of the target
32 // rectangle with respect to the scaled rectangle in the face of differing
33 // scale factors.
34 //
35 // Examples:
36 // +--------------+ Since both rectangles are of the same
37 // | | scale factor, positions and sizes
38 // | | remain the same.
39 // | REF 1x +----------+
40 // | | |
41 // +--------------+ 1x |
42 // | |
43 // +----------+
44 //
45 // Original
46 // +--------------+ The 2x rectangle is scaled down while
47 // | | maintaining a similar neighboring relationship
48 // | | with the 1x rectangle.
49 // | REF 1x +----------+
50 // | | |
51 // +--------------+ 2x |
52 // | |
53 // +----------+
54 // Scaled
55 // +--------------+
56 // | |
57 // | |
58 // | REF 1x |
59 // | +-----+
60 // +--------------+ 2x |
61 // +-----+
62 GFX_EXPORT gfx::Rect ScaleAndPositionRect(gfx::Rect ref_scaled_rect,
63 gfx::Rect ref_original_rect,
64 gfx::Rect target_rect,
65 float target_scale_factor);
66
67 // Returns the squared distance between two rects.
68 // The distance between two rects is the length of the shortest segment that can
69 // be drawn between two rectangles. This generally the segment connects two
70 // opposing corners between rectangles like this...
71 //
72 // +----------+
73 // | |
74 // +----------+
75 // \ <--- Shortest Segment
76 // \
77 // +---+
78 // | |
79 // | |
80 // +---+
81 // For rectangles that share coordinates within the same axis, that generally
82 // means the segment is parallel to the axis and perpendicular to the edges.
83 //
84 // One of many shortest segments
85 // +----------+ / \ +--------+
86 // | | | \ | |
87 // | | V +---+ \ +--------+
88 // | |-----| | \-->|
89 // +----------+ | | +----+
90 // | | | |
91 // +---+ +----+
92 //
93 // For rectangles that intersect each other, the distance is 0.
94 //
95 // The squared distance is used to avoid taking the square root as the common
96 // usage is to compare distances greather than 1 unit.
97 GFX_EXPORT int64_t SquaredDistanceBetweenRects(gfx::Rect ref, gfx::Rect rect);
98
99 } // namespace win
100 } // namespace gfx
101
102 #endif // UI_GFX_WIN_RECT_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698