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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 gfx::Point3F p(*point); | 594 gfx::Point3F p(*point); |
595 transform.TransformPointReverse(p); | 595 transform.TransformPointReverse(p); |
596 *point = gfx::ToFlooredPoint(p.AsPointF()); | 596 *point = gfx::ToFlooredPoint(p.AsPointF()); |
597 return result; | 597 return result; |
598 } | 598 } |
599 | 599 |
600 bool Layer::GetTransformRelativeTo(const Layer* ancestor, | 600 bool Layer::GetTransformRelativeTo(const Layer* ancestor, |
601 gfx::Transform* transform) const { | 601 gfx::Transform* transform) const { |
602 const Layer* p = this; | 602 const Layer* p = this; |
603 for (; p && p != ancestor; p = p->parent()) { | 603 for (; p && p != ancestor; p = p->parent()) { |
| 604 gfx::Transform translation; |
| 605 translation.Translate(static_cast<float>(p->bounds().x()), |
| 606 static_cast<float>(p->bounds().y())); |
604 if (!p->transform().IsIdentity()) | 607 if (!p->transform().IsIdentity()) |
605 transform->ConcatTransform(p->transform()); | 608 transform->ConcatTransform(p->transform()); |
606 transform->ConcatTranslate(static_cast<float>(p->bounds().x()), | 609 transform->ConcatTransform(translation); |
607 static_cast<float>(p->bounds().y())); | |
608 } | 610 } |
609 return p == ancestor; | 611 return p == ancestor; |
610 } | 612 } |
611 | 613 |
612 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { | 614 void Layer::SetBoundsImmediately(const gfx::Rect& bounds) { |
613 if (bounds == bounds_) | 615 if (bounds == bounds_) |
614 return; | 616 return; |
615 | 617 |
616 base::Closure closure; | 618 base::Closure closure; |
617 if (delegate_) | 619 if (delegate_) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 gfx::Transform scale_translate; | 761 gfx::Transform scale_translate; |
760 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, | 762 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, |
761 0, device_scale_factor_, 0, | 763 0, device_scale_factor_, 0, |
762 0, 0, 1); | 764 0, 0, 1); |
763 // Start with the inverse matrix of above. | 765 // Start with the inverse matrix of above. |
764 gfx::Transform transform; | 766 gfx::Transform transform; |
765 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, | 767 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, |
766 0, 1.0f / device_scale_factor_, 0, | 768 0, 1.0f / device_scale_factor_, 0, |
767 0, 0, 1); | 769 0, 0, 1); |
768 transform.ConcatTransform(transform_); | 770 transform.ConcatTransform(transform_); |
769 transform.ConcatTranslate(bounds_.x(), bounds_.y()); | 771 gfx::Transform translate; |
| 772 translate.Translate(bounds_.x(), bounds_.y()); |
| 773 transform.ConcatTransform(translate); |
770 transform.ConcatTransform(scale_translate); | 774 transform.ConcatTransform(scale_translate); |
771 cc_layer_->setTransform(WebKit::WebTransformationMatrix(transform)); | 775 cc_layer_->setTransform(WebKit::WebTransformationMatrix(transform)); |
772 } | 776 } |
773 | 777 |
774 void Layer::RecomputeDrawsContentAndUVRect() { | 778 void Layer::RecomputeDrawsContentAndUVRect() { |
775 DCHECK(cc_layer_); | 779 DCHECK(cc_layer_); |
776 if (!cc_layer_is_accelerated_) { | 780 if (!cc_layer_is_accelerated_) { |
777 cc_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); | 781 cc_layer_->setBounds(ConvertSizeToPixel(this, bounds_.size())); |
778 } else { | 782 } else { |
779 DCHECK(texture_); | 783 DCHECK(texture_); |
780 | 784 |
781 float texture_scale_factor = 1.0f / texture_->device_scale_factor(); | 785 float texture_scale_factor = 1.0f / texture_->device_scale_factor(); |
782 gfx::Size texture_size = gfx::ToFlooredSize( | 786 gfx::Size texture_size = gfx::ToFlooredSize( |
783 gfx::ScaleSize(texture_->size(), texture_scale_factor)); | 787 gfx::ScaleSize(texture_->size(), texture_scale_factor)); |
784 | 788 |
785 gfx::Size size(std::min(bounds().width(), texture_size.width()), | 789 gfx::Size size(std::min(bounds().width(), texture_size.width()), |
786 std::min(bounds().height(), texture_size.height())); | 790 std::min(bounds().height(), texture_size.height())); |
787 gfx::RectF rect( | 791 gfx::RectF rect( |
788 0, | 792 0, |
789 0, | 793 0, |
790 static_cast<float>(size.width())/texture_size.width(), | 794 static_cast<float>(size.width())/texture_size.width(), |
791 static_cast<float>(size.height())/texture_size.height()); | 795 static_cast<float>(size.height())/texture_size.height()); |
792 texture_layer_->setUVRect(rect); | 796 texture_layer_->setUVRect(rect); |
793 | 797 |
794 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); | 798 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); |
795 } | 799 } |
796 } | 800 } |
797 | 801 |
798 } // namespace ui | 802 } // namespace ui |
OLD | NEW |