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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 parent_->cc_layer_->replaceChild(cc_layer_, new_layer); | 431 parent_->cc_layer_->replaceChild(cc_layer_, new_layer); |
432 } | 432 } |
433 cc_layer_= new_layer; | 433 cc_layer_= new_layer; |
434 cc_layer_is_accelerated_ = layer_updated_externally_; | 434 cc_layer_is_accelerated_ = layer_updated_externally_; |
435 for (size_t i = 0; i < children_.size(); ++i) { | 435 for (size_t i = 0; i < children_.size(); ++i) { |
436 DCHECK(children_[i]->cc_layer_); | 436 DCHECK(children_[i]->cc_layer_); |
437 cc_layer_->addChild(children_[i]->cc_layer_); | 437 cc_layer_->addChild(children_[i]->cc_layer_); |
438 } | 438 } |
439 cc_layer_->setAnchorPoint(gfx::PointF()); | 439 cc_layer_->setAnchorPoint(gfx::PointF()); |
440 cc_layer_->setContentsOpaque(fills_bounds_opaquely_); | 440 cc_layer_->setContentsOpaque(fills_bounds_opaquely_); |
441 cc_layer_->setOpacity(visible_ ? opacity_ : 0.f); | 441 cc_layer_->setOpacity(opacity_); |
| 442 cc_layer_->setVisible(visible_); |
442 cc_layer_->setForceRenderSurface(force_render_surface_); | 443 cc_layer_->setForceRenderSurface(force_render_surface_); |
443 cc_layer_->setIsDrawable(true); | 444 cc_layer_->setIsDrawable(true); |
444 RecomputeTransform(); | 445 RecomputeTransform(); |
445 } | 446 } |
446 RecomputeDrawsContentAndUVRect(); | 447 RecomputeDrawsContentAndUVRect(); |
447 } | 448 } |
448 | 449 |
449 void Layer::SetColor(SkColor color) { | 450 void Layer::SetColor(SkColor color) { |
450 GetAnimator()->SetColor(color); | 451 GetAnimator()->SetColor(color); |
451 } | 452 } |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 void Layer::SetTransformImmediately(const gfx::Transform& transform) { | 639 void Layer::SetTransformImmediately(const gfx::Transform& transform) { |
639 transform_ = transform; | 640 transform_ = transform; |
640 | 641 |
641 RecomputeTransform(); | 642 RecomputeTransform(); |
642 } | 643 } |
643 | 644 |
644 void Layer::SetOpacityImmediately(float opacity) { | 645 void Layer::SetOpacityImmediately(float opacity) { |
645 bool schedule_draw = (opacity != opacity_ && IsDrawn()); | 646 bool schedule_draw = (opacity != opacity_ && IsDrawn()); |
646 opacity_ = opacity; | 647 opacity_ = opacity; |
647 | 648 |
648 if (visible_) | 649 cc_layer_->setOpacity(opacity); |
649 cc_layer_->setOpacity(opacity); | |
650 if (schedule_draw) | 650 if (schedule_draw) |
651 ScheduleDraw(); | 651 ScheduleDraw(); |
652 } | 652 } |
653 | 653 |
654 void Layer::SetVisibilityImmediately(bool visible) { | 654 void Layer::SetVisibilityImmediately(bool visible) { |
655 if (visible_ == visible) | 655 if (visible_ == visible) |
656 return; | 656 return; |
657 | 657 |
658 visible_ = visible; | 658 visible_ = visible; |
659 // TODO(piman): Expose a visibility flag on WebLayer. | 659 cc_layer_->setVisible(visible_); |
660 cc_layer_->setOpacity(visible_ ? opacity_ : 0.f); | |
661 } | 660 } |
662 | 661 |
663 void Layer::SetBrightnessImmediately(float brightness) { | 662 void Layer::SetBrightnessImmediately(float brightness) { |
664 layer_brightness_ = brightness; | 663 layer_brightness_ = brightness; |
665 SetLayerFilters(); | 664 SetLayerFilters(); |
666 } | 665 } |
667 | 666 |
668 void Layer::SetGrayscaleImmediately(float grayscale) { | 667 void Layer::SetGrayscaleImmediately(float grayscale) { |
669 layer_grayscale_ = grayscale; | 668 layer_grayscale_ = grayscale; |
670 SetLayerFilters(); | 669 SetLayerFilters(); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 gfx::PointF uv_bottom_right( | 789 gfx::PointF uv_bottom_right( |
791 static_cast<float>(size.width())/texture_size.width(), | 790 static_cast<float>(size.width())/texture_size.width(), |
792 static_cast<float>(size.height())/texture_size.height()); | 791 static_cast<float>(size.height())/texture_size.height()); |
793 texture_layer_->setUV(uv_top_left, uv_bottom_right); | 792 texture_layer_->setUV(uv_top_left, uv_bottom_right); |
794 | 793 |
795 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); | 794 cc_layer_->setBounds(ConvertSizeToPixel(this, size)); |
796 } | 795 } |
797 } | 796 } |
798 | 797 |
799 } // namespace ui | 798 } // namespace ui |
OLD | NEW |