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

Unified Diff: ui/compositor/layer.cc

Issue 2648583003: Handle floating point coordinates from ozone to exosphere (Closed)
Patch Set: Handle floating point coordinates from ozone to exosphere 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 side-by-side diff with in-line comments
Download patch
Index: ui/compositor/layer.cc
diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc
index 7d9c07b32e4f20ca9d93f3ec46617f1606449cb6..31149a880721044c885f7daedd57f4cb27150c3d 100644
--- a/ui/compositor/layer.cc
+++ b/ui/compositor/layer.cc
@@ -533,6 +533,21 @@ void Layer::ConvertPointToLayer(const Layer* source,
target->ConvertPointFromAncestor(root_layer, point);
}
+// static
+void Layer::ConvertPointToLayerF(const Layer* source,
+ const Layer* target,
+ gfx::PointF* point) {
+ if (source == target)
+ return;
+
+ const Layer* root_layer = GetRoot(source);
+ CHECK_EQ(root_layer, GetRoot(target));
+
+ if (source != root_layer)
+ source->ConvertPointForAncestorF(root_layer, point);
+ if (target != root_layer)
+ target->ConvertPointFromAncestorF(root_layer, point);
+}
bool Layer::GetTargetTransformRelativeTo(const Layer* ancestor,
gfx::Transform* transform) const {
const Layer* p = this;
@@ -956,21 +971,37 @@ void Layer::StackRelativeTo(Layer* child, Layer* other, bool above) {
bool Layer::ConvertPointForAncestor(const Layer* ancestor,
gfx::Point* point) const {
+ gfx::PointF point_f(*point);
+ bool result = ConvertPointForAncestorF(ancestor, &point_f);
+ *point = gfx::ToFlooredPoint(point_f);
+ return result;
+}
+
+bool Layer::ConvertPointFromAncestor(const Layer* ancestor,
+ gfx::Point* point) const {
+ gfx::PointF point_f(*point);
+ bool result = ConvertPointFromAncestorF(ancestor, &point_f);
+ *point = gfx::ToFlooredPoint(point_f);
+ return result;
+}
+
+bool Layer::ConvertPointForAncestorF(const Layer* ancestor,
+ gfx::PointF* point) const {
gfx::Transform transform;
bool result = GetTargetTransformRelativeTo(ancestor, &transform);
- auto p = gfx::Point3F(gfx::PointF(*point));
+ auto p = gfx::Point3F(*point);
transform.TransformPoint(&p);
- *point = gfx::ToFlooredPoint(p.AsPointF());
+ *point = p.AsPointF();
return result;
}
-bool Layer::ConvertPointFromAncestor(const Layer* ancestor,
- gfx::Point* point) const {
+bool Layer::ConvertPointFromAncestorF(const Layer* ancestor,
+ gfx::PointF* point) const {
gfx::Transform transform;
bool result = GetTargetTransformRelativeTo(ancestor, &transform);
- auto p = gfx::Point3F(gfx::PointF(*point));
+ auto p = gfx::Point3F(*point);
transform.TransformPointReverse(&p);
- *point = gfx::ToFlooredPoint(p.AsPointF());
+ *point = p.AsPointF();
return result;
}
« ui/aura/window.cc ('K') | « ui/compositor/layer.h ('k') | ui/events/event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698