OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
sky
2017/07/26 22:12:12
no (c) (see style guide).
malaykeshav
2017/07/28 01:24:37
Done
| |
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_VIEWS_PAINT_INFO_H_ | |
6 #define UI_VIEWS_PAINT_INFO_H_ | |
7 | |
8 #include "ui/compositor/paint_context.h" | |
9 #include "ui/gfx/geometry/rect.h" | |
10 #include "ui/views/views_export.h" | |
11 | |
12 namespace views { | |
13 | |
14 class VIEWS_EXPORT PaintInfo { | |
sky
2017/07/26 22:12:11
Please add a description.
malaykeshav
2017/07/28 01:24:37
Done
| |
15 public: | |
16 enum class ScaleType { | |
17 // Scales the context by the default dsf. Use this if you dont want any form | |
sky
2017/07/26 22:12:12
dont => don't
malaykeshav
2017/07/28 01:24:37
Done
| |
18 // of distortion during scaling. | |
sky
2017/07/28 16:02:11
Distortion is bad, so based on this description I
| |
19 kScaleToScaleFactor = 0, | |
sky
2017/07/26 22:12:11
Do we really need both of these? I don't see any u
malaykeshav
2017/07/28 01:24:37
This is needed in the subsequent changes when deal
sky
2017/07/28 16:02:11
Please document (in View::GetPaintScaleType) *why*
| |
20 | |
21 // Scales the context based on the effective dsf. This may lead to minor | |
22 // distortion during scaling due to edge snapping. | |
23 kScaleToFit | |
24 }; | |
25 | |
26 PaintInfo(const ui::PaintContext& context, const gfx::Size& size); | |
27 PaintInfo(const PaintInfo& other, | |
28 const gfx::Rect& bounds, | |
29 const gfx::Rect& parent_bounds, | |
30 ScaleType scale_type); | |
31 PaintInfo(const PaintInfo& other); | |
32 ~PaintInfo(); | |
33 | |
34 const ui::PaintContext& context() const { | |
35 return root_context_ ? *root_context_ : context_; | |
36 } | |
37 | |
38 gfx::Vector2d offset_from_root() const { | |
39 return paint_recording_bounds_.OffsetFromOrigin(); | |
40 } | |
41 | |
42 bool IsPixelCanvas() const; | |
sky
2017/07/26 22:12:12
Add description.
malaykeshav
2017/07/28 01:24:38
Done
| |
43 | |
44 gfx::Vector2d offset_from_parent() const { return offset_from_parent_; } | |
sky
2017/07/26 22:12:12
const gfx::Vector2&
malaykeshav
2017/07/28 01:24:37
Done
| |
45 | |
46 gfx::PointF paint_recording_scale() const { | |
47 return gfx::PointF(paint_recording_scale_x_, paint_recording_scale_y_); | |
48 } | |
49 | |
50 const gfx::Size& paint_recording_size() const { | |
51 return paint_recording_bounds_.size(); | |
52 } | |
53 | |
54 const gfx::Rect& paint_recording_bounds() const { | |
55 return paint_recording_bounds_; | |
56 } | |
57 | |
58 private: | |
59 // The scale at which the paint commands are recorded at. Due to the decimal | |
60 // rounding and snapping to edges during scaling operations, the effective | |
61 // paint recording scale may end up being slightly different between the x and | |
62 // y axis. | |
63 float paint_recording_scale_x_; | |
64 float paint_recording_scale_y_; | |
65 | |
66 // Paint Recording bounds for this view. The offset is relative to the root | |
sky
2017/07/26 22:12:12
Please document coordinates. It isn't readily clea
malaykeshav
2017/07/28 01:24:37
Done
| |
67 // paint context. | |
68 const gfx::Rect paint_recording_bounds_; | |
69 | |
70 // Offset relative to the parent paint context. | |
71 gfx::Vector2d offset_from_parent_; | |
72 | |
73 // Compositor PaintContext associated with the view this object belongs to. | |
74 ui::PaintContext context_; | |
75 const ui::PaintContext* root_context_; | |
76 | |
77 // Given the DIP |size|, this function updates the paint recording scales. | |
78 void ComputePaintRecordingScales(const gfx::Size& size, ScaleType scale_type); | |
sky
2017/07/26 22:12:12
functions then members.
malaykeshav
2017/07/28 01:24:37
Done
| |
79 | |
80 // Scales the |child_bounds| to its recording bounds based on the | |
81 // |context.device_scale_factor()|. The recording bounds are snapped to the | |
82 // |parent_bound|'s right and/or bottom edge if required. | |
83 // If pixel canvas is disabled, this function returns |child_bounds| as is. | |
84 gfx::Rect GetSnappedRecordingBounds(const gfx::Rect& parent_bounds, | |
85 const gfx::Rect& child_bounds) const; | |
86 }; | |
87 | |
88 } // namespace views | |
89 | |
90 #endif // UI_VIEWS_PAINT_INFO_H_ | |
OLD | NEW |