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_owner.h" | 5 #include "ui/compositor/layer_owner.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "ui/compositor/layer_owner_delegate.h" | 10 #include "ui/compositor/layer_owner_delegate.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 std::unique_ptr<Layer> LayerOwner::RecreateLayer() { | 33 std::unique_ptr<Layer> LayerOwner::RecreateLayer() { |
34 std::unique_ptr<ui::Layer> old_layer(AcquireLayer()); | 34 std::unique_ptr<ui::Layer> old_layer(AcquireLayer()); |
35 if (!old_layer) | 35 if (!old_layer) |
36 return old_layer; | 36 return old_layer; |
37 | 37 |
38 LayerDelegate* old_delegate = old_layer->delegate(); | 38 LayerDelegate* old_delegate = old_layer->delegate(); |
39 old_layer->set_delegate(NULL); | 39 old_layer->set_delegate(NULL); |
40 | 40 |
41 const gfx::Rect layer_bounds(old_layer->bounds()); | 41 Layer* new_layer = new ui::Layer(*old_layer); |
42 Layer* new_layer = new ui::Layer(old_layer->type()); | |
43 SetLayer(new_layer); | 42 SetLayer(new_layer); |
44 new_layer->SetVisible(old_layer->GetTargetVisibility()); | |
45 new_layer->SetOpacity(old_layer->GetTargetOpacity()); | |
46 new_layer->SetBounds(layer_bounds); | |
47 new_layer->SetMasksToBounds(old_layer->GetMasksToBounds()); | |
48 new_layer->set_name(old_layer->name()); | |
49 new_layer->SetFillsBoundsOpaquely(old_layer->fills_bounds_opaquely()); | |
50 new_layer->SetFillsBoundsCompletely(old_layer->FillsBoundsCompletely()); | |
51 new_layer->SetSubpixelPositionOffset(old_layer->subpixel_position_offset()); | |
52 new_layer->SetLayerInverted(old_layer->layer_inverted()); | |
53 new_layer->SetTransform(old_layer->GetTargetTransform()); | |
54 if (old_layer->type() == LAYER_SOLID_COLOR) | |
55 new_layer->SetColor(old_layer->GetTargetColor()); | |
56 SkRegion* alpha_shape = old_layer->alpha_shape(); | |
57 if (alpha_shape) | |
58 new_layer->SetAlphaShape(base::MakeUnique<SkRegion>(*alpha_shape)); | |
59 | 43 |
60 if (old_layer->parent()) { | 44 if (old_layer->parent()) { |
61 // Install new layer as a sibling of the old layer, stacked below it. | 45 // Install new layer as a sibling of the old layer, stacked below it. |
62 old_layer->parent()->Add(new_layer); | 46 old_layer->parent()->Add(new_layer); |
63 old_layer->parent()->StackBelow(new_layer, old_layer.get()); | 47 old_layer->parent()->StackBelow(new_layer, old_layer.get()); |
64 } else if (old_layer->GetCompositor()) { | 48 } else if (old_layer->GetCompositor()) { |
65 // If old_layer was the layer tree root then we need to move the Compositor | 49 // If old_layer was the layer tree root then we need to move the Compositor |
66 // over to the new root. | 50 // over to the new root. |
67 old_layer->GetCompositor()->SetRootLayer(new_layer); | 51 old_layer->GetCompositor()->SetRootLayer(new_layer); |
68 } | 52 } |
(...skipping 21 matching lines...) Expand all Loading... |
90 void LayerOwner::DestroyLayer() { | 74 void LayerOwner::DestroyLayer() { |
91 layer_ = NULL; | 75 layer_ = NULL; |
92 layer_owner_.reset(); | 76 layer_owner_.reset(); |
93 } | 77 } |
94 | 78 |
95 bool LayerOwner::OwnsLayer() const { | 79 bool LayerOwner::OwnsLayer() const { |
96 return !!layer_owner_; | 80 return !!layer_owner_; |
97 } | 81 } |
98 | 82 |
99 } // namespace ui | 83 } // namespace ui |
OLD | NEW |