| 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 namespace ui { | 7 namespace ui { |
| 8 | 8 |
| 9 LayerOwner::LayerOwner() | 9 LayerOwner::LayerOwner() : layer_(NULL) { |
| 10 : layer_(NULL) { | |
| 11 } | 10 } |
| 12 | 11 |
| 13 LayerOwner::~LayerOwner() { | 12 LayerOwner::~LayerOwner() { |
| 14 } | 13 } |
| 15 | 14 |
| 15 void LayerOwner::SetLayer(Layer* layer) { |
| 16 DCHECK(!OwnsLayer()); |
| 17 layer_owner_.reset(layer); |
| 18 layer_ = layer; |
| 19 layer_->owner_ = this; |
| 20 } |
| 21 |
| 16 Layer* LayerOwner::AcquireLayer() { | 22 Layer* LayerOwner::AcquireLayer() { |
| 17 return layer_owner_.release(); | 23 return layer_owner_.release(); |
| 18 } | 24 } |
| 19 | 25 |
| 26 void LayerOwner::DestroyLayer() { |
| 27 layer_ = NULL; |
| 28 layer_owner_.reset(); |
| 29 } |
| 30 |
| 31 bool LayerOwner::OwnsLayer() const { |
| 32 return !!layer_owner_; |
| 33 } |
| 34 |
| 20 } // namespace ui | 35 } // namespace ui |
| OLD | NEW |