Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1102)

Side by Side Diff: ui/compositor/layer.cc

Issue 2648583003: Handle floating point coordinates from ozone to exosphere (Closed)
Patch Set: added F variant to screen position client. fixed exo tests. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/compositor/layer.h" 5 #include "ui/compositor/layer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 const Layer* root_layer = GetRoot(source); 527 const Layer* root_layer = GetRoot(source);
528 CHECK_EQ(root_layer, GetRoot(target)); 528 CHECK_EQ(root_layer, GetRoot(target));
529 529
530 if (source != root_layer) 530 if (source != root_layer)
531 source->ConvertPointForAncestor(root_layer, point); 531 source->ConvertPointForAncestor(root_layer, point);
532 if (target != root_layer) 532 if (target != root_layer)
533 target->ConvertPointFromAncestor(root_layer, point); 533 target->ConvertPointFromAncestor(root_layer, point);
534 } 534 }
535 535
536 // static
537 void Layer::ConvertPointToLayerF(const Layer* source,
538 const Layer* target,
539 gfx::PointF* point) {
540 if (source == target)
541 return;
542
543 const Layer* root_layer = GetRoot(source);
544 CHECK_EQ(root_layer, GetRoot(target));
545
546 if (source != root_layer)
547 source->ConvertPointForAncestorF(root_layer, point);
548 if (target != root_layer)
549 target->ConvertPointFromAncestorF(root_layer, point);
550 }
oshima 2017/01/20 22:11:55 new line
536 bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor, 551 bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor,
537 gfx::Transform* transform) const { 552 gfx::Transform* transform) const {
538 const Layer* p = this; 553 const Layer* p = this;
539 for (; p && p != ancestor; p = p->parent()) { 554 for (; p && p != ancestor; p = p->parent()) {
540 gfx::Transform translation; 555 gfx::Transform translation;
541 translation.Translate(static_cast<float>(p->bounds().x()), 556 translation.Translate(static_cast<float>(p->bounds().x()),
542 static_cast<float>(p->bounds().y())); 557 static_cast<float>(p->bounds().y()));
543 // Use target transform so that result will be correct once animation is 558 // Use target transform so that result will be correct once animation is
544 // finished. 559 // finished.
545 if (!p->GetTargetTransform().IsIdentity()) 560 if (!p->GetTargetTransform().IsIdentity())
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 964
950 children_.erase(children_.begin() + child_i); 965 children_.erase(children_.begin() + child_i);
951 children_.insert(children_.begin() + dest_i, child); 966 children_.insert(children_.begin() + dest_i, child);
952 967
953 child->cc_layer_->RemoveFromParent(); 968 child->cc_layer_->RemoveFromParent();
954 cc_layer_->InsertChild(child->cc_layer_, dest_i); 969 cc_layer_->InsertChild(child->cc_layer_, dest_i);
955 } 970 }
956 971
957 bool Layer::ConvertPointForAncestor(const Layer* ancestor, 972 bool Layer::ConvertPointForAncestor(const Layer* ancestor,
958 gfx::Point* point) const { 973 gfx::Point* point) const {
959 gfx::Transform transform; 974 gfx::PointF point_f(*point);
960 bool result = GetTargetTransformRelativeTo(ancestor, &transform); 975 bool result = ConvertPointForAncestorF(ancestor, &point_f);
961 auto p = gfx::Point3F(gfx::PointF(*point)); 976 *point = gfx::ToFlooredPoint(point_f);
962 transform.TransformPoint(&p);
963 *point = gfx::ToFlooredPoint(p.AsPointF());
964 return result; 977 return result;
965 } 978 }
966 979
967 bool Layer::ConvertPointFromAncestor(const Layer* ancestor, 980 bool Layer::ConvertPointFromAncestor(const Layer* ancestor,
968 gfx::Point* point) const { 981 gfx::Point* point) const {
969 gfx::Transform transform; 982 gfx::PointF point_f(*point);
970 bool result = GetTargetTransformRelativeTo(ancestor, &transform); 983 bool result = ConvertPointFromAncestorF(ancestor, &point_f);
971 auto p = gfx::Point3F(gfx::PointF(*point)); 984 *point = gfx::ToFlooredPoint(point_f);
972 transform.TransformPointReverse(&p);
973 *point = gfx::ToFlooredPoint(p.AsPointF());
974 return result; 985 return result;
975 } 986 }
976 987
988 bool Layer::ConvertPointForAncestorF(const Layer* ancestor,
989 gfx::PointF* point) const {
990 gfx::Transform transform;
991 bool result = GetTargetTransformRelativeTo(ancestor, &transform);
992 auto p = gfx::Point3F(*point);
993 transform.TransformPoint(&p);
994 *point = p.AsPointF();
995 return result;
996 }
997
998 bool Layer::ConvertPointFromAncestorF(const Layer* ancestor,
999 gfx::PointF* point) const {
1000 gfx::Transform transform;
1001 bool result = GetTargetTransformRelativeTo(ancestor, &transform);
1002 auto p = gfx::Point3F(*point);
1003 transform.TransformPointReverse(&p);
1004 *point = p.AsPointF();
1005 return result;
1006 }
1007
977 void Layer::SetBoundsFromAnimation(const gfx::Rect& bounds) { 1008 void Layer::SetBoundsFromAnimation(const gfx::Rect& bounds) {
978 if (bounds == bounds_) 1009 if (bounds == bounds_)
979 return; 1010 return;
980 1011
981 base::Closure closure; 1012 base::Closure closure;
982 const gfx::Rect old_bounds = bounds_; 1013 const gfx::Rect old_bounds = bounds_;
983 bounds_ = bounds; 1014 bounds_ = bounds;
984 1015
985 RecomputeDrawsContentAndUVRect(); 1016 RecomputeDrawsContentAndUVRect();
986 RecomputePosition(); 1017 RecomputePosition();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(), 1197 const auto it = std::find_if(mirrors_.begin(), mirrors_.end(),
1167 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) { 1198 [mirror](const std::unique_ptr<LayerMirror>& mirror_ptr) {
1168 return mirror_ptr.get() == mirror; 1199 return mirror_ptr.get() == mirror;
1169 }); 1200 });
1170 1201
1171 DCHECK(it != mirrors_.end()); 1202 DCHECK(it != mirrors_.end());
1172 mirrors_.erase(it); 1203 mirrors_.erase(it);
1173 } 1204 }
1174 1205
1175 } // namespace ui 1206 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698