| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 delegate_(NULL), | 88 delegate_(NULL), |
| 89 scale_content_(true), | 89 scale_content_(true), |
| 90 device_scale_factor_(1.0f) { | 90 device_scale_factor_(1.0f) { |
| 91 CreateWebLayer(); | 91 CreateWebLayer(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 Layer::~Layer() { | 94 Layer::~Layer() { |
| 95 // Destroying the animator may cause observers to use the layer (and | 95 // Destroying the animator may cause observers to use the layer (and |
| 96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer | 96 // indirectly the WebLayer). Destroy the animator first so that the WebLayer |
| 97 // is still around. | 97 // is still around. |
| 98 if (animator_) | 98 animator_.reset(); |
| 99 animator_->SetDelegate(NULL); | |
| 100 animator_ = NULL; | |
| 101 if (compositor_) | 99 if (compositor_) |
| 102 compositor_->SetRootLayer(NULL); | 100 compositor_->SetRootLayer(NULL); |
| 103 if (parent_) | 101 if (parent_) |
| 104 parent_->Remove(this); | 102 parent_->Remove(this); |
| 105 if (layer_mask_) | 103 if (layer_mask_) |
| 106 SetMaskLayer(NULL); | 104 SetMaskLayer(NULL); |
| 107 if (layer_mask_back_link_) | 105 if (layer_mask_back_link_) |
| 108 layer_mask_back_link_->SetMaskLayer(NULL); | 106 layer_mask_back_link_->SetMaskLayer(NULL); |
| 109 for (size_t i = 0; i < children_.size(); ++i) | 107 for (size_t i = 0; i < children_.size(); ++i) |
| 110 children_[i]->parent_ = NULL; | 108 children_[i]->parent_ = NULL; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 for (const Layer* parent = other; parent; parent = parent->parent()) { | 167 for (const Layer* parent = other; parent; parent = parent->parent()) { |
| 170 if (parent == this) | 168 if (parent == this) |
| 171 return true; | 169 return true; |
| 172 } | 170 } |
| 173 return false; | 171 return false; |
| 174 } | 172 } |
| 175 | 173 |
| 176 void Layer::SetAnimator(LayerAnimator* animator) { | 174 void Layer::SetAnimator(LayerAnimator* animator) { |
| 177 if (animator) | 175 if (animator) |
| 178 animator->SetDelegate(this); | 176 animator->SetDelegate(this); |
| 179 animator_ = animator; | 177 animator_.reset(animator); |
| 180 } | 178 } |
| 181 | 179 |
| 182 LayerAnimator* Layer::GetAnimator() { | 180 LayerAnimator* Layer::GetAnimator() { |
| 183 if (!animator_.get()) | 181 if (!animator_.get()) |
| 184 SetAnimator(LayerAnimator::CreateDefaultAnimator()); | 182 SetAnimator(LayerAnimator::CreateDefaultAnimator()); |
| 185 return animator_.get(); | 183 return animator_.get(); |
| 186 } | 184 } |
| 187 | 185 |
| 188 void Layer::SetTransform(const ui::Transform& transform) { | 186 void Layer::SetTransform(const ui::Transform& transform) { |
| 189 GetAnimator()->SetTransform(transform); | 187 GetAnimator()->SetTransform(transform); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 return; | 773 return; |
| 776 unsigned int color = 0xFF000000; | 774 unsigned int color = 0xFF000000; |
| 777 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; | 775 color |= web_layer_is_accelerated_ ? 0x0000FF00 : 0x00FF0000; |
| 778 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); | 776 bool opaque = fills_bounds_opaquely_ && (GetCombinedOpacity() == 1.f); |
| 779 if (!opaque) | 777 if (!opaque) |
| 780 color |= 0xFF; | 778 color |= 0xFF; |
| 781 web_layer_->setDebugBorderColor(color); | 779 web_layer_->setDebugBorderColor(color); |
| 782 } | 780 } |
| 783 | 781 |
| 784 } // namespace ui | 782 } // namespace ui |
| OLD | NEW |