Commit ea291015 authored by jamesr@chromium.org's avatar jamesr@chromium.org

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
parent 03d89351
...@@ -623,7 +623,6 @@ void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) { ...@@ -623,7 +623,6 @@ void RenderWidgetHostViewAura::SetBounds(const gfx::Rect& rect) {
} }
} }
SnapToPhysicalPixelBoundary();
InternalSetBounds(gfx::Rect(relative_origin, rect.size())); InternalSetBounds(gfx::Rect(relative_origin, rect.size()));
} }
...@@ -987,15 +986,14 @@ void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { ...@@ -987,15 +986,14 @@ void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() {
gfx::Vector2dF fudge = view_offset_snapped - view_offset; gfx::Vector2dF fudge = view_offset_snapped - view_offset;
fudge.Scale(1.0 / current_device_scale_factor_); fudge.Scale(1.0 / current_device_scale_factor_);
gfx::Transform fudge_transform; GetLayer()->SetSubpixelPositionOffset(fudge);
fudge_transform.Translate(fudge.x(), fudge.y());
GetLayer()->cc_layer()->SetTransform(fudge_transform);
} }
void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
if (HasDisplayPropertyChanged(window_)) if (HasDisplayPropertyChanged(window_))
host_->InvalidateScreenInfo(); host_->InvalidateScreenInfo();
SnapToPhysicalPixelBoundary();
// Don't recursively call SetBounds if this bounds update is the result of // Don't recursively call SetBounds if this bounds update is the result of
// a Window::SetBoundsInternal call. // a Window::SetBoundsInternal call.
if (!in_bounds_changed_) if (!in_bounds_changed_)
......
...@@ -243,6 +243,11 @@ void Layer::SetBounds(const gfx::Rect& bounds) { ...@@ -243,6 +243,11 @@ void Layer::SetBounds(const gfx::Rect& bounds) {
GetAnimator()->SetBounds(bounds); GetAnimator()->SetBounds(bounds);
} }
void Layer::SetSubpixelPositionOffset(const gfx::Vector2dF offset) {
subpixel_position_offset_ = offset;
RecomputePosition();
}
gfx::Rect Layer::GetTargetBounds() const { gfx::Rect Layer::GetTargetBounds() const {
if (animator_.get() && animator_->IsAnimatingProperty( if (animator_.get() && animator_->IsAnimatingProperty(
LayerAnimationElement::BOUNDS)) { LayerAnimationElement::BOUNDS)) {
...@@ -959,7 +964,7 @@ void Layer::RecomputeDrawsContentAndUVRect() { ...@@ -959,7 +964,7 @@ void Layer::RecomputeDrawsContentAndUVRect() {
} }
void Layer::RecomputePosition() { void Layer::RecomputePosition() {
cc_layer_->SetPosition(gfx::PointF(bounds_.x(), bounds_.y())); cc_layer_->SetPosition(bounds_.origin() + subpixel_position_offset_);
} }
void Layer::AddAnimatorsInTreeToCollection( void Layer::AddAnimatorsInTreeToCollection(
......
...@@ -139,6 +139,10 @@ class COMPOSITOR_EXPORT Layer ...@@ -139,6 +139,10 @@ class COMPOSITOR_EXPORT Layer
void SetBounds(const gfx::Rect& bounds); void SetBounds(const gfx::Rect& bounds);
const gfx::Rect& bounds() const { return 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 // Return the target bounds if animator is running, or the current bounds
// otherwise. // otherwise.
gfx::Rect GetTargetBounds() const; gfx::Rect GetTargetBounds() const;
...@@ -410,6 +414,7 @@ class COMPOSITOR_EXPORT Layer ...@@ -410,6 +414,7 @@ class COMPOSITOR_EXPORT Layer
std::vector<Layer*> children_; std::vector<Layer*> children_;
gfx::Rect bounds_; gfx::Rect bounds_;
gfx::Vector2dF subpixel_position_offset_;
// Visibility of this layer. See SetVisible/IsDrawn for more details. // Visibility of this layer. See SetVisible/IsDrawn for more details.
bool visible_; bool visible_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment