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

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

Issue 11087093: Migrate ui::Transform to gfx::Transform (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 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 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 animator->SetDelegate(this); 179 animator->SetDelegate(this);
180 animator_ = animator; 180 animator_ = animator;
181 } 181 }
182 182
183 LayerAnimator* Layer::GetAnimator() { 183 LayerAnimator* Layer::GetAnimator() {
184 if (!animator_.get()) 184 if (!animator_.get())
185 SetAnimator(LayerAnimator::CreateDefaultAnimator()); 185 SetAnimator(LayerAnimator::CreateDefaultAnimator());
186 return animator_.get(); 186 return animator_.get();
187 } 187 }
188 188
189 void Layer::SetTransform(const ui::Transform& transform) { 189 void Layer::SetTransform(const gfx::Transform& transform) {
190 GetAnimator()->SetTransform(transform); 190 GetAnimator()->SetTransform(transform);
191 } 191 }
192 192
193 Transform Layer::GetTargetTransform() const { 193 Transform Layer::GetTargetTransform() const {
194 if (animator_.get() && animator_->IsAnimatingProperty( 194 if (animator_.get() && animator_->IsAnimatingProperty(
195 LayerAnimationElement::TRANSFORM)) { 195 LayerAnimationElement::TRANSFORM)) {
196 return animator_->GetTargetTransform(); 196 return animator_->GetTargetTransform();
197 } 197 }
198 return transform_; 198 return transform_;
199 } 199 }
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 (child_i < other_i ? other_i - 1 : other_i); 556 (child_i < other_i ? other_i - 1 : other_i);
557 children_.erase(children_.begin() + child_i); 557 children_.erase(children_.begin() + child_i);
558 children_.insert(children_.begin() + dest_i, child); 558 children_.insert(children_.begin() + dest_i, child);
559 559
560 child->web_layer_->removeFromParent(); 560 child->web_layer_->removeFromParent();
561 web_layer_->insertChild(child->web_layer_, dest_i); 561 web_layer_->insertChild(child->web_layer_, dest_i);
562 } 562 }
563 563
564 bool Layer::ConvertPointForAncestor(const Layer* ancestor, 564 bool Layer::ConvertPointForAncestor(const Layer* ancestor,
565 gfx::Point* point) const { 565 gfx::Point* point) const {
566 ui::Transform transform; 566 gfx::Transform transform;
567 bool result = GetTransformRelativeTo(ancestor, &transform); 567 bool result = GetTransformRelativeTo(ancestor, &transform);
568 gfx::Point3f p(*point); 568 gfx::Point3f p(*point);
569 transform.TransformPoint(p); 569 transform.TransformPoint(p);
570 *point = p.AsPoint(); 570 *point = p.AsPoint();
571 return result; 571 return result;
572 } 572 }
573 573
574 bool Layer::ConvertPointFromAncestor(const Layer* ancestor, 574 bool Layer::ConvertPointFromAncestor(const Layer* ancestor,
575 gfx::Point* point) const { 575 gfx::Point* point) const {
576 ui::Transform transform; 576 gfx::Transform transform;
577 bool result = GetTransformRelativeTo(ancestor, &transform); 577 bool result = GetTransformRelativeTo(ancestor, &transform);
578 gfx::Point3f p(*point); 578 gfx::Point3f p(*point);
579 transform.TransformPointReverse(p); 579 transform.TransformPointReverse(p);
580 *point = p.AsPoint(); 580 *point = p.AsPoint();
581 return result; 581 return result;
582 } 582 }
583 583
584 bool Layer::GetTransformRelativeTo(const Layer* ancestor, 584 bool Layer::GetTransformRelativeTo(const Layer* ancestor,
585 ui::Transform* transform) const { 585 gfx::Transform* transform) const {
586 const Layer* p = this; 586 const Layer* p = this;
587 for (; p && p != ancestor; p = p->parent()) { 587 for (; p && p != ancestor; p = p->parent()) {
588 if (p->transform().HasChange()) 588 if (p->transform().HasChange())
589 transform->ConcatTransform(p->transform()); 589 transform->ConcatTransform(p->transform());
590 transform->ConcatTranslate(static_cast<float>(p->bounds().x()), 590 transform->ConcatTranslate(static_cast<float>(p->bounds().x()),
591 static_cast<float>(p->bounds().y())); 591 static_cast<float>(p->bounds().y()));
592 } 592 }
593 return p == ancestor; 593 return p == ancestor;
594 } 594 }
595 595
(...skipping 16 matching lines...) Expand all
612 // Don't schedule a draw if we're invisible. We'll schedule one 612 // Don't schedule a draw if we're invisible. We'll schedule one
613 // automatically when we get visible. 613 // automatically when we get visible.
614 if (IsDrawn()) 614 if (IsDrawn())
615 ScheduleDraw(); 615 ScheduleDraw();
616 } else { 616 } else {
617 // Always schedule a paint, even if we're invisible. 617 // Always schedule a paint, even if we're invisible.
618 SchedulePaint(gfx::Rect(bounds.size())); 618 SchedulePaint(gfx::Rect(bounds.size()));
619 } 619 }
620 } 620 }
621 621
622 void Layer::SetTransformImmediately(const ui::Transform& transform) { 622 void Layer::SetTransformImmediately(const gfx::Transform& transform) {
623 transform_ = transform; 623 transform_ = transform;
624 624
625 RecomputeTransform(); 625 RecomputeTransform();
626 } 626 }
627 627
628 void Layer::SetOpacityImmediately(float opacity) { 628 void Layer::SetOpacityImmediately(float opacity) {
629 bool schedule_draw = (opacity != opacity_ && IsDrawn()); 629 bool schedule_draw = (opacity != opacity_ && IsDrawn());
630 opacity_ = opacity; 630 opacity_ = opacity;
631 631
632 if (visible_) 632 if (visible_)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
718 } 718 }
719 web_layer_is_accelerated_ = false; 719 web_layer_is_accelerated_ = false;
720 show_debug_borders_ = CommandLine::ForCurrentProcess()->HasSwitch( 720 show_debug_borders_ = CommandLine::ForCurrentProcess()->HasSwitch(
721 switches::kUIShowLayerBorders); 721 switches::kUIShowLayerBorders);
722 web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f)); 722 web_layer_->setAnchorPoint(WebKit::WebFloatPoint(0.f, 0.f));
723 web_layer_->setOpaque(true); 723 web_layer_->setOpaque(true);
724 web_layer_->setDebugBorderWidth(show_debug_borders_ ? 2 : 0); 724 web_layer_->setDebugBorderWidth(show_debug_borders_ ? 2 : 0);
725 } 725 }
726 726
727 void Layer::RecomputeTransform() { 727 void Layer::RecomputeTransform() {
728 ui::Transform scale_translate; 728 gfx::Transform scale_translate;
729 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0, 729 scale_translate.matrix().set3x3(device_scale_factor_, 0, 0,
730 0, device_scale_factor_, 0, 730 0, device_scale_factor_, 0,
731 0, 0, 1); 731 0, 0, 1);
732 // Start with the inverse matrix of above. 732 // Start with the inverse matrix of above.
733 Transform transform; 733 Transform transform;
734 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0, 734 transform.matrix().set3x3(1.0f / device_scale_factor_, 0, 0,
735 0, 1.0f / device_scale_factor_, 0, 735 0, 1.0f / device_scale_factor_, 0,
736 0, 0, 1); 736 0, 0, 1);
737 transform.ConcatTransform(transform_); 737 transform.ConcatTransform(transform_);
738 transform.ConcatTranslate(bounds_.x(), bounds_.y()); 738 transform.ConcatTranslate(bounds_.x(), bounds_.y());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 return; 778 return;
779 unsigned int color = 0xFF000000; 779 unsigned int color = 0xFF000000;
780 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; 780 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000;
781 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); 781 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f);
782 if (!opaque) 782 if (!opaque)
783 color |= 0xFF; 783 color |= 0xFF;
784 web_layer_->setDebugBorderColor(color); 784 web_layer_->setDebugBorderColor(color);
785 } 785 }
786 786
787 } // namespace ui 787 } // namespace ui
OLDNEW
« no previous file with comments | « ui/compositor/layer.h ('k') | ui/gfx/canvas.h » ('j') | ui/gfx/transform.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698