Chromium Code Reviews| Index: ui/views/view.cc |
| diff --git a/ui/views/view.cc b/ui/views/view.cc |
| index 3809c1e73250005d9607e065292d14316ff57e81..8972e0101bb1db934d65110417227ab3d9bb9617 100644 |
| --- a/ui/views/view.cc |
| +++ b/ui/views/view.cc |
| @@ -20,6 +20,7 @@ |
| #include "ui/base/cursor/cursor.h" |
| #include "ui/base/dragdrop/drag_drop_types.h" |
| #include "ui/compositor/compositor.h" |
| +#include "ui/compositor/dip_util.h" |
| #include "ui/compositor/layer.h" |
| #include "ui/compositor/layer_animator.h" |
| #include "ui/events/event_target_iterator.h" |
| @@ -112,6 +113,7 @@ View::View() |
| root_bounds_dirty_(true), |
| clip_insets_(0, 0, 0, 0), |
| needs_layout_(true), |
| + snap_layer_to_pixel_boundary_(false), |
| flip_canvas_on_paint_for_rtl_ui_(false), |
| paint_to_layer_(false), |
| accelerator_focus_manager_(NULL), |
| @@ -572,6 +574,19 @@ void View::SetLayoutManager(LayoutManager* layout_manager) { |
| layout_manager_->Installed(this); |
| } |
| +void View::SnapLayerToPixelBoundary() { |
|
Ben Goodger (Google)
2014/07/08 16:07:34
should this be implemented in Layer?
oshima
2014/07/08 17:39:18
Layer currently does not know which layers are ali
|
| + if (!layer()) |
| + return; |
| + |
| + if (snap_layer_to_pixel_boundary_ && |
| + layer()->parent() && layer()->GetCompositor()) { |
|
danakj
2014/07/15 21:11:02
why the check for GetCompositor?
oshima
2014/07/15 22:28:42
Because view can exist without parent nor widget.
|
| + ui::SnapLayerToPhysicalPixelBoundary(layer()->parent(), layer()); |
| + } else { |
| + // Reset the offset. |
| + layer()->SetSubpixelPositionOffset(gfx::Vector2dF()); |
| + } |
| +} |
| + |
| // Attributes ------------------------------------------------------------------ |
| const char* View::GetClassName() const { |
| @@ -1542,6 +1557,9 @@ void View::OnPaintLayer(gfx::Canvas* canvas) { |
| } |
| void View::OnDeviceScaleFactorChanged(float device_scale_factor) { |
| + snap_layer_to_pixel_boundary_ = |
|
danakj
2014/07/15 21:11:02
Didn't you want this to be false for some layers l
oshima
2014/07/15 22:28:42
Yes, it'll be handled in a separate CL for ash. (s
|
| + (device_scale_factor - std::floor(device_scale_factor)) != 0.0f; |
| + SnapLayerToPixelBoundary(); |
| // Repainting with new scale factor will paint the content at the right scale. |
| } |
| @@ -2071,6 +2089,7 @@ void View::RemoveDescendantToNotify(View* view) { |
| void View::SetLayerBounds(const gfx::Rect& bounds) { |
| layer()->SetBounds(bounds); |
| + SnapLayerToPixelBoundary(); |
| } |
| void View::SetRootBoundsDirty(bool origin_changed) { |