Commit b9cff569 authored by ajuma@chromium.org's avatar ajuma@chromium.org

Merge ui::Layer's concept of position with cc::Layer's

This makes ui::Layer use cc::Layer::SetPosition for setting
its position, instead of baking its position into the
transform that's set on the cc::Layer. This means that a
change to a ui::Layer's bounds no longer affects the
transform set on the cc::Layer, and hence bounds animations
no longer conflict with threaded transform animations.

BUG=170219,226326


Review URL: https://chromiumcodereview.appspot.com/13725015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192659 0039d316-1c4b-4281-b951-d872f2087c98
parent 6aa13e28
......@@ -425,11 +425,9 @@ bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor,
// static
gfx::Transform Layer::ConvertTransformToCCTransform(
const gfx::Transform& transform,
const gfx::Rect& bounds,
float device_scale_factor) {
gfx::Transform cc_transform;
cc_transform.Scale(device_scale_factor, device_scale_factor);
cc_transform.Translate(bounds.x(), bounds.y());
cc_transform.PreconcatTransform(transform);
cc_transform.Scale(1.0f / device_scale_factor, 1.0f / device_scale_factor);
return cc_transform;
......@@ -463,6 +461,7 @@ void Layer::SwitchToLayer(scoped_refptr<cc::Layer> new_layer) {
cc_layer_->RemoveLayerAnimationEventObserver(this);
new_layer->SetOpacity(cc_layer_->opacity());
new_layer->SetTransform(cc_layer_->transform());
new_layer->SetPosition(cc_layer_->position());
cc_layer_= new_layer;
content_layer_ = NULL;
......@@ -601,6 +600,7 @@ void Layer::OnDeviceScaleFactorChanged(float device_scale_factor) {
device_scale_factor_ = device_scale_factor;
RecomputeCCTransformFromTransform(transform);
RecomputeDrawsContentAndUVRect();
RecomputePosition();
SchedulePaint(gfx::Rect(bounds_.size()));
if (delegate_)
delegate_->OnDeviceScaleFactorChanged(device_scale_factor);
......@@ -704,11 +704,11 @@ void Layer::SetBoundsImmediately(const gfx::Rect& bounds) {
if (delegate_)
closure = delegate_->PrepareForLayerBoundsChange();
bool was_move = bounds_.size() == bounds.size();
gfx::Transform transform = this->transform();
bounds_ = bounds;
RecomputeCCTransformFromTransform(transform);
RecomputeDrawsContentAndUVRect();
RecomputePosition();
if (!closure.is_null())
closure.Run();
......@@ -891,17 +891,16 @@ void Layer::CreateWebLayer() {
cc_layer_->SetContentsOpaque(true);
cc_layer_->SetIsDrawable(type_ != LAYER_NOT_DRAWN);
cc_layer_->AddLayerAnimationEventObserver(this);
RecomputePosition();
}
void Layer::RecomputeCCTransformFromTransform(const gfx::Transform& transform) {
cc_layer_->SetTransform(ConvertTransformToCCTransform(transform,
bounds_,
device_scale_factor_));
}
gfx::Transform Layer::transform() const {
gfx::Transform transform;
transform.Translate(-bounds_.x(), -bounds_.y());
transform.Scale(1.0f / device_scale_factor_, 1.0f / device_scale_factor_);
transform.PreconcatTransform(cc_layer_->transform());
transform.Scale(device_scale_factor_, device_scale_factor_);
......@@ -932,4 +931,10 @@ void Layer::RecomputeDrawsContentAndUVRect() {
cc_layer_->SetBounds(ConvertSizeToPixel(this, size));
}
void Layer::RecomputePosition() {
cc_layer_->SetPosition(gfx::ScalePoint(
gfx::PointF(bounds_.x(), bounds_.y()),
device_scale_factor_));
}
} // namespace ui
......@@ -234,7 +234,6 @@ class COMPOSITOR_EXPORT Layer
// cc::Layer.
static gfx::Transform ConvertTransformToCCTransform(
const gfx::Transform& transform,
const gfx::Rect& bounds,
float device_scale_factor);
// See description in View for details
......@@ -369,6 +368,7 @@ class COMPOSITOR_EXPORT Layer
void CreateWebLayer();
void RecomputeCCTransformFromTransform(const gfx::Transform& transform);
void RecomputeDrawsContentAndUVRect();
void RecomputePosition();
// Set all filters which got applied to the layer.
void SetLayerFilters();
......
......@@ -509,13 +509,10 @@ class ThreadedTransformTransition : public ThreadedLayerAnimationElement {
protected:
virtual void OnStart(LayerAnimationDelegate* delegate) OVERRIDE {
start_ = delegate->GetTransformForAnimation();
gfx::Rect bounds = delegate->GetBoundsForAnimation();
float device_scale_factor = delegate->GetDeviceScaleFactor();
cc_start_ = Layer::ConvertTransformToCCTransform(start_,
bounds,
device_scale_factor);
cc_target_ = Layer::ConvertTransformToCCTransform(target_,
bounds,
device_scale_factor);
}
......
......@@ -183,18 +183,7 @@ bool LayerAnimationSequence::HasConflictingProperty(
std::set_intersection(properties_.begin(), properties_.end(),
other.begin(), other.end(),
ii);
if (intersection.size() > 0)
return true;
if (properties_.find(LayerAnimationElement::TRANSFORM) != properties_.end() &&
other.find(LayerAnimationElement::BOUNDS) != other.end())
return true;
if (properties_.find(LayerAnimationElement::BOUNDS) != properties_.end() &&
other.find(LayerAnimationElement::TRANSFORM) != other.end())
return true;
return false;
return (intersection.size() > 0);
}
bool LayerAnimationSequence::IsFirstElementThreaded() const {
......
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