diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-10 12:32:35 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-10 12:32:35 +0000 |
commit | ea291015e6f06b914ef19a09409746bb2af5cd7e (patch) | |
tree | 2c58518491e8697020685598088a0da8dfe9e024 | |
parent | 03d89351263776a55332e0e0280b5a4d485040b9 (diff) | |
download | chromium_src-ea291015e6f06b914ef19a09409746bb2af5cd7e.zip chromium_src-ea291015e6f06b914ef19a09409746bb2af5cd7e.tar.gz chromium_src-ea291015e6f06b914ef19a09409746bb2af5cd7e.tar.bz2 |
Move SnapToPhysicalPixelBoundary call to RWHVA::InternalSetBounds
RWHVAura::SetBounds isn't actually called in most situations, so the snapping
wasn't occuring when it should. ::SetSize is actually called when the bounds
of the RWHVA changes and both call ::InternalSetBounds(), so this calls the
snapping logic there.
BUG=370074
Review URL: https://codereview.chromium.org/317633006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275994 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 6 | ||||
-rw-r--r-- | ui/compositor/layer.cc | 7 | ||||
-rw-r--r-- | ui/compositor/layer.h | 5 |
3 files changed, 13 insertions, 5 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 6bec9f2..8f2cd85 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -623,7 +623,6 @@ void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { } } - SnapToPhysicalPixelBoundary(); InternalSetBounds(gfx::Rect(relative_origin, rect.size())); } @@ -987,15 +986,14 @@ void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { gfx::Vector2dF fudge = view_offset_snapped - view_offset; fudge.Scale(1.0 / current_device_scale_factor_); - gfx::Transform fudge_transform; - fudge_transform.Translate(fudge.x(), fudge.y()); - GetLayer()->cc_layer()->SetTransform(fudge_transform); + GetLayer()->SetSubpixelPositionOffset(fudge); } void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { if (HasDisplayPropertyChanged(window_)) host_->InvalidateScreenInfo(); + SnapToPhysicalPixelBoundary(); // Don't recursively call SetBounds if this bounds update is the result of // a Window::SetBoundsInternal call. if (!in_bounds_changed_) diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc index 17ab899..150e1ef 100644 --- a/ui/compositor/layer.cc +++ b/ui/compositor/layer.cc @@ -243,6 +243,11 @@ void Layer::SetBounds(const gfx::Rect& bounds) { GetAnimator()->SetBounds(bounds); } +void Layer::SetSubpixelPositionOffset(const gfx::Vector2dF offset) { + subpixel_position_offset_ = offset; + RecomputePosition(); +} + gfx::Rect Layer::GetTargetBounds() const { if (animator_.get() && animator_->IsAnimatingProperty( LayerAnimationElement::BOUNDS)) { @@ -959,7 +964,7 @@ void Layer::RecomputeDrawsContentAndUVRect() { } void Layer::RecomputePosition() { - cc_layer_->SetPosition(gfx::PointF(bounds_.x(), bounds_.y())); + cc_layer_->SetPosition(bounds_.origin() + subpixel_position_offset_); } void Layer::AddAnimatorsInTreeToCollection( diff --git a/ui/compositor/layer.h b/ui/compositor/layer.h index 069f167..03041ed 100644 --- a/ui/compositor/layer.h +++ b/ui/compositor/layer.h @@ -139,6 +139,10 @@ class COMPOSITOR_EXPORT Layer void SetBounds(const gfx::Rect& bounds); const gfx::Rect& bounds() const { return bounds_; } + // The offset from our parent (stored in bounds.origin()) is an integer but we + // may need to be at a fractional pixel offset to align properly on screen. + void SetSubpixelPositionOffset(const gfx::Vector2dF offset); + // Return the target bounds if animator is running, or the current bounds // otherwise. gfx::Rect GetTargetBounds() const; @@ -410,6 +414,7 @@ class COMPOSITOR_EXPORT Layer std::vector<Layer*> children_; gfx::Rect bounds_; + gfx::Vector2dF subpixel_position_offset_; // Visibility of this layer. See SetVisible/IsDrawn for more details. bool visible_; |