OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/compositor/compositor.h" | 5 #include "ui/gfx/compositor/compositor.h" |
6 | 6 |
7 #include "ui/gfx/compositor/compositor_observer.h" | 7 #include "ui/gfx/compositor/compositor_observer.h" |
8 #include "ui/gfx/compositor/layer.h" | 8 #include "ui/gfx/compositor/layer.h" |
9 | 9 |
10 namespace ui { | 10 namespace ui { |
11 | 11 |
12 TextureDrawParams::TextureDrawParams() | 12 TextureDrawParams::TextureDrawParams() |
13 : blend(false), | 13 : blend(false), |
14 has_valid_alpha_channel(false), | 14 has_valid_alpha_channel(false), |
15 opacity(1.0f), | 15 opacity(1.0f), |
16 vertically_flipped(false) { | 16 vertically_flipped(false) { |
17 } | 17 } |
18 | 18 |
19 // static | 19 // static |
20 Compositor*(*Compositor::compositor_factory_)(CompositorDelegate*) = NULL; | 20 Compositor*(*Compositor::compositor_factory_)(CompositorDelegate*) = NULL; |
21 | 21 |
22 Compositor::Compositor(CompositorDelegate* delegate, const gfx::Size& size) | 22 Compositor::Compositor(CompositorDelegate* delegate, const gfx::Size& size) |
23 : delegate_(delegate), | 23 : delegate_(delegate), |
24 size_(size), | 24 size_(size), |
25 root_layer_(NULL) { | 25 root_layer_(NULL) { |
26 } | 26 } |
27 | 27 |
28 Compositor::~Compositor() { | 28 Compositor::~Compositor() { |
| 29 if (root_layer_) |
| 30 root_layer_->SetCompositor(NULL); |
29 } | 31 } |
30 | 32 |
31 void Compositor::ScheduleDraw() { | 33 void Compositor::ScheduleDraw() { |
32 delegate_->ScheduleDraw(); | 34 delegate_->ScheduleDraw(); |
33 } | 35 } |
34 | 36 |
35 void Compositor::SetRootLayer(Layer* root_layer) { | 37 void Compositor::SetRootLayer(Layer* root_layer) { |
| 38 if (root_layer_) |
| 39 root_layer_->SetCompositor(NULL); |
36 root_layer_ = root_layer; | 40 root_layer_ = root_layer; |
37 if (!root_layer_->GetCompositor()) | 41 if (!root_layer_->GetCompositor()) |
38 root_layer_->SetCompositor(this); | 42 root_layer_->SetCompositor(this); |
39 OnRootLayerChanged(); | 43 OnRootLayerChanged(); |
40 } | 44 } |
41 | 45 |
42 void Compositor::Draw(bool force_clear) { | 46 void Compositor::Draw(bool force_clear) { |
43 if (!root_layer_) | 47 if (!root_layer_) |
44 return; | 48 return; |
45 | 49 |
(...skipping 27 matching lines...) Expand all Loading... |
73 } | 77 } |
74 | 78 |
75 void Compositor::NotifyEnd() { | 79 void Compositor::NotifyEnd() { |
76 OnNotifyEnd(); | 80 OnNotifyEnd(); |
77 FOR_EACH_OBSERVER(CompositorObserver, | 81 FOR_EACH_OBSERVER(CompositorObserver, |
78 observer_list_, | 82 observer_list_, |
79 OnCompositingEnded(this)); | 83 OnCompositingEnded(this)); |
80 } | 84 } |
81 | 85 |
82 } // namespace ui | 86 } // namespace ui |
OLD | NEW |