Index: ui/views/paint_info.h |
diff --git a/ui/views/paint_info.h b/ui/views/paint_info.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..86c04828250087c703fa019e60e9d06efbe3ad4c |
--- /dev/null |
+++ b/ui/views/paint_info.h |
@@ -0,0 +1,90 @@ |
+// 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
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef UI_VIEWS_PAINT_INFO_H_ |
+#define UI_VIEWS_PAINT_INFO_H_ |
+ |
+#include "ui/compositor/paint_context.h" |
+#include "ui/gfx/geometry/rect.h" |
+#include "ui/views/views_export.h" |
+ |
+namespace views { |
+ |
+class VIEWS_EXPORT PaintInfo { |
sky
2017/07/26 22:12:11
Please add a description.
malaykeshav
2017/07/28 01:24:37
Done
|
+ public: |
+ enum class ScaleType { |
+ // 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
|
+ // of distortion during scaling. |
sky
2017/07/28 16:02:11
Distortion is bad, so based on this description I
|
+ 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*
|
+ |
+ // Scales the context based on the effective dsf. This may lead to minor |
+ // distortion during scaling due to edge snapping. |
+ kScaleToFit |
+ }; |
+ |
+ PaintInfo(const ui::PaintContext& context, const gfx::Size& size); |
+ PaintInfo(const PaintInfo& other, |
+ const gfx::Rect& bounds, |
+ const gfx::Rect& parent_bounds, |
+ ScaleType scale_type); |
+ PaintInfo(const PaintInfo& other); |
+ ~PaintInfo(); |
+ |
+ const ui::PaintContext& context() const { |
+ return root_context_ ? *root_context_ : context_; |
+ } |
+ |
+ gfx::Vector2d offset_from_root() const { |
+ return paint_recording_bounds_.OffsetFromOrigin(); |
+ } |
+ |
+ bool IsPixelCanvas() const; |
sky
2017/07/26 22:12:12
Add description.
malaykeshav
2017/07/28 01:24:38
Done
|
+ |
+ 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
|
+ |
+ gfx::PointF paint_recording_scale() const { |
+ return gfx::PointF(paint_recording_scale_x_, paint_recording_scale_y_); |
+ } |
+ |
+ const gfx::Size& paint_recording_size() const { |
+ return paint_recording_bounds_.size(); |
+ } |
+ |
+ const gfx::Rect& paint_recording_bounds() const { |
+ return paint_recording_bounds_; |
+ } |
+ |
+ private: |
+ // The scale at which the paint commands are recorded at. Due to the decimal |
+ // rounding and snapping to edges during scaling operations, the effective |
+ // paint recording scale may end up being slightly different between the x and |
+ // y axis. |
+ float paint_recording_scale_x_; |
+ float paint_recording_scale_y_; |
+ |
+ // 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
|
+ // paint context. |
+ const gfx::Rect paint_recording_bounds_; |
+ |
+ // Offset relative to the parent paint context. |
+ gfx::Vector2d offset_from_parent_; |
+ |
+ // Compositor PaintContext associated with the view this object belongs to. |
+ ui::PaintContext context_; |
+ const ui::PaintContext* root_context_; |
+ |
+ // Given the DIP |size|, this function updates the paint recording scales. |
+ 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
|
+ |
+ // Scales the |child_bounds| to its recording bounds based on the |
+ // |context.device_scale_factor()|. The recording bounds are snapped to the |
+ // |parent_bound|'s right and/or bottom edge if required. |
+ // If pixel canvas is disabled, this function returns |child_bounds| as is. |
+ gfx::Rect GetSnappedRecordingBounds(const gfx::Rect& parent_bounds, |
+ const gfx::Rect& child_bounds) const; |
+}; |
+ |
+} // namespace views |
+ |
+#endif // UI_VIEWS_PAINT_INFO_H_ |