OLD | NEW |
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 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 gfx::Point3F p(*point); | 608 gfx::Point3F p(*point); |
609 transform.TransformPointReverse(p); | 609 transform.TransformPointReverse(p); |
610 *point = gfx::ToFlooredPoint(p.AsPointF()); | 610 *point = gfx::ToFlooredPoint(p.AsPointF()); |
611 return result; | 611 return result; |
612 } | 612 } |
613 | 613 |
614 bool Layer::GetTransformRelativeTo(const Layer* ancestor, | 614 bool Layer::GetTransformRelativeTo(const Layer* ancestor, |
615 gfx::Transform* transform) const { | 615 gfx::Transform* transform) const { |
616 const Layer* p = this; | 616 const Layer* p = this; |
617 for (; p && p != ancestor; p = p->parent()) { | 617 for (; p && p != ancestor; p = p->parent()) { |
| 618 gfx::Transform translation; |
| 619 translation.Translate(static_cast<float>(p->bounds().x()), |
| 620 static_cast<float>(p->bounds().y())); |
618 if (p->transform().HasChange()) | 621 if (p->transform().HasChange()) |
619 transform->ConcatTransform(p->transform()); | 622 *transform = translation * p->transform() * *transform; |
620 transform->ConcatTranslate(static_cast<float>(p->bounds().x()), | 623 else |
621 static_cast<float>(p->bounds().y())); | 624 *transform = translation * *transform; |
622 } | 625 } |
623 return p == ancestor; | 626 return p == ancestor; |
624 } | 627 } |
625 | 628 |
626 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { | 629 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { |
627 if (bounds == bounds_) | 630 if (bounds == bounds_) |
628 return; | 631 return; |
629 | 632 |
630 base::Closure closure; | 633 base::Closure closure; |
631 if (delegate_) | 634 if (delegate_) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
774 gfx::Transform scale_translate; | 777 gfx::Transform scale_translate; |
775 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, | 778 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, |
776 0, device_scale_factor_, 0, | 779 0, device_scale_factor_, 0, |
777 0, 0, 1); | 780 0, 0, 1); |
778 // Start with the inverse matrix of above. | 781 // Start with the inverse matrix of above. |
779 gfx::Transform transform; | 782 gfx::Transform transform; |
780 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, | 783 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, |
781 0, 1.0f / device_scale_factor_, 0, | 784 0, 1.0f / device_scale_factor_, 0, |
782 0, 0, 1); | 785 0, 0, 1); |
783 transform.ConcatTransform(transform_); | 786 transform.ConcatTransform(transform_); |
784 transform.ConcatTranslate(bounds_.x(), bounds_.y()); | 787 gfx::Transform translate; |
| 788 translate.Translate(bounds_.x(), bounds_.y()); |
| 789 transform.ConcatTransform(translate); |
785 transform.ConcatTransform(scale_translate); | 790 transform.ConcatTransform(scale_translate); |
786 web_layer_->setTransform(transform.matrix()); | 791 web_layer_->setTransform(transform.matrix()); |
787 } | 792 } |
788 | 793 |
789 void Layer::RecomputeDrawsContentAndUVRect() { | 794 void Layer::RecomputeDrawsContentAndUVRect() { |
790 DCHECK(web_layer_); | 795 DCHECK(web_layer_); |
791 bool should_draw = type_ != LAYER_NOT_DRAWN; | 796 bool should_draw = type_ != LAYER_NOT_DRAWN; |
792 if (!web_layer_is_accelerated_) { | 797 if (!web_layer_is_accelerated_) { |
793 if (type_ != LAYER_SOLID_COLOR) { | 798 if (type_ != LAYER_SOLID_COLOR) { |
794 web_layer_->setDrawsContent(should_draw); | 799 web_layer_->setDrawsContent(should_draw); |
(...skipping 14 matching lines...) Expand all Loading... |
809 static_cast<float>(size.width())/texture_size.width(), | 814 static_cast<float>(size.width())/texture_size.width(), |
810 static_cast<float>(size.height())/texture_size.height()); | 815 static_cast<float>(size.height())/texture_size.height()); |
811 texture_layer_->setUVRect(rect); | 816 texture_layer_->setUVRect(rect); |
812 | 817 |
813 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); | 818 gfx::Size size_in_pixel = ConvertSizeToPixel(this, size); |
814 web_layer_->setBounds(size_in_pixel); | 819 web_layer_->setBounds(size_in_pixel); |
815 } | 820 } |
816 } | 821 } |
817 | 822 |
818 } // namespace ui | 823 } // namespace ui |
OLD | NEW |